Struct near_workspaces::Account
source · [−]pub struct Account { /* private fields */ }Expand description
Account is directly associated to an account 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 Account
impl Account
sourcepub fn from_file(path: impl AsRef<Path>) -> Self
pub fn from_file(path: impl AsRef<Path>) -> Self
Create a new account with the given path to the credentials JSON file
sourcepub fn call<'a, 'b, T: Network>(
&self,
worker: &'a Worker<T>,
contract_id: &AccountId,
function: &'b str
) -> CallTransaction<'a, 'b, T>
pub fn call<'a, 'b, T: Network>(
&self,
worker: &'a Worker<T>,
contract_id: &AccountId,
function: &'b str
) -> CallTransaction<'a, 'b, T>
Call a contract on the network specified within worker, and return
a CallTransaction object that we will make use to populate the
rest of the call details.
sourcepub async fn transfer_near<T: Network>(
&self,
worker: &Worker<T>,
receiver_id: &AccountId,
amount: u128
) -> Result<CallExecutionDetails>
pub async fn transfer_near<T: Network>(
&self,
worker: &Worker<T>,
receiver_id: &AccountId,
amount: u128
) -> Result<CallExecutionDetails>
Transfer NEAR to an account specified by receiver_id with the amount
specified by amount. Returns the execution details of this transaction
sourcepub async fn delete_account<T: Network>(
self,
worker: &Worker<T>,
beneficiary_id: &AccountId
) -> Result<CallExecutionDetails>
pub async fn delete_account<T: Network>(
self,
worker: &Worker<T>,
beneficiary_id: &AccountId
) -> Result<CallExecutionDetails>
Deletes the current account, and returns the execution details of this transaction. The beneficiary will receive the funds of the account deleted
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 account’s details such as balance and storage usage.
sourcepub fn create_subaccount<'a, 'b, T: Network>(
&self,
worker: &'a Worker<T>,
new_account_id: &'b str
) -> CreateAccountTransaction<'a, 'b, T>
pub fn create_subaccount<'a, 'b, T: Network>(
&self,
worker: &'a Worker<T>,
new_account_id: &'b str
) -> CreateAccountTransaction<'a, 'b, T>
Create a new sub account. Returns a CreateAccountTransaction object
that we can make use of to fill out the rest of the details. The subaccount
id will be in the form of: “{new_account_id}.{parent_account_id}”
sourcepub async fn deploy<T: Network>(
&self,
worker: &Worker<T>,
wasm: &[u8]
) -> Result<CallExecution<Contract>>
pub async fn deploy<T: Network>(
&self,
worker: &Worker<T>,
wasm: &[u8]
) -> Result<CallExecution<Contract>>
Deploy contract code or WASM bytes to the account, and return us a new
Contract object that we can use to interact with the contract.
sourcepub fn batch<'a, T: Network>(
&self,
worker: &'a Worker<T>,
contract_id: &AccountId
) -> Transaction<'a>
pub fn batch<'a, T: Network>(
&self,
worker: &'a Worker<T>,
contract_id: &AccountId
) -> Transaction<'a>
Start a batch transaction, using the current account as the signer and
making calls into the contract provided by contract_id. 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 Account
impl Send for Account
impl Sync for Account
impl Unpin for Account
impl UnwindSafe for Account
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