Crate ethers_contract
source ·Expand description
Type-safe abstractions for interacting with Ethereum smart contracts
Interacting with a smart contract requires broadcasting carefully crafted
transactions where the data
field
contains the
function’s selector
along with the arguments of the called function.
This module provides the Contract
and ContractFactory
abstractions so
that you do not have to worry about that. It also provides typesafe bindings via
the abigen
macro and the Abigen
builder.
Modules
Macros
abigen
abigen
Proc macro to generate type-safe bindings to a contract(s). This macro
accepts one or more Ethereum contract ABI or a path. Note that relative paths are
rooted in the crate’s root
CARGO_MANIFEST_DIR
.
Environment variable interpolation is supported via $
prefix, like
"$CARGO_MANIFEST_DIR/contracts/c.json"
Structs
Abigen
abigen
Builder struct for generating type-safe bindings from a contract’s ABI
A reduced form of
Contract
which just takes the abi
and produces
ABI encoded data for its functions.A Contract is an abstraction of an executable program on the Ethereum Blockchain.
It has code (called byte code) as well as allocated long-term memory
(called storage). Every deployed Contract has an address, which is used to connect
to it so that it may be sent messages to call its methods.
Helper which manages the deployment transaction of a smart contract.
To deploy a contract to the Ethereum network, a
ContractFactory
can be
created which manages the Contract bytecode and Application Binary Interface
(ABI), usually generated from the Solidity compiler.Helper for managing the event filter before querying or streaming its logs
ExcludeContracts
abigen
A Contract Filter that exclude certain contracts
InternalStructs
abigen
Helper to match
ethabi::Param
s with structs and nested structsMetadata inside a log
MultiAbigen
abigen
Collects Abigen structs for a series of contracts, pending generation of
the contract bindings.
Multicall
abigen
A Multicall is an abstraction for sending batched calls/transactions to the Ethereum blockchain.
It stores an instance of the
Multicall
smart contract
and the user provided list of transactions to be called or executed on chain.MulticallContract
abigen
SelectContracts
abigen
A Contract Filter that only includes certain contracts.
Enums
ABI codec related errors
An Error which is thrown when interacting with a smart contract
ContractFilter
abigen
Used to filter contracts that should be included in the abigen generation.
MulticallError
abigen
MulticallVersion
abigen
The version of the
Multicall
.
Used to determine which methods of the Multicall smart contract to use:Constants
MULTICALL_ADDRESS
abigen
The Multicall3 contract address that is deployed in
MULTICALL_SUPPORTED_CHAIN_IDS
:
0xcA11bde05977b3631167028862bE2a173976CA11
Statics
The chain IDs that
MULTICALL_ADDRESS
has been deployed to.
Taken from: https://github.com/mds1/multicall#multicall3-contract-addressesTraits
A helper trait for types that represent all call input parameters of a specific function
A helper trait for types that represents a custom error type
A trait for implementing event bindings
A trait for types (events) that can be decoded from a
RawLog
Functions
Helper for ABI decoding raw data based on a function’s input or output.
Decodes a series of logs into a vector
Helper for ABI encoding arguments for a specific function
Derive Macros
Derive macro for
Eip712
EthAbiCodec
abigen
Derives the
AbiEncode
, AbiDecode
and traits for the labeled type.EthAbiType
abigen
Derives the
AbiType
and all Tokenizable
traits for the labeled type.EthCall
abigen
Derives the
EthCall
and Tokenizeable
trait for the labeled type.EthDisplay
abigen
Derives
fmt::Display
trait and generates a convenient format for all the
underlying primitive types/tokens.EthError
abigen
Derives the
EthError
and Tokenizeable
trait for the labeled type.EthEvent
abigen
Derives the
EthEvent
and Tokenizeable
trait for the labeled type.