Struct ethers_contract::BaseContract
source · Expand description
A reduced form of Contract
which just takes the abi
and produces
ABI encoded data for its functions.
Fields§
§methods: HashMap<Selector, (String, usize)>
A mapping from method signature to a name-index pair for accessing functions in the contract ABI. This is used to avoid allocation when searching for matching functions by signature.
Implementations§
source§impl BaseContract
impl BaseContract
sourcepub fn encode<T: Tokenize>(&self, name: &str, args: T) -> Result<Bytes, AbiError>
pub fn encode<T: Tokenize>(&self, name: &str, args: T) -> Result<Bytes, AbiError>
Returns the ABI encoded data for the provided function and arguments
If the function exists multiple times and you want to use one of the overloaded
versions, consider using encode_with_selector
sourcepub fn encode_with_selector<T: Tokenize>(
&self,
signature: Selector,
args: T
) -> Result<Bytes, AbiError>
pub fn encode_with_selector<T: Tokenize>(
&self,
signature: Selector,
args: T
) -> Result<Bytes, AbiError>
Returns the ABI encoded data for the provided function selector and arguments
sourcepub fn decode<D: Detokenize, T: AsRef<[u8]>>(
&self,
name: &str,
bytes: T
) -> Result<D, AbiError>
pub fn decode<D: Detokenize, T: AsRef<[u8]>>(
&self,
name: &str,
bytes: T
) -> Result<D, AbiError>
Decodes the provided ABI encoded function arguments with the selected function name.
If the function exists multiple times and you want to use one of the overloaded
versions, consider using decode_with_selector
sourcepub fn decode_raw<T: AsRef<[u8]>>(
&self,
name: &str,
bytes: T
) -> Result<Vec<Token>, AbiError>
pub fn decode_raw<T: AsRef<[u8]>>(
&self,
name: &str,
bytes: T
) -> Result<Vec<Token>, AbiError>
Decodes the provided ABI encoded function arguments with the selected function name.
If the function exists multiple times and you want to use one of the overloaded
versions, consider using decode_with_selector
Returns a [Token
] vector, which lets you decode function arguments dynamically
without knowing the return type.
sourcepub fn decode_output<D: Detokenize, T: AsRef<[u8]>>(
&self,
name: &str,
bytes: T
) -> Result<D, AbiError>
pub fn decode_output<D: Detokenize, T: AsRef<[u8]>>(
&self,
name: &str,
bytes: T
) -> Result<D, AbiError>
Decodes the provided ABI encoded function output with the selected function name.
If the function exists multiple times and you want to use one of the overloaded
versions, consider using decode_with_selector
sourcepub fn decode_output_raw<T: AsRef<[u8]>>(
&self,
name: &str,
bytes: T
) -> Result<Vec<Token>, AbiError>
pub fn decode_output_raw<T: AsRef<[u8]>>(
&self,
name: &str,
bytes: T
) -> Result<Vec<Token>, AbiError>
Decodes the provided ABI encoded function output with the selected function name.
If the function exists multiple times and you want to use one of the overloaded
versions, consider using decode_with_selector
Returns a [Token
] vector, which lets you decode function arguments dynamically
without knowing the return type.
sourcepub fn decode_event<D: Detokenize>(
&self,
name: &str,
topics: Vec<H256>,
data: Bytes
) -> Result<D, AbiError>
pub fn decode_event<D: Detokenize>(
&self,
name: &str,
topics: Vec<H256>,
data: Bytes
) -> Result<D, AbiError>
Decodes for a given event name, given the log.topics
and
log.data
fields from the transaction receipt
sourcepub fn decode_event_raw(
&self,
name: &str,
topics: Vec<H256>,
data: Bytes
) -> Result<Vec<Token>, AbiError>
pub fn decode_event_raw(
&self,
name: &str,
topics: Vec<H256>,
data: Bytes
) -> Result<Vec<Token>, AbiError>
Decodes for a given event name, given the log.topics
and
log.data
fields from the transaction receipt
Returns a [Token
] vector, which lets you decode function arguments dynamically
without knowing the return type.
sourcepub fn decode_with_selector_raw<T: AsRef<[u8]>>(
&self,
signature: Selector,
bytes: T
) -> Result<Vec<Token>, AbiError>
pub fn decode_with_selector_raw<T: AsRef<[u8]>>(
&self,
signature: Selector,
bytes: T
) -> Result<Vec<Token>, AbiError>
Decodes the provided ABI encoded bytes with the selected function selector
Returns a [Token
] vector, which lets you decode function arguments dynamically
without knowing the return type.
sourcepub fn decode_with_selector<D: Detokenize, T: AsRef<[u8]>>(
&self,
signature: Selector,
bytes: T
) -> Result<D, AbiError>
pub fn decode_with_selector<D: Detokenize, T: AsRef<[u8]>>(
&self,
signature: Selector,
bytes: T
) -> Result<D, AbiError>
Decodes the provided ABI encoded bytes with the selected function selector
pub fn decode_output_with_selector<D: Detokenize, T: AsRef<[u8]>>(
&self,
signature: Selector,
bytes: T
) -> Result<D, AbiError>
sourcepub fn decode_output_with_selector_raw<T: AsRef<[u8]>>(
&self,
signature: Selector,
bytes: T
) -> Result<Vec<Token>, AbiError>
pub fn decode_output_with_selector_raw<T: AsRef<[u8]>>(
&self,
signature: Selector,
bytes: T
) -> Result<Vec<Token>, AbiError>
Decodes the provided ABI encoded bytes with the selected function selector
Returns a [Token
] vector, which lets you decode function arguments dynamically
without knowing the return type.
sourcepub fn into_contract<M: Middleware>(
self,
address: Address,
client: impl Into<Arc<M>>
) -> Contract<M>
pub fn into_contract<M: Middleware>(
self,
address: Address,
client: impl Into<Arc<M>>
) -> Contract<M>
Upgrades a BaseContract
into a full fledged contract with an address and middleware.
Trait Implementations§
source§impl AsRef<Contract> for BaseContract
impl AsRef<Contract> for BaseContract
source§impl Clone for BaseContract
impl Clone for BaseContract
source§fn clone(&self) -> BaseContract
fn clone(&self) -> BaseContract
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more