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

[Question] how can we decode transaction data ? #1534

Open
Aviksaikat opened this issue Oct 19, 2024 · 1 comment
Open

[Question] how can we decode transaction data ? #1534

Aviksaikat opened this issue Oct 19, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@Aviksaikat
Copy link

Component

other

Describe the feature you would like

As we all know, we can decode transaction data when a known method is called like this.

[...]
fn main() {
    let input = "0x38ed173900000000000000000000000000000000000000000001a717cc0a3e4f84c00000000000000000000000000000000000000000000000000000000000000283568400000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000201f129111c60401630932d9f9811bd5b5fff34e000000000000000000000000000000000000000000000000000000006227723d000000000000000000000000000000000000000000000000000000000000000200000000000000000000000095ad61b0a150d79219dcf64e1e6cc01f0b64c4ce000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7";
    let input = hex::decode(input)?;

    // Decode the input using the generated `swapExactTokensForTokens` bindings.
    let decoded = swapExactTokensForTokensCall::abi_decode(&input, false);

[...]
}

But how can we decode the data when we don't know which method is called? We can read the function signature data from the first 4 bytes of data, which can be used to determine what function is called. But how can we use alloy-rs to decode the data further using abi?

Additional context

No response

@Aviksaikat Aviksaikat added the enhancement New feature or request label Oct 19, 2024
@mattsse
Copy link
Member

mattsse commented Oct 21, 2024

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

No branches or pull requests

3 participants
@mattsse @Aviksaikat and others