Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

decoding abi #85

Open
GildedHonour opened this issue Jul 21, 2022 · 1 comment
Open

decoding abi #85

GildedHonour opened this issue Jul 21, 2022 · 1 comment

Comments

@GildedHonour
Copy link

GildedHonour commented Jul 21, 2022

In README:

Need to pass the ABI's manually to the library in order to be able to decode params later

//Add ABI's

const testABI = [{"inputs": [{"type": ....}];
abiDecoder.addABI(testABI);

//Decode Tx data

const testData = "0x53d9d910000........0000a6d9c5f7d4de3cef51ad3b7235d79ccc95114daa";
const decodedData = abiDecoder.decodeMethod(testData);
  1. What's testData? Is it transaction.input? Or what is it?

  2. abiDecoder.addABI(testABI); - does this mean that once I've added some abi (abi1), the method decodeMethod will ONLY be able to decode methods using once specified abi1? What if I have multiple abi-s and multiple methods to decode? In other words, how can I decode a specifi method with a specific abi?

@Yiwen-Gao
Copy link

What's testData? Is it transaction.input? Or what is it?

Yep, I believe testData is the transaction's input and includes the function signature in the first eight bytes.

abiDecoder.addABI(testABI); - does this mean that once I've added some abi (abi1), the method decodeMethod will ONLY be able to decode methods using once specified abi1? What if I have multiple abi-s and multiple methods to decode? In other words, how can I decode a specifi method with a specific abi?

I think you can call addABI multiple times. As long as the function signatures are unique, it'll add a new entry to the state and not overwrite an existing one (see L35 and L37 below).
https://github.com/ConsenSys/abi-decoder/blob/a9ed4923433ad32069e2ea963d683ed2ff49fa07/index.js#L20-L46

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants