![](/img/trans.png)
[英]Error: Transaction has been reverted by the EVM while sending transaction via ropsten infura testnet
[英]Web3 Error: Transaction has been reverted by the EVM:
我對使用 Web3 相當陌生。
我正在嘗試測試為智能合約(ERC20 硬幣)購買的功能。 我已經測試了這段代碼,將以太幣從一個錢包發送到另一個錢包,它成功了。 現在,每當我嘗試與智能合約交互(發送已簽名的交易以購買代幣)時,我都會收到此錯誤消息:
錯誤:事務已被 EVM 還原:
這就是它在 etherscan rinkeby 上的顯示方式
這是我的代碼
var rawTx = {
nonce : nxn,
gasPrice: web3.utils.toHex(web3.utils.toWei('3000', 'gwei')),
gasLimit: '0x5208',
to: '0x40d3b2f06f198d2b789b823cdbecd1db78090d74',
value: web3.utils.toHex(web3.utils.toWei('0.002', "ether")),
data : '0x',
}
var tx = new Tx(rawTx,{chain:'rinkeby', hardfork: 'petersburg'});
tx.sign(privateKey);
var serializedTx = tx.serialize();
await web3.eth.sendSignedTransaction('0x' + serializedTx.toString('hex'))
.on('receipt', console.log);
如果你正在做 Dapp 大學教程,我認為問題出在與 initialSupply 的合同中。 查看構造函數是否采用任何參數。
這意味着智能合約確實為您的交易revert()
,通常是通過失敗的require()
行。 其他原因包括試圖對不接受付款的智能合約進行應付交易。
如果沒有智能合約源代碼,就不可能知道是什么導致了恢復。
我對使用Web3相當陌生。
我正在嘗試測試可以購買智能合約(ERC20代幣)的功能。 我已經測試了這段代碼,將以太幣從一個錢包發送到另一個錢包,它成功了。 現在,每當我嘗試與智能合約進行交互(發送已簽名的交易以購買硬幣)時,都會出現此錯誤:
錯誤:事務已被EVM恢復:
這就是它在etherscan rinkeby上的顯示方式
這是我的代碼
var rawTx = {
nonce : nxn,
gasPrice: web3.utils.toHex(web3.utils.toWei('3000', 'gwei')),
gasLimit: '0x5208',
to: '0x40d3b2f06f198d2b789b823cdbecd1db78090d74',
value: web3.utils.toHex(web3.utils.toWei('0.002', "ether")),
data : '0x',
}
var tx = new Tx(rawTx,{chain:'rinkeby', hardfork: 'petersburg'});
tx.sign(privateKey);
var serializedTx = tx.serialize();
await web3.eth.sendSignedTransaction('0x' + serializedTx.toString('hex'))
.on('receipt', console.log);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.