返回错误:BEP-20 代币交易中的交易价格过低
Posted
技术标签:
【中文标题】返回错误:BEP-20 代币交易中的交易价格过低【英文标题】:Returned error: transaction underpriced in BEP-20 Token transaction 【发布时间】:2021-09-23 22:32:08 【问题描述】:我尝试使用 web3.js 转移我的 BEP-20 令牌
我部署了新的 BEP-20 令牌,并且可以使用 MetaMask 将令牌发送到另一个地址。
我尝试在 nodejs 中传输。我按照指南发送令牌。
下面是我的代码
const sendBEP20Transaction = async () =>
var Web3 = require('web3');
var web3 = new Web3(new Web3.providers.HttpProvider('https://bsc-dataseed1.binance.org'))
var myAddress = '0xF3b6A45AFbC5892a70EA7ca5b10d61A500BeCeC1';
var toAddress = '0xa5915F48DDD3A7D25Daf1AeBd5Df677389b679bA';
var privateKey = 'd5...';
var abiArray = [...];
var contractAddress = '0xcB39dAF817EC0BaDDF78719dA24768b3fe81A7b5';
var amount = web3.utils.toHex(10)
var count;
await web3.eth.getTransactionCount(myAddress).then(function (v)
console.log('count: ', v);
count = v
)
let account = web3.eth.accounts.wallet.add(privateKey);
var contract = new web3.eth.Contract(abiArray, contractAddress,
from: myAddress,
gasPrice: web3.utils.toHex(5),
gasLimit: web3.utils.toHex(80000),
)
contract.methods.transfer(toAddress, amount).send(
from: '0xF3b6A45AFbC5892a70EA7ca5b10d61A500BeCeC1',
gasPrice: web3.utils.toHex(5),
gasLimit: web3.utils.toHex(80000),
)
.then()
.catch(console.error);
当我运行此代码时,我收到错误“返回错误:交易价格过低”
Error: Returned error: transaction underpriced
at Object.ErrorResponse (F:\bep20_test\node_modules\web3-core-helpers\lib\errors.js:28:19)
at F:\bep20_test\node_modules\web3-core-requestmanager\lib\index.js:304:36
at XMLHttpRequest.request.onreadystatechange (F:\bep20_test\node_modules\web3-providers-http\lib\index.js:98:13)
at XMLHttpRequestEventTarget.dispatchEvent (F:\bep20_test\node_modules\xhr2-cookies\dist\xml-http-request-event-target.js:34:22)
at XMLHttpRequest._setReadyState (F:\bep20_test\node_modules\xhr2-cookies\dist\xml-http-request.js:208:14)
at XMLHttpRequest._onHttpResponseEnd (F:\bep20_test\node_modules\xhr2-cookies\dist\xml-http-request.js:318:14)
at IncomingMessage.<anonymous> (F:\bep20_test\node_modules\xhr2-cookies\dist\xml-http-request.js:289:61)
at IncomingMessage.emit (events.js:327:22)
at endReadableNT (internal/streams/readable.js:1327:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
data: null
请大家帮帮我,谢谢
【问题讨论】:
【参考方案1】:当您尝试替换交易并且替换的gas价格太低时,会发生“交易低估”错误。
解决方案和深入解释见此:
transaction underpriced in BEP-20 Token transaction
【讨论】:
以上是关于返回错误:BEP-20 代币交易中的交易价格过低的主要内容,如果未能解决你的问题,请参考以下文章
如何计算 BSC (BEP-20) 区块链中 USDT 等代币交易的 gasLimit?