Module clarity::abi

source ·
Expand description

A module to simplify ABI encoding

For simplicity, it is based on tokens (as in items, not as in coin tokens). You have to specify a list of tokens and they will be automatically encoded.

Additionally there are helpers to help deal with deriving a function signatures.

This is not a full fledged implementation of ABI encoder, it is more like a bunch of helpers that would help to successfully encode a contract call.

§Limitation

Currently this module can only serialize types that can be represented by a Token.

Unfortunately if you need to support custom type that is not currently supported you are welcome to open an issue on issues page, or do the serialization yourself by converting your custom type into a [u8; 32] array and creating a proper Token instance.

Enums§

  • A token represents a value of parameter of the contract call.
  • Representation of a serialized token.

Functions§

  • Given a signature it derives a Method ID
  • Raw derive for a Keccak256 digest from a string
  • A helper function that encodes both signature and a list of tokens.
  • This one is a very simplified ABI encoder that takes a bunch of tokens, and serializes them.
  • Gets the Keccak256 hash of some input bytes. Signatures in Ethereum are nearly without exception performed after encoding using the ABI, then hashing using this function.