pub struct BaseContract { /* private fields */ }
Expand description
Base contract functionality for interacting with blockchain contracts.
This struct provides common RPC execution patterns that can be reused by specific contract implementations like ERC20, ERC721, etc.
Implementations§
Source§impl BaseContract
impl BaseContract
Sourcepub fn new(client: Arc<BlockchainHttpRpcClient>) -> Self
pub fn new(client: Arc<BlockchainHttpRpcClient>) -> Self
Creates a new base contract interface with the specified RPC client.
§Panics
Panics if the multicall address is invalid (which should never happen with the hardcoded address).
Sourcepub const fn client(&self) -> &Arc<BlockchainHttpRpcClient>
pub const fn client(&self) -> &Arc<BlockchainHttpRpcClient>
Gets a reference to the RPC client.
Sourcepub async fn execute_call(
&self,
contract_address: &Address,
call_data: &[u8],
) -> Result<Vec<u8>, BlockchainRpcClientError>
pub async fn execute_call( &self, contract_address: &Address, call_data: &[u8], ) -> Result<Vec<u8>, BlockchainRpcClientError>
Executes a single contract call and returns the raw response bytes.
§Errors
Returns an error if the RPC call fails or response decoding fails.
Sourcepub async fn execute_multicall(
&self,
calls: Vec<ContractCall>,
) -> Result<Vec<Result>, BlockchainRpcClientError>
pub async fn execute_multicall( &self, calls: Vec<ContractCall>, ) -> Result<Vec<Result>, BlockchainRpcClientError>
Executes multiple contract calls in a single multicall transaction.
§Errors
Returns an error if the multicall fails or decoding fails.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BaseContract
impl !RefUnwindSafe for BaseContract
impl Send for BaseContract
impl Sync for BaseContract
impl Unpin for BaseContract
impl !UnwindSafe for BaseContract
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
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
Converts
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>
Converts
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