Crate contract

Crate 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§

stream
Contains the EventStream type 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.
BaseContract
A reduced form of Contract which just takes the abi and produces ABI encoded data for its functions.
Call
Helper struct for managing calls to be made to the function in smart contract target with data.
ContractDeploymentTx
Helper which manages the deployment transaction of a smart contract. It wraps a deployment transaction, and retrieves the contract address output by it.
ContractInstance
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
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.
Event
Helper for managing the event filter before querying or streaming its logs
ExcludeContracts
A Contract Filter that exclude certain contracts
FunctionCall
Helper for managing a transaction before submitting it to a node
InternalStructs
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
MultiAbigen
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 Multicall smart contract and the user provided list of transactions to be called or executed on chain.
MulticallContract
SelectContracts
A Contract Filter that only includes certain contracts.

Enums§

AbiError
ABI codec related errors
ContractError
An Error which is thrown when interacting with a smart contract
ContractFilter
Used to filter contracts that should be included in the abigen generation.
MulticallError
Errors using the crate::Multicall system
MulticallVersion
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_ADDRESS has been deployed to.

Traits§

ContractRevert
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.
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
EthLogDecode
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
Contract is a ContractInstance object with an Arc middleware. This type alias exists to preserve backwards compatibility with less-abstract Contracts.
ContractCall
ContractCall is a FunctionCall object with an std::sync::Arc middleware. This type alias exists to preserve backwards compatibility with less-abstract Contracts.
ContractDeployer
ContractDeployer is a ContractDeploymentTx object with an Arc middleware. This type alias exists to preserve backwards compatibility with less-abstract Contracts.
ContractFactory
ContractFactory is a DeploymentTxFactory object with an Arc middleware. This type alias exists to preserve backwards compatibility with less-abstract Contracts.

Derive Macros§

Eip712
Derives the Eip712 trait for the labeled type.
EthAbiCodec
Derives the AbiEncode and AbiDecode traits for the labeled type.
EthAbiType
Derives the AbiType and all Tokenizable traits for the labeled type.
EthCall
Derives the EthCall and Tokenizeable trait for the labeled type.
EthDisplay
Derives the Display trait on structs by formatting each field based on its Ethereum type.
EthError
Derives the EthError and Tokenizeable trait for the labeled type.
EthEvent
Derives the EthEvent and Tokenizable traits for the labeled type.