Skip to content

How to ABI decode given just signature  #836

Open
@fxfactorial

Description

@fxfactorial

What piece of the framework are having the lack of docs?

Here is a code sample

let payload = "128acb08000000000000000000000000b27308f9f90d607463bb33ea1bebb41c27ce5ab600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000fffd8963efd1fc6a506488495d951d5263988d2500000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002bc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000bb8a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000"

let sig = "swap(address,bool,int256,uint160,bytes)"
// actually does work on payload if you remove the first four bytes of payload
let result = ABIDecoder.decode(types: [
                                 .address, .bool, .int(bits:256), .uint(bits:160), .dynamicBytes,
                               ],
                               data: Data(hex: payload[8...]))

now how can I get result without having to manually give the types? that is, I want to pass to ABIDecoder just the (address,bool,int256,uint160,bytes) and data and get the parsed result.

What bit of docs would you like to have?

How to decode using just signature

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions