Ethereum error ( VM Exception while processing transaction revert )

I am trying to call transfer of an ERC20 contract with following code. my environment is Geneche-cli and Node with Web3 installed. THe application is console but later this function will be used in web application. Please give me some hints how to handle this. Here is the function and then by calling this function i got error presented at end

sendTokens: function(fromAddress, sendAddress, amountToSend, abi, contractAddress, web3Address) {

return new Promise(function(resolve, reject) {

var web3 = new Web3(new Web3.providers.HttpProvider(web3Address));

if(web3.isConnected()) {




var count = web3.eth.getTransactionCount(fromAddress);
var contract = web3.eth.contract(abi).at(contractAddress);
var rawTransaction = {
"from": fromAddress,
"nonce": web3.toHex(count+1),
"gasPrice": "0x04e3b29200",
"gasLimit": "0x7458",
"to": contractAddress,
"value": "0x0",
"data": contract.transfer(sendAddress, 10, {from: fromAddress}),
"chainId": 0x03
};

var privKey = new Buffer.from('c0270793c6d211618dbef578aa380e744547e417e21fb295235ee2d4c94cd04e', 'hex');
var tx = new ethereumjs(rawTransaction);

tx.sign(privKey);
var serializedTx = tx.serialize();


web3.eth.sendRawTransaction('0x' + serializedTx.toString('hex'), function(err, hash) {
if (!err)
console.log(hash);
else
console.log(err);
});


} else {
resolve({"code":"0", "message":"connection error"})
}

})

},
And this is Error

Error: VM Exception while processing transaction: revert
at Object.InvalidResponse (F:\Projects\work\GS\BlockchainSettings\node_modules\web3\lib\web3\errors.js:38:16)
at F:\Projects\work\GS\BlockchainSettings\node_modules\web3\lib\web3\requestmanager.js:86:36
at XMLHttpRequest.request.onreadystatechange (F:\Projects\work\GS\BlockchainSettings\node_modules\web3\lib\web3\httpprovider.js:129:7)
at XMLHttpRequestEventTarget.dispatchEvent (F:\Projects\work\GS\BlockchainSettings\node_modules\xhr2-cookies\dist\xml-http-request-event-target.js:34:22)
at XMLHttpRequest._setReadyState (F:\Projects\work\GS\BlockchainSettings\node_modules\xhr2-cookies\dist\xml-http-request.js:208:14)
at XMLHttpRequest._onHttpResponseEnd (F:\Projects\work\GS\BlockchainSettings\node_modules\xhr2-cookies\dist\xml-http-request.js:318:14)
at IncomingMessage. (F:\Projects\work\GS\BlockchainSettings\node_modules\xhr2-cookies\dist\xml-http-request.js:289:61)
at IncomingMessage.emit (events.js:187:15)
at endReadableNT (_stream_readable.js:1094:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
Sign In or Register to comment.