I have an error after I send signedTransaction
always return error node:
(node:16924) UnhandledPromiseRejectionWarning: Error: Transaction has been reverted by the EVM: { "blockHash": ........
look my code and error:
CODE:
var Web3 = require('web3')
var web3= new Web3(new
Web3.providers.HttpProvider('https://mainnet.infura.io/v3/.....'))
var tokenABI=[{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"},{"name":"_extraData","type":"bytes"}],"name":"approveAndCall","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"},{"name":"","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"}]
var contractAddr='0x63C94B6221B4021b564F4563ec72688655b2604A'
var destinityAddr='0xaB3C01D51B6E301dA185601BFEe39AE29F6C16ce'
var pKey='xxxxxxxx' //private key
var sendingAddr='0x14e56f3C2C4736181cEEE69FDb5F89847f42a9AF'
var nonces=""
web3.eth.getTransactionCount(sendingAddr,function(err,res){nonces=res})
var myContractes= new web3.eth.Contract(tokenABI,contractAddr)
var Tx= require('ethereumjs-tx')
var dataso= myContractes.methods.transfer(destinityAddr,web3.utils.toHex(1e18)).encodeABI()
var rawTx={nonce:nonces,gasPrice:web3.utils.toHex('20000000000'),gasLimit:web3.utils.toHex('21000'),to:contractAddr,value:0,data:dataso}
var tx= new Tx(rawTx)
var privateKeyBuffer= Buffer.from(pKey,'hex')
tx.sign(privateKeyBuffer)
var serializedTx=tx.serialize()
//and here sent signed transaction
web3.eth.sendSignedTransaction('0x'+serializedTx.toString('hex'),function(err,hash){console.log(hash)}else{console.log(err)})
and when I executed shows the hash: 0x48b75130d6041d8ff19c063892e77dc4c7e2d5a94049a5a8ab4de6ee054cbc19
all is OK till here, however after waiting some seconds it always breaks and shows an error:
ERROR:
(node:16924) UnhandledPromiseRejectionWarning: Error: Transaction has been reverted by the EVM: { "blockHash": "0xe458f379a150700e1fd32209d0d52d7348b2005bb010785bf22c5f629bd70922", "blockNumber": 6793039, "contractAddress": null, "cumulativeGasUsed": 2460800, "from": "0x14e56f3c2c4736181ceee69fdb5f89847f42a9af", "gasUsed": 23920, "logs": [], "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "status": false, "to": "0x63c94b6221b4021b564f4563ec72688655b2604a", "transactionHash": "0x48b75130d6041d8ff19c063892e77dc4c7e2d5a94049a5a8ab4de6ee054cbc19", "transactionIndex": 43 } at /home/markus/Documents/wallets/node_modules/web3-core-method/src/index.js:364:46 at process._tickCallback (internal/process/next_tick.js:68:7) (node:16924) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:16924) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I spend a lot of time, read in every website and there are no solution, how can I solve this issue?