TransWikia.com

web3 erroneously returning error

Ethereum Asked by bitsanity on January 5, 2022

This is strange. My web3 script to deploy a contract seems to work, but always activates the .on(‘error’, fcn) clause even though there is no error.

The message says Transaction has been reverted by the EVM but it has not really been reverted. It returns the contract address, the contract is there and I can call it with other scripts.

Code:

con
  .deploy({data:getBinary()} )
  .send({from: eb, gas: 1000000, gasPrice: gprice}, (err, txhash) => {
    if (txhash) console.log( "sent txhash: ", txhash );
  } )
  .on('error', (err) => { console.log("borked: ", err); })
  .on('transactionHash', (h) => { console.log( "hash: ", h ); } )
  .on('receipt', (r) => { console.log( 'rcpt: ' + r.contractAddress); } )
  .on('confirmation', (cn, rcpt) => { console.log( 'cn: ', cn ); } )
  .then( (con) => {
    console.log( "SCA", con.options.address );
    process.exit(0);
  } )
  .catch( err => { console.log } );

Result:

$ node cli.js 0 0 0 deploy
sent txhash:  0x73c25e524056d76937429a92349f019d436c452b006cb4178e4170e5b24aa5b4
hash:  0x73c25e524056d76937429a92349f019d436c452b006cb4178e4170e5b24aa5b4
borked:  Error: Transaction has been reverted by the EVM:
{
  "transactionHash": "0x73c25e524056d76937429a92349f019d436c452b006cb4178e4170e5b24aa5b4",
  "transactionIndex": 0,
  "blockHash": "0xa7afc701efd8fcc397536f018a3307c5d38d6031431c3887298693a9b11edfc0",
  "blockNumber": 6,
  "gasUsed": "0x0b60fa",
  "cumulativeGasUsed": "0x0b60fa",
  "contractAddress": "0x786a010206921e8ea1181d86da22adbd87259d33",
  "logs": [],
  "status": "0x01",
  "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  "to": null
}
    at TransactionReceiptValidator.validate (/home/skull/node_modules/web3-core-method/dist/web3-core-method.cjs.js:146:16)
    at /home/skull/node_modules/web3-core-method/dist/web3-core-method.cjs.js:44:68
    at process._tickCallback (internal/process/next_tick.js:109:7)

2 Answers

Had the same problem but I needed to upgrade Ganache 1.1.0 to 1.3.0 until I got rid of the EVM error message.

Answered by Pertti 'Petteri' Martikainen on January 5, 2022

upgrade ganache-cli separately from web3 and truffle

Answered by bitsanity on January 5, 2022

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP