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§
- stream
- Contains the
EventStreamtype which aids in streaming access to contract events
Macros§
- abigen
- Generates type-safe bindings to an Ethereum smart contract from its ABI.
Structs§
- Abigen
- Programmatically generate type-safe Rust bindings for an Ethereum smart contract from its ABI.
- Base
Contract - A reduced form of
Contractwhich just takes theabiand produces ABI encoded data for its functions. - Call
- Helper struct for managing calls to be made to the
functionin smart contracttargetwithdata. - Contract
Deployment Tx - Helper which manages the deployment transaction of a smart contract. It wraps a deployment transaction, and retrieves the contract address output by it.
- Contract
Instance - 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.
- Deployment
TxFactory - To deploy a contract to the Ethereum network, a
ContractFactorycan be created which manages the Contract bytecode and Application Binary Interface (ABI), usually generated from the Solidity compiler. - Event
- Helper for managing the event filter before querying or streaming its logs
- Exclude
Contracts - A Contract Filter that exclude certain contracts
- Function
Call - Helper for managing a transaction before submitting it to a node
- Internal
Structs - Helper to match
ethabi::Params with structs and nested structs - Lazy
- A value which is initialized on the first access.
- LogMeta
- Metadata inside a log
- Multi
Abigen - Collects Abigen structs for a series of contracts, pending generation of the contract bindings.
- Multicall
- A Multicall is an abstraction for sending batched calls/transactions to the Ethereum blockchain.
It stores an instance of the
Multicallsmart contract and the user provided list of transactions to be called or executed on chain. - Multicall
Contract - Select
Contracts - A Contract Filter that only includes certain contracts.
Enums§
- AbiError
- ABI codec related errors
- Contract
Error - An Error which is thrown when interacting with a smart contract
- Contract
Filter - Used to filter contracts that should be included in the abigen generation.
- Multicall
Error - Errors using the
crate::Multicallsystem - Multicall
Version - The version of the
Multicall. Used to determine which methods of the Multicall smart contract to use:
Constants§
- MULTICALL_
ADDRESS - The Multicall3 contract address that is deployed in
MULTICALL_SUPPORTED_CHAIN_IDS:0xcA11bde05977b3631167028862bE2a173976CA11 - MULTICALL_
SUPPORTED_ CHAIN_ IDS - The chain IDs that
MULTICALL_ADDRESShas been deployed to.
Traits§
- Contract
Revert - A trait for enums unifying
EthErrortypes. This trait is usually used to represent the errors that a specific contract might throw. I.e. all solidity custom errors + revert strings. - EthCall
- A helper trait for types that represent all call input parameters of a specific function
- EthError
- A helper trait for types that represents a custom error type
- EthEvent
- A trait for implementing event bindings
- EthLog
Decode - A trait for types (events) that can be decoded from a
RawLog
Functions§
- decode_
function_ data - Helper for ABI decoding raw data based on a function’s input or output.
- decode_
logs - Decodes a series of logs into a vector
- encode_
function_ data - Helper for ABI encoding arguments for a specific function
- parse_
log - Attempt to parse a log into a specific output type.
Type Aliases§
- Contract
Contractis aContractInstanceobject with anArcmiddleware. This type alias exists to preserve backwards compatibility with less-abstract Contracts.- Contract
Call ContractCallis aFunctionCallobject with anstd::sync::Arcmiddleware. This type alias exists to preserve backwards compatibility with less-abstract Contracts.- Contract
Deployer ContractDeployeris aContractDeploymentTxobject with anArcmiddleware. This type alias exists to preserve backwards compatibility with less-abstract Contracts.- Contract
Factory ContractFactoryis aDeploymentTxFactoryobject with anArcmiddleware. This type alias exists to preserve backwards compatibility with less-abstract Contracts.
Derive Macros§
- Eip712
- Derives the
Eip712trait for the labeled type. - EthAbi
Codec - Derives the
AbiEncodeandAbiDecodetraits for the labeled type. - EthAbi
Type - Derives the
AbiTypeand allTokenizabletraits for the labeled type. - EthCall
- Derives the
EthCallandTokenizeabletrait for the labeled type. - EthDisplay
- Derives the
Displaytrait on structs by formatting each field based on its Ethereum type. - EthError
- Derives the
EthErrorandTokenizeabletrait for the labeled type. - EthEvent
- Derives the
EthEventandTokenizabletraits for the labeled type.