In my contract interaction with web3js I have a

.once("receipt", async (receipt) => {
                    console.log("receipt:", receipt);

I run this with a firebase function. The receipt shows stuff like the transactionhash, to, status, logbloom, blockhash etc. etc. However there is no eventsobject in there where i can check the return values my event is supposed to give:

event BetCompleted(uint256 indexed betId, address indexed winner, uint256 amount);

I've also read that the logs[0].topics is related to the events which looks to contain 3 adresses in my receipt.

Does anyone know what i'm doing wrong / how to read the event through the receipt?


1 Answer 1


You should have a receipt.logs array. If it's empty it means no event was emitted.

If BetCompleted was emitted than receipt.logs should have a element log with the following fields:

  • address: the address of the contract that emitted it.
  • topics[0] = web3.utils.sha3("BetCompleted(uint256,address,uint256)") = 0x8a204c2634e61fa974cd81173313c7f47ce714e2bfe11f395233a751f52b0445. This identifies the event.
  • topics[1]: betId as a uint256.
  • topics[2]: winner as an address padded with 0.
  • data: amount as a uint256.
  • 1
    Late response but sweet, this helped me figure out to decode the event :) Jul 13, 2023 at 7:00

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.