1

I am using

const decodedEvent = Abi.decodeEvent(Uint8Array.from(Buffer.from("00000064a7b3b6e00d000000000000000000000000000000000000000000000000", 'hex'))) 
(00000064a7b3b6e00d000000000000000000000000000000000000000000000000 is the data in the contracts::contractemitted event.)

But I cannot access the actual argument values, only their types. I'd like to be able to access the values when decoding the event. What am I missing?

Here's the decodedEvent.event.args enter image description here

Currently when accessing the decodedEvent.event.args, I only see the names and types. Where can I access the values?

1
  • Did you check the content of decodedEvent.event.data?
    – Achim
    Commented Oct 8, 2022 at 10:31

2 Answers 2

1

IIRC the values should be in decodedEvent.args.

2
  • it isn't there, could it be due to an incorrect abi?
    – Ayudh
    Commented Sep 8, 2022 at 8:51
  • Might be the case, but I'm not sure. Commented Sep 8, 2022 at 9:30
1

I use this:

if (result.status.isInBlock) {

  result.events.forEach(({event, phase, topics}) => {

    if (api.events.contracts.ContractEmitted.is(event)) {

      const [account_id, contract_event] = event.data

      let decoded = new Abi(metadata).decodeEvent(contract_event)
      decoded = JSON.parse(JSON.stringify(decoded));

      console.log(decoded)
    }
  });
}

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.