0

Using this transaction: https://polygonscan.com/tx/0x1b4165c1093936b74803666c75edd720fbd1713b5f77160e3a726299fb04078d

I thought I could simply decode the Input Data using https://github.com/ConsenSys/abi-decoder/ to figure out the function name and parameters, so I can call that function directly from Nodejs.

However, it's just returning undefined :thinking:

const inputData = "0x4ae301550000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b400000000000000000000000000000000000000000000000000000000000000034254430000000000000000000000000000000000000000000000000000000000";

const decodedData = abiDecoder.decodeMethod(inputData);
console.log(decodedData);

Am I using this package incorrectly? Is there any other way to figure out the contract function name and parameters for this transaction?

1 Answer 1

1

yes, you are using the method correctly. the problem is, you don't have the ABI. The ABI is the specification of the contract , similar to variable testABI shown as example at https://github.com/ConsenSys/abi-decoder/ so, because you don't have it (the ABI) you won't be able to decode the input.

You have to provide the abi specification and that is created during compilation of your solidity code when you pass the --abi parameter to solc executable

3
  • This isn't my contract though. So without the ABI you're saying there's no way to call the contract functions directly? I can't even "guess" what the ABI would contain?
    – Kane
    Commented Dec 21, 2022 at 1:39
  • you can check the "Ethereum Signature Database" (a public knowledge base of functions) and if it is there, you will know its name and arguments
    – Nulik
    Commented Dec 21, 2022 at 1:48
  • without ABI you have to disassemble (decompile) the contract to understand what it does and then you can derive the ABI yourself
    – Nulik
    Commented Dec 21, 2022 at 1:50

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.