pub struct BaseContract {
    pub methods: HashMap<Selector, (String, usize)>,
    /* private fields */
}
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

source

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

source

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

source

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

source

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.

source

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

source

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.

source

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

source

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.

source

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.

source

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

source

pub fn decode_input_raw<T: AsRef<[u8]>>( &self, bytes: T ) -> Result<Vec<Token>, AbiError>

Decodes the provided ABI encoded input bytes

Returns a Token vector, which lets you decode function arguments dynamically without knowing the return type.

source

pub fn decode_input<D: Detokenize, T: AsRef<[u8]>>( &self, bytes: T ) -> Result<D, AbiError>

Decodes the provided ABI encoded input bytes

source

pub fn decode_output_with_selector<D: Detokenize, T: AsRef<[u8]>>( &self, signature: Selector, bytes: T ) -> Result<D, AbiError>

Decode the provided ABI encoded bytes as the output of the provided function selector

source

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.

source

pub fn abi(&self) -> &Abi

Returns a reference to the contract’s ABI

source

pub fn into_contract<B, M>( self, address: Address, client: B ) -> ContractInstance<B, M>
where B: Borrow<M>, M: Middleware,

Available on crate feature providers only.

Upgrades a BaseContract into a full fledged contract with an address and middleware.

Trait Implementations§

source§

impl AsRef<Contract> for BaseContract

source§

fn as_ref(&self) -> &Abi

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Clone for BaseContract

source§

fn clone(&self) -> BaseContract

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for BaseContract

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<Contract> for BaseContract

source§

fn from(abi: Abi) -> Self

Creates a new BaseContract from the abi.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> JsonSchemaMaybe for T