i'm doing this send function

let result = await myContract.methods.myMethod().send({from: account});
console.log("result:", result);

using web3.js ^1.2.2 on testRPC with Ganache, hardfork Byzantium, solc compiler version 0.5.2

I expected to see in the result object the new object "receipt" with the "status" attribute, instead i receive this object:

  transactionHash: '0x13491851ee14dddab1be3112cd9ed01a4829d69b1ca304085acd165ec35ba80f',
  transactionIndex: 0,
  blockHash: '0x4de0f8b5e1a47e630f417d6c2d5ca6af5bac2010313c76cb8ebd8752f425fb05',      
  blockNumber: 20,
  from: '0x9f93725aaff6f60d507ae6b2636bcd222eb8e19a',
  to: '0xe3f2c9598a82200e187bf927ecc9a7ed8b0dae55',
  gasUsed: 48769,
  cumulativeGasUsed: 48769,
  contractAddress: null,
  status: true,
  logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
  v: '0x1b',
  r: '0xdfd2b3195e7df3790d3acfbc15787f38ddeacb15de857e36a8d1c71328c6f616',
  s: '0x35bb958464b4e21f539f8aa11dc509d49dee04da0be758ae8762922f79e6b5f5',
  events: {}

unfortunately i have a constraint to read result.receipt.status, so i need the object made in that way.

Any suggestion? Thanks in advance

  • What version of ganache are you using? What command line do you use to launch ganache? From the output it appears you are printing the receipt, since it has gasUsed, events and status. Can you try with latest version of web3.js 1.2.6? – Ismael Apr 4 '20 at 3:55

This IS the receipt.

In web3.js v0.x, you get an object:

    tx: ...
    receipt: {
        status: ...

So you use result.receipt.status in order to get the status.

In web3.js v1.x, you get an object:

    status: ...

So you use result.status in order to get the status.

  • i just tried with web3.js v0.x but instead of he result object expected, it only returns the tx hash – spawn85 Apr 3 '20 at 10:54
  • @spawn85: Either await for the receipt (i.e., resolve the promise), or catch it via the .on('receipt') callback. – goodvibration Apr 3 '20 at 10:58
  • already tried of course with await but got just tx hash, also tried .on('receipt') but doesn't seem to be supported on web3.js v0.x . i was able to get the same object using await this.web3.eth.getTransactionReceipt(txHash) but is not what i'm looking for – spawn85 Apr 3 '20 at 11:32
  • @spawn85: You'll need to better explain what exactly prevents you from replacing result.receipt.status with result.status. – goodvibration Apr 3 '20 at 12:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.