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§
source§impl Contract
impl Contract
sourcepub fn from_secret_key(
id: AccountId,
sk: SecretKey,
worker: &Worker<impl Network + 'static>
) -> Self
pub fn from_secret_key(
id: AccountId,
sk: SecretKey,
worker: &Worker<impl Network + 'static>
) -> Self
sourcepub fn as_account(&self) -> &Account
pub fn as_account(&self) -> &Account
sourcepub fn as_account_mut(&mut self) -> &mut Account
pub fn as_account_mut(&mut self) -> &mut Account
sourcepub fn signer(&self) -> &InMemorySigner
pub fn signer(&self) -> &InMemorySigner
Grab the signer of the account. This signer is used to sign all transactions sent to the network.
sourcepub fn call(&self, function: &str) -> CallTransaction<'_>
pub fn call(&self, function: &str) -> CallTransaction<'_>
Call the current contract’s function using the contract’s own account
secret key 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 secret key as a signer to call
into another contract, use contract.as_account().call instead.
sourcepub fn view(&self, function: &str) -> Query<'_, ViewFunction>
pub fn view(&self, function: &str) -> Query<'_, ViewFunction>
Call a view function into the current contract. Returns a result which can be deserialized into borsh or JSON.
sourcepub fn view_state(&self) -> Query<'_, ViewState>
pub fn view_state(&self) -> Query<'_, ViewState>
View a contract’s state map of key value pairs.
sourcepub fn view_account(&self) -> Query<'_, ViewAccount>
pub fn view_account(&self) -> Query<'_, ViewAccount>
Views the current contract’s details such as balance and storage usage.
sourcepub fn view_access_key(&self, pk: &PublicKey) -> Query<'_, ViewAccessKey>
pub fn view_access_key(&self, pk: &PublicKey) -> Query<'_, ViewAccessKey>
Views the current contract’s access key, given the PublicKey associated to it.
sourcepub fn view_access_keys(&self) -> Query<'_, ViewAccessKeyList>
pub fn view_access_keys(&self) -> Query<'_, ViewAccessKeyList>
sourcepub async fn delete_contract(
self,
beneficiary_id: &AccountId
) -> Result<ExecutionFinalResult>
pub async fn delete_contract(
self,
beneficiary_id: &AccountId
) -> Result<ExecutionFinalResult>
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(&self) -> Transaction<'_>
pub fn batch(&self) -> Transaction<'_>
Start a batch transaction, using the current contract’s secret key as the
signer, making calls into itself. 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.