Struct near_sdk_sim::UserTransaction[][src]

pub struct UserTransaction { /* fields omitted */ }

A transaction to be signed by the user which created it. Multiple actions can be chained together and then signed and sumited to be executed.

Example:

use near_sdk_sim::{to_yocto, account::AccessKey};
use near_crypto::{InMemorySigner, KeyType, Signer};
let master_account = near_sdk_sim::init_simulator(None);
let account_id = "alice".to_string();
let transaction = master_account.create_transaction(account_id.clone());
// Creates a signer which contains a public key.
let signer = InMemorySigner::from_seed(&account_id, KeyType::ED25519, &account_id);
let res = transaction.create_account()
                     .add_key(signer.public_key(), AccessKey::full_access())
                     .transfer(to_yocto("10"))
                     .submit();

This creates an account for alice, and a new key pair for the account, adding the public key to the account, and finally transfering 10 NEAR to the account from the master_account.

Implementations

impl UserTransaction[src]

pub fn submit(self) -> ExecutionResult[src]

Sign and execute the transaction

pub fn create_account(self) -> Self[src]

Create account for the receiver of the transaction.

pub fn deploy_contract(self, code: Vec<u8>) -> Self[src]

Deploy Wasm binary

pub fn function_call(
    self,
    method_name: String,
    args: Vec<u8>,
    gas: Gas,
    deposit: Balance
) -> Self
[src]

Execute contract call to receiver

pub fn transfer(self, deposit: Balance) -> Self[src]

Transfer deposit to receiver

pub fn stake(self, stake: Balance, public_key: PublicKey) -> Self[src]

Express interest in becoming a validator

pub fn add_key(self, public_key: PublicKey, access_key: AccessKey) -> Self[src]

Add access key, either FunctionCall or FullAccess

pub fn delete_key(self, public_key: PublicKey) -> Self[src]

Delete an access key

pub fn delete_account(self, beneficiary_id: AccountId) -> Self[src]

Delete an account and send remaining balance to beneficiary_id

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,