Struct near_workspaces::Contract
source · [−]pub struct Contract { /* private fields */ }Expand description
Contract is directly associated to a contract in the network provided by the
Worker that creates it. This type offers methods to interact with any
network, such as creating transactions and calling into contract functions.
Implementations
sourceimpl Contract
impl Contract
sourcepub fn as_account(&self) -> &Account
pub fn as_account(&self) -> &Account
sourcepub fn call<'a, 'b, T: Network>(
&self,
worker: &'a Worker<T>,
function: &'b str
) -> CallTransaction<'a, 'b, T>
pub fn call<'a, 'b, T: Network>(
&self,
worker: &'a Worker<T>,
function: &'b str
) -> CallTransaction<'a, 'b, T>
Call the current contract’s function using the contract’s own account
details to do the signing. Returns a CallTransaction object that
we will make use to populate the rest of the call details.
If we want to make use of the contract’s account to call into a
different contract besides the current one, use
contract.as_account().call instead.
sourcepub async fn view<T: Network>(
&self,
worker: &Worker<T>,
function: &str,
args: Vec<u8>
) -> Result<ViewResultDetails>
pub async fn view<T: Network>(
&self,
worker: &Worker<T>,
function: &str,
args: Vec<u8>
) -> Result<ViewResultDetails>
Call a view function into the current contract. Returns a result that yields a JSON string object.
sourcepub async fn view_code<T: Network>(&self, worker: &Worker<T>) -> Result<Vec<u8>>
pub async fn view_code<T: Network>(&self, worker: &Worker<T>) -> Result<Vec<u8>>
View the WASM code bytes of this contract.
sourcepub async fn view_state<T: Network>(
&self,
worker: &Worker<T>,
prefix: Option<&[u8]>
) -> Result<HashMap<Vec<u8>, Vec<u8>>>
pub async fn view_state<T: Network>(
&self,
worker: &Worker<T>,
prefix: Option<&[u8]>
) -> Result<HashMap<Vec<u8>, Vec<u8>>>
View a contract’s state map of key value pairs.
sourcepub async fn view_account<T: Network>(
&self,
worker: &Worker<T>
) -> Result<AccountDetails>
pub async fn view_account<T: Network>(
&self,
worker: &Worker<T>
) -> Result<AccountDetails>
Views the current contract’s details such as balance and storage usage.
sourcepub async fn delete_contract<T: Network>(
self,
worker: &Worker<T>,
beneficiary_id: &AccountId
) -> Result<CallExecutionDetails>
pub async fn delete_contract<T: Network>(
self,
worker: &Worker<T>,
beneficiary_id: &AccountId
) -> Result<CallExecutionDetails>
Deletes the current contract, and returns the execution details of this transaction. The beneciary will receive the funds of the account deleted
sourcepub fn batch<'a, T: Network>(&self, worker: &'a Worker<T>) -> Transaction<'a>
pub fn batch<'a, T: Network>(&self, worker: &'a Worker<T>) -> Transaction<'a>
Start a batch transaction, using the current contract as the signer and
making calls into this contract. Returns a Transaction object that
we can use to add Actions to the batched transaction. Call transact
to send the batched transaction to the network.
Auto Trait Implementations
impl RefUnwindSafe for Contract
impl Send for Contract
impl Sync for Contract
impl Unpin for Contract
impl UnwindSafe for Contract
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more