Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sendSignedTransaction error EVM revert on kovan (infura) #3713

Closed
LouisHatte opened this issue Sep 8, 2020 · 1 comment
Closed

sendSignedTransaction error EVM revert on kovan (infura) #3713

LouisHatte opened this issue Sep 8, 2020 · 1 comment

Comments

@LouisHatte
Copy link

LouisHatte commented Sep 8, 2020

Expected behavior

I want to send a successful transaction with web3.eth.sendSignedTransaction on kovan network.

Actual behavior

I get this non explicit error: Error: Transaction has been reverted by the EVM.
The Smart Contract Token I use works with Metamask.
Without Metamask I can call read methods from my Smart Contract like: token.methods.balanceOf(tmpAddr).call().

Steps to reproduce the behavior

tmpAddress = '0x0267f6d34bf659cf2d0a68a3bf9ca9e863d037bb'
tmpPrivateKey = Buffer.from(..., 'hex')

token = new web3.eth.Contract(Token.abi, networks[kovan_network_id].address, { from: tmpAddress })

const withdrawBlinkAbi = token.methods.withdrawBlink().encodeABI()

nonce = await web3.eth.getTransactionCount(tmpAddress)

const txParams = {
    nonce: web3.utils.toHex(nonce),
    gasPrice: web3.utils.toHex(web3.utils.toWei('87', 'gwei')),
    gasLimit: web3.utils.toHex('21064'),
    to: token.options.address,
    value: web3.utils.toHex(web3.utils.toWei('0.1', 'ether')),
    data: withdrawBlinkAbi,
}
console.log('txParams: ', txParams)

const tx = new EthereumTx(txParams, { chain: 'kovan' })
tx.sign(tmpPrivateKey)
const serializedTx = tx.serialize()

await web3.eth.sendSignedTransaction('0x' + serializedTx.toString('hex'), (err, res) => {
        console.log('response: ' + res)
}).once('transactionHash', function(hash) {
    console.log('(1) hash: ', hash)
}).once('receipt', function(receipt) {
    console.log('(2) receipt: ', receipt)
}).on('confirmation', function(confNumber, receipt) {
    console.log('(3) confNumber: ', confNumber)
}).on('error', function(error) {
    console.log('(4) error: ', error)
}).then(function(receipt) {
    console.log('(5) receipt: ', receipt)
})

Logs

console.log('txParams: ', txParams):

tx parameters:  { nonce: '0xc',
gasPrice: '0x14419aa600',
gasLimit: '0x5248',
to: '0x2dd1FF7F65721e6E7A3e38b20f17449b837fa875',
value: '0x16345785d8a0000',
data: '0x74ac2303' }

console.log('response: ' + res)
``
for example: 0xc133b91c994992fef71e9fd4397daabd3d9a269c240d474176ca9221cd1b8095

error:

(1) hash:  0x959655b2e1d9cac6a2f4b31c8b68804ee021a2f1c2b753122eef62ba64b569f7
API_dev        | (3) confNumber:  0
API_dev        | (4) error:  { Error: Transaction has been reverted by the EVM:
API_dev        | {
API_dev        |   "blockHash": "0xc1d1037d3a27f3573ff416385b3bd85947b15b6d10c3786a426c03147e32a3e1",
API_dev        |   "blockNumber": 20784047,
API_dev        |   "contractAddress": null,
API_dev        |   "cumulativeGasUsed": 21064,
API_dev        |   "from": "0x0267f6d34bf659cf2d0a68a3bf9ca9e863d037bb",
API_dev        |   "gasUsed": 21064,
API_dev        |   "logs": [],
API_dev        |   "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
API_dev        |   "root": null,
API_dev        |   "status": false,
API_dev        |   "to": "0x2dd1ff7f65721e6e7a3e38b20f17449b837fa875",
API_dev        |   "transactionHash": "0x959655b2e1d9cac6a2f4b31c8b68804ee021a2f1c2b753122eef62ba64b569f7",
API_dev        |   "transactionIndex": 0
API_dev        | }
API_dev        |     at Object.TransactionError (/usr/src/app/node_modules/web3-core-helpers/src/errors.js:96:21)
API_dev        |     at Object.TransactionRevertedWithoutReasonError (/usr/src/app/node_modules/web3-core-helpers/src/errors.js:108:21)
API_dev        |     at /usr/src/app/node_modules/web3-core-method/src/index.js:482:48
API_dev        |     at <anonymous>
API_dev        |     at process._tickCallback (internal/process/next_tick.js:189:7)
API_dev        |   receipt: 
API_dev        |    { blockHash: '0xc1d1037d3a27f3573ff416385b3bd85947b15b6d10c3786a426c03147e32a3e1',
API_dev        |      blockNumber: 20784047,
API_dev        |      contractAddress: null,
API_dev        |      cumulativeGasUsed: 21064,
API_dev        |      from: '0x0267f6d34bf659cf2d0a68a3bf9ca9e863d037bb',
API_dev        |      gasUsed: 21064,
API_dev        |      logs: [],
API_dev        |      logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
API_dev        |      root: null,
API_dev        |      status: false,
API_dev        |      to: '0x2dd1ff7f65721e6e7a3e38b20f17449b837fa875',
API_dev        |      transactionHash: '0x959655b2e1d9cac6a2f4b31c8b68804ee021a2f1c2b753122eef62ba64b569f7',
API_dev        |      transactionIndex: 0 } }
API_dev        | (node:323) UnhandledPromiseRejectionWarning: Error: Transaction has been reverted by the EVM:
API_dev        | {
API_dev        |   "blockHash": "0xc1d1037d3a27f3573ff416385b3bd85947b15b6d10c3786a426c03147e32a3e1",
API_dev        |   "blockNumber": 20784047,
API_dev        |   "contractAddress": null,
API_dev        |   "cumulativeGasUsed": 21064,
API_dev        |   "from": "0x0267f6d34bf659cf2d0a68a3bf9ca9e863d037bb",
API_dev        |   "gasUsed": 21064,
API_dev        |   "logs": [],
API_dev        |   "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
API_dev        |   "root": null,
API_dev        |   "status": false,
API_dev        |   "to": "0x2dd1ff7f65721e6e7a3e38b20f17449b837fa875",
API_dev        |   "transactionHash": "0x959655b2e1d9cac6a2f4b31c8b68804ee021a2f1c2b753122eef62ba64b569f7",
API_dev        |   "transactionIndex": 0
API_dev        | }
API_dev        |     at Object.TransactionError (/usr/src/app/node_modules/web3-core-helpers/src/errors.js:96:21)
API_dev        |     at Object.TransactionRevertedWithoutReasonError (/usr/src/app/node_modules/web3-core-helpers/src/errors.js:108:21)
API_dev        |     at /usr/src/app/node_modules/web3-core-method/src/index.js:482:48
API_dev        |     at <anonymous>
API_dev        |     at process._tickCallback (internal/process/next_tick.js:189:7)
API_dev        | (node:323) 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: 6)

Environment

Node: v10.19.0
web3.js: ^1.2.6
web3-eth: ^1.2.7
ethereumjs-tx: ^2.1.2

OS: Ubuntu 20

@LouisHatte
Copy link
Author

My gasLimit was too low...

Now it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant