Module alloy_sol_types::abi

source ·
Expand description

Ethereum ABI codec implementation.

This module provides the low-level ABI Encoder and Decoder structs, along with generic functions for their operation. These utilize an intermediate representation, referred to as tokens. For additional information about tokens, see the token module documentation.

You should not need this module in most cases, as the SolType and SolValue traits provide a higher-level and easier to use interface. If you’re sure you need the low-level functionality of this module, there are three main interfaces:

§{encode,decode}

encode operates on a single token. It wrap this token in a single-element tuple, and passes it to the encoder. Similarly, decode decodes a single token from a blob by decoding a single-element tuple.

Use this interface when ABI-encoding a single token. This is suitable for encoding a type in isolation, or for encoding parameters for single-param functions.

§{encode,decode}_params

encode_params operates on a sequence. If the sequence is a tuple, the tuple is inferred to be a set of Solidity function parameters, The corresponding decode_params reverses this operation, decoding a tuple from a blob.

This is used to encode the parameters for a Solidity function.

§{encode,decode}_sequence

encode_sequence operates on a sequence of tokens. This sequence is inferred not to be function parameters.

This is the least useful one. Most users will not need it.

Re-exports§

Modules§

  • Ethereum ABI tokens.

Structs§

  • The Decoder wraps a byte slice with necessary info to progressively deserialize the bytes into a sequence of tokens.
  • An ABI encoder.

Constants§

  • The ABI encoding of an empty byte array (bytes or string).
  • The decoder recursion limit. This is currently hardcoded, but may be parameterizable in the future.

Functions§

  • ABI-decodes a token by wrapping it in a single-element tuple.
  • ABI-decodes top-level function args.
  • Decodes ABI compliant vector of bytes into vector of tokens described by types param.
  • ABI-encodes a single token.
  • ABI-encodes a tuple as ABI function params, suitable for passing to a function.
  • ABI-encodes a token sequence.