Struct 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§

Create a new account with the given path to the credentials JSON file

Create an Account object from an AccountId and SecretKey.

Grab the current account identifier

Grab the signer of the account. This signer is used to sign all transactions sent to the network.

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. Note that the current Account’s secret key is used as the signer of the transaction.

View call to a specified contract function. Returns a result which can be deserialized into borsh or JSON.

Transfer NEAR to an account specified by receiver_id with the amount specified by amount. Returns the execution details of this transaction

Deletes the current account, and returns the execution details of this transaction. The beneficiary will receive the funds of the account deleted

Views the current account’s details such as balance and storage usage.

Views the current accounts’s access key, given the PublicKey associated to it.

Views all the AccessKeys of the current account. This will return a list of AccessKeys along with each associated PublicKey.

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}”

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.

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.

Store the credentials of this account locally in the directory provided.

Get the keys of this account. The public key can be retrieved from the secret key.

Sets the SecretKey of this account. Future transactions will be signed using this newly provided key.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

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

Calls U::from(self).

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

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more