Crate ethers_contract
source ·Expand description
§ethers-contract
Type-safe abstractions for interacting with Ethereum smart contracts.
Warning
This library is in the process of being deprecated. See #2667 for more information.
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.
For more information, please refer to the book.
Modules§
- multicall_contract
abigen
The Multicall contract bindings. Auto-generated withabigen
. - Contains the
EventStream
type which aids in streaming access to contract events
Macros§
- abigen
abigen
Generates type-safe bindings to an Ethereum smart contract from its ABI.
Structs§
- Abigen
abigen
Programmatically generate type-safe Rust bindings for an Ethereum smart contract from its ABI. - A reduced form of
Contract
which just takes theabi
and produces ABI encoded data for its functions. - Call
providers
andabigen
Helper struct for managing calls to be made to thefunction
in smart contracttarget
withdata
. - ContractDeploymentTx
providers
Helper which manages the deployment transaction of a smart contract. It wraps a deployment transaction, and retrieves the contract address output by it. - ContractInstance
providers
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. - DeploymentTxFactory
providers
To deploy a contract to the Ethereum network, aContractFactory
can be created which manages the Contract bytecode and Application Binary Interface (ABI), usually generated from the Solidity compiler. - Event
providers
Helper for managing the event filter before querying or streaming its logs - ExcludeContracts
abigen
A Contract Filter that exclude certain contracts - FunctionCall
providers
Helper for managing a transaction before submitting it to a node - InternalStructs
abigen
Helper to matchethabi::Param
s with structs and nested structs - Metadata inside a log
- MultiAbigen
abigen
Collects Abigen structs for a series of contracts, pending generation of the contract bindings. - Multicall
providers
andabigen
A Multicall is an abstraction for sending batched calls/transactions to the Ethereum blockchain. It stores an instance of theMulticall
smart contract and the user provided list of transactions to be called or executed on chain. - MulticallContract
abigen
andproviders
- SelectContracts
abigen
A Contract Filter that only includes certain contracts.
Enums§
- ABI codec related errors
- ContractError
providers
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
providers
andabigen
Errors using thecrate::Multicall
system - MulticallVersion
abigen
The version of theMulticall
. Used to determine which methods of the Multicall smart contract to use:
Constants§
- MULTICALL_ADDRESS
abigen
The Multicall3 contract address that is deployed inMULTICALL_SUPPORTED_CHAIN_IDS
:0xcA11bde05977b3631167028862bE2a173976CA11
- The chain IDs that
MULTICALL_ADDRESS
has been deployed to.
Traits§
- A trait for enums unifying
EthError
types. This trait is usually used to represent the errors that a specific contract might throw. I.e. all solidity custom errors + revert strings. - 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
- Attempt to parse a log into a specific output type.
Type Aliases§
- Contract
providers
Contract
is aContractInstance
object with anArc
middleware. This type alias exists to preserve backwards compatibility with less-abstract Contracts. - ContractCall
providers
ContractCall
is aFunctionCall
object with anstd::sync::Arc
middleware. This type alias exists to preserve backwards compatibility with less-abstract Contracts. - ContractDeployer
providers
ContractDeployer
is aContractDeploymentTx
object with anArc
middleware. This type alias exists to preserve backwards compatibility with less-abstract Contracts. - ContractFactory
providers
ContractFactory
is aDeploymentTxFactory
object with anArc
middleware. This type alias exists to preserve backwards compatibility with less-abstract Contracts.
Derive Macros§
- Eip712
abigen
Derives theEip712
trait for the labeled type. - EthAbiCodec
abigen
- EthAbiType
abigen
Derives theAbiType
and allTokenizable
traits for the labeled type. - EthCall
abigen
Derives theEthCall
andTokenizeable
trait for the labeled type. - EthDisplay
abigen
Derives theDisplay
trait on structs by formatting each field based on its Ethereum type. - EthError
abigen
Derives theEthError
andTokenizeable
trait for the labeled type. - EthEvent
abigen
Derives theEthEvent
andTokenizable
traits for the labeled type.