Crate ethers_contract
source ·Expand description
ethers-contract
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.
For more information, please refer to the book.
Modules
- multicall_contract
abigenThe Multicall contract bindings. Auto-generated withabigen. - Contains the
EventStreamtype which aids in streaming access to contract events
Macros
- abigen
abigenGenerates type-safe bindings to an Ethereum smart contract from its ABI.
Structs
- Abigen
abigenProgrammatically generate type-safe Rust bindings for an Ethereum smart contract from its ABI. - A reduced form of
Contractwhich just takes theabiand produces ABI encoded data for its functions. - Call
providersandabigenHelper struct for managing calls to be made to thefunctionin smart contracttargetwithdata. - ContractDeploymentTx
providersHelper which manages the deployment transaction of a smart contract. It wraps a deployment transaction, and retrieves the contract address output by it. - ContractInstance
providersA 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
providersTo deploy a contract to the Ethereum network, aContractFactorycan be created which manages the Contract bytecode and Application Binary Interface (ABI), usually generated from the Solidity compiler. - Event
providersHelper for managing the event filter before querying or streaming its logs - ExcludeContracts
abigenA Contract Filter that exclude certain contracts - FunctionCall
providersHelper for managing a transaction before submitting it to a node - InternalStructs
abigenHelper to matchethabi::Params with structs and nested structs - Metadata inside a log
- MultiAbigen
abigenCollects Abigen structs for a series of contracts, pending generation of the contract bindings. - Multicall
providersandabigenA Multicall is an abstraction for sending batched calls/transactions to the Ethereum blockchain. It stores an instance of theMulticallsmart contract and the user provided list of transactions to be called or executed on chain. - MulticallContract
abigenandproviders - SelectContracts
abigenA Contract Filter that only includes certain contracts.
Enums
- ABI codec related errors
- ContractError
providersAn Error which is thrown when interacting with a smart contract - ContractFilter
abigenUsed to filter contracts that should be included in the abigen generation. - MulticallError
providersandabigenErrors using thecrate::Multicallsystem - MulticallVersion
abigenThe version of theMulticall. Used to determine which methods of the Multicall smart contract to use:
Constants
- MULTICALL_ADDRESS
abigenThe Multicall3 contract address that is deployed inMULTICALL_SUPPORTED_CHAIN_IDS:0xcA11bde05977b3631167028862bE2a173976CA11 - The chain IDs that
MULTICALL_ADDRESShas been deployed to.
Traits
- 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. - 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 Definitions
- Contract
providersContractis aContractInstanceobject with anArcmiddleware. This type alias exists to preserve backwards compatibility with less-abstract Contracts. - ContractCall
providersContractCallis aFunctionCallobject with anstd::sync::Arcmiddleware. This type alias exists to preserve backwards compatibility with less-abstract Contracts. - ContractDeployer
providersContractDeployeris aContractDeploymentTxobject with anArcmiddleware. This type alias exists to preserve backwards compatibility with less-abstract Contracts. - ContractFactory
providersContractFactoryis aDeploymentTxFactoryobject with anArcmiddleware. This type alias exists to preserve backwards compatibility with less-abstract Contracts.
Derive Macros
- Eip712
abigenDerives theEip712trait for the labeled type. - EthAbiCodec
abigen - EthAbiType
abigenDerives theAbiTypeand allTokenizabletraits for the labeled type. - EthCall
abigenDerives theEthCallandTokenizeabletrait for the labeled type. - EthDisplay
abigenDerives theDisplaytrait on structs by formatting each field based on its Ethereum type. - EthError
abigenDerives theEthErrorandTokenizeabletrait for the labeled type. - EthEvent
abigenDerives theEthEventandTokenizabletraits for the labeled type.