I am trying to transfer a erc20 token.
const data = contract.methods.transfer(recipient, amount).encodeABI();
const rawTx = {
from: sender,
nonce: '0x' + count.toString(16),
gasPrice: this.web3.utils.toHex(2000000000),
gasLimit: estimateGas,
to: contracts.address,
value: '0x0',
data: data,
chainId: '0x' + contracts.chainId
};
console.log(rawTx);
const privKeyBuffer = new Buffer.from(senderPrivateKey, 'hex');
const tx = new EthereumTx(rawTx);
tx.sign(privKeyBuffer);
const serializedTx = tx.serialize();
const signedTransaction = '0x' + serializedTx.toString('hex');
console.log(signedTransaction);
but when I try to trace_rawTransaction
, to see if the transaction is alright, I get this output:
{
"jsonrpc": "2.0",
"result": {
"output": "0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001e536166654d6174683a207375627472616374696f6e206f766572666c6f770000",
"stateDiff": null,
"trace": [
{
"action": {
"callType": "call",
"from": "0x...",
"gas": "0x7470",
"input": "0xa9059cbb0000000000000000000000004b346650ea60d22583c9e47a44b49120ae2638250000000000000000000000000000000000000000000000000de0b6b3a7640000",
"to": "0x...",
"value": "0x0"
},
"error": "Reverted",
"subtraces": 0,
"traceAddress": [],
"type": "call"
}
],
"vmTrace": null
},
"id": 1
}
The output is :
SafeMath: subtraction overflow
What is happening?
data
??? – goodvibration Oct 13 '19 at 5:25transfer
? (I'm trying to guide you to the point where you realize that the subtraction overflow is in that function, where you should be able to easily understand why you're getting it). – goodvibration Oct 14 '19 at 7:40