2

for example: I am a multisig signer. And I want to decode the call data that is used to call a specific smart contract.

example on smart contract : 0x02f0826ef6aD107Cfc861152B32B52fD11BaB9ED (WNat) I want to decode this call data: 0x2e1a7d4d000000000000000000000000000000000000000000000001158e460913d00000

Is there a way to decode this call in order to see the transaction details.

another example: if I want to decode a pre signed transaction. to make sure it has the correct values.

1

To decode calls on Songbird network you can use this tool: https://decoder.aflabs.si/.

It uses the songbird explorer to get contract ABI from the contract's address and then decodes the function call and its parameters. In your example it works as expected:

Decoded contract call

1
  • Thanks very helpful Nov 4 '21 at 13:07
1

Just adding to the previous answer to help people understand how to interpret the encoding.

The call data is composed of 2 parts :

  1. Function selector (4 first bytes)
  2. Parameters (everything after the 4 first bytes)

The function selector is the 4 first bytes of the keccack-256 of the function signature hash:

The function: withdraw(uint256 _amount) signature is withdraw(uint256):

keccack256 of withdraw(uint256) is :

2e1a7d4d13322e7b96f9a57413e1525c250fb7a9021cf91d1540d5b69f16a49f

The first 4 bytes are : 2e1a7d4d matching the first 4 bytes of your calldata.

Next, we know from the signature that this function accepts one parameter of type uint256 (so 32 bytes).

This parameter is encoded in the call data as : 000000000000000000000000000000000000000000000001158e460913d00000

converting this Hex representation to decimals we get :

20000000000000000000

So we can conclude that the calldata targetted the withdraw function with an amount of 20000000000000000000 as parameter.

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.