Struct alloy_contract::ContractInstance
source · pub struct ContractInstance<T, P, N = Ethereum> { /* private fields */ }
Expand description
A handle to an Ethereum contract at a specific address.
A contract is an abstraction of an executable program on Ethereum. Every deployed contract has an address, which is used to connect to it so that it may receive messages (transactions).
Implementations§
source§impl<T, P, N> ContractInstance<T, P, N>
impl<T, P, N> ContractInstance<T, P, N>
source§impl<T, P: Clone, N> ContractInstance<T, &P, N>
impl<T, P: Clone, N> ContractInstance<T, &P, N>
sourcepub fn with_cloned_provider(self) -> ContractInstance<T, P, N>
pub fn with_cloned_provider(self) -> ContractInstance<T, P, N>
Clones the provider and returns a new contract instance with the cloned provider.
source§impl<T: Transport + Clone, P: Provider<T, N>, N: Network> ContractInstance<T, P, N>
impl<T: Transport + Clone, P: Provider<T, N>, N: Network> ContractInstance<T, P, N>
sourcepub fn function(
&self,
name: &str,
args: &[DynSolValue],
) -> Result<CallBuilder<T, &P, Function, N>>
pub fn function( &self, name: &str, args: &[DynSolValue], ) -> Result<CallBuilder<T, &P, Function, N>>
Returns a transaction builder for the provided function name.
If there are multiple functions with the same name due to overloading, consider using
the ContractInstance::function_from_selector
method instead, since this will use the
first match.
sourcepub fn function_from_selector(
&self,
selector: &Selector,
args: &[DynSolValue],
) -> Result<CallBuilder<T, &P, Function, N>>
pub fn function_from_selector( &self, selector: &Selector, args: &[DynSolValue], ) -> Result<CallBuilder<T, &P, Function, N>>
Returns a transaction builder for the provided function selector.
Methods from Deref<Target = Interface>§
sourcepub fn encode_input(&self, name: &str, args: &[DynSolValue]) -> Result<Vec<u8>>
pub fn encode_input(&self, name: &str, args: &[DynSolValue]) -> Result<Vec<u8>>
Returns the ABI encoded data (including the selector) for the provided function and arguments.
§Note
If the function exists multiple times and you want to use one of the overloaded versions,
consider using Self::encode_input_with_selector
.
sourcepub fn encode_input_with_selector(
&self,
selector: &Selector,
args: &[DynSolValue],
) -> Result<Vec<u8>>
pub fn encode_input_with_selector( &self, selector: &Selector, args: &[DynSolValue], ) -> Result<Vec<u8>>
Returns the ABI encoded data (including the selector) for the function with the provided selector and arguments.
sourcepub fn decode_input(
&self,
name: &str,
data: &[u8],
validate: bool,
) -> Result<Vec<DynSolValue>>
pub fn decode_input( &self, name: &str, data: &[u8], validate: bool, ) -> Result<Vec<DynSolValue>>
ABI-decodes the given data according to the function’s types.
§Note
If the function exists multiple times and you want to use one of the overloaded versions,
consider using Self::decode_input_with_selector
.
sourcepub fn decode_input_with_selector(
&self,
selector: &Selector,
data: &[u8],
validate: bool,
) -> Result<Vec<DynSolValue>>
pub fn decode_input_with_selector( &self, selector: &Selector, data: &[u8], validate: bool, ) -> Result<Vec<DynSolValue>>
Decode the provided ABI encoded bytes as the input of the provided function selector.
sourcepub fn decode_output(
&self,
name: &str,
data: &[u8],
validate: bool,
) -> Result<Vec<DynSolValue>>
pub fn decode_output( &self, name: &str, data: &[u8], validate: bool, ) -> Result<Vec<DynSolValue>>
Decode the provided ABI encoded bytes as the output of the first function with the given name.
§Note
If there are multiple functions with the same name, consider using
Self::decode_output_with_selector
sourcepub fn decode_output_with_selector(
&self,
selector: &Selector,
data: &[u8],
validate: bool,
) -> Result<Vec<DynSolValue>>
pub fn decode_output_with_selector( &self, selector: &Selector, data: &[u8], validate: bool, ) -> Result<Vec<DynSolValue>>
Decode the provided ABI encoded bytes as the output of the provided function selector.
Trait Implementations§
source§impl<T: Clone, P: Clone, N: Clone> Clone for ContractInstance<T, P, N>
impl<T: Clone, P: Clone, N: Clone> Clone for ContractInstance<T, P, N>
source§fn clone(&self) -> ContractInstance<T, P, N>
fn clone(&self) -> ContractInstance<T, P, N>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<T, P, N> Debug for ContractInstance<T, P, N>
impl<T, P, N> Debug for ContractInstance<T, P, N>
Auto Trait Implementations§
impl<T, P, N> Freeze for ContractInstance<T, P, N>where
P: Freeze,
impl<T, P, N> RefUnwindSafe for ContractInstance<T, P, N>
impl<T, P, N> Send for ContractInstance<T, P, N>
impl<T, P, N> Sync for ContractInstance<T, P, N>
impl<T, P, N> Unpin for ContractInstance<T, P, N>
impl<T, P, N> UnwindSafe for ContractInstance<T, P, N>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more