Module clarity::abi[][src]

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

SerializedToken

Representation of a serialized token.

Token

A token represents a value of parameter of the contract call.

Functions

derive_method_id

Given a signature it derives a Method ID

derive_signature

Raw derive for a Keccak256 digest from a string

encode_call

A helper function that encodes both signature and a list of tokens.

encode_tokens

This one is a very simplified ABI encoder that takes a bunch of tokens, and serializes them.

get_hash

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.