1

I have of a contract and I am using it to construct Contract instance of :

const pairContract = new web3.eth.Contract(ABI_JSON);

Reading the documentation, I see that there is a contract.events property, which should give me access to computed signature, e.g.

pairContract.events;

{
  Sync: [Function: bound ],
  '0x1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1': [Function: bound ],
}

I want to get signature for the Sync event. How do I do this?

To be clear, I know that I can calculate the signature myself if I know the event name and parameter names, e.g.

web3.utils.sha3('Sync(uint112,uint112)')

The question is only if provides a convenient way to get event signature just by knowing the event name.

1 Answer 1

1

Turns out options holds computed values:

pairyContract.options.jsonInterface.find((token) => {
  return token.type === 'event' && token.name === 'Sync';
});

Result:

{
  anonymous: false,
  inputs: [
    {
      indexed: false,
      internalType: 'uint112',
      name: 'reserve0',
      type: 'uint112'
    },
    {
      indexed: false,
      internalType: 'uint112',
      name: 'reserve1',
      type: 'uint112'
    }
  ],
  name: 'Sync',
  type: 'event',
  constant: undefined,
  payable: undefined,
  signature: '0x1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1'
}

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.