0

The code is based on ethers.js. meBid is a function in a contract which places bid for user. Here is the function declaration in contract:

function meBid(address _bidItemAddress) external noBidder notComplete notDelisted returns (bool) { ....}

Here is how the function is called in React Native app with ethers:

import { ContractFactory, ethers } from "ethers";
let chres = await postContract.meBid(_trade.deployed_address);  //postContract is the contract and is valid
postContract.on("_meBid", async () => {
  //handle event after bid success.
})

Here is the return value of chres:

LOG  chainres :  {"chainId": 2018, "confirmations": 0, "data": "0x3ab0a29a00000000000000000000000089e10fa7794ac05ac820e9b0b68d4107f6509", "from": "0x882C5329a8fFe6570839eafF91e40cc5473063e0", "gasLimit": {"hex": "0x667b", "type": "BigNumber"}, "gasPrice": {"hex": "0x00", "type": "BigNumber"}, "hash": "0x8b4d1f1244e99859fcb1136b34f60413e9fe0d708f9c654a0072dbcefe3d7", "nonce": 122, "r": "0x2226e1b203e0b8902d064e8212d272fe8ee2894d6d86b45b7dd5c04cd663aa", "s": "0x4297e6a1004a20563a1de85a7a8db48e2ce12bd4b5fe247d124df4556509d0", "to": "0xadB0e387B5C600e4e01F4574A2116cD3df0fB", "type": null, "v": 4071, "value": {"hex": "0x00", "type": "BigNumber"}, "wait": [Function anonymous]}

But the _meBid event never called which means the function call to meBid didn't go through well. I check the Besu server log and didn't find any error on chain. The only thing I have is the value of chres. How to pin point the error here?

1 Answer 1

1

You are setting the listener for the event "_meBid" after awaiting the call to be mined. In order to listen for it setup the listener beforehand.

//postContract is the contract and is valid
postContract.on("_meBid", async () => {
  //handle event after bid success.
})
let chres = await postContract.meBid(_trade.deployed_address);  

Another options is to search the transaction receipt for the event.

let chres = await postContract.meBid(_trade.deployed_address);

// Search in chres for the event

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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