pub enum Action {
Show 14 variants
CreateAccount(CreateAccountAction),
DeployContract(DeployContractAction),
FunctionCall(FunctionCallAction),
Transfer(TransferAction),
Stake(StakeAction),
AddKey(AddKeyAction),
DeleteKey(DeleteKeyAction),
DeleteAccount(DeleteAccountAction),
Delegate(Box<SignedDelegateAction>),
DeployGlobalContract(DeployGlobalContractAction),
UseGlobalContract(UseGlobalContractAction),
DeterministicStateInit(DeterministicStateInitAction),
TransferToGasKey(TransferToGasKeyAction),
WithdrawFromGasKey(WithdrawFromGasKeyAction),
}Expand description
A transaction action.
IMPORTANT: Variant order matters for Borsh serialization! The discriminants match NEAR Protocol specification: 0 = CreateAccount, 1 = DeployContract, 2 = FunctionCall, 3 = Transfer, 4 = Stake, 5 = AddKey, 6 = DeleteKey, 7 = DeleteAccount, 8 = Delegate, 9 = DeployGlobalContract, 10 = UseGlobalContract, 11 = DeterministicStateInit, 12 = TransferToGasKey, 13 = WithdrawFromGasKey
Variants§
CreateAccount(CreateAccountAction)
Create a new account. (discriminant = 0)
DeployContract(DeployContractAction)
Deploy contract code. (discriminant = 1)
FunctionCall(FunctionCallAction)
Call a contract function. (discriminant = 2)
Transfer(TransferAction)
Transfer NEAR tokens. (discriminant = 3)
Stake(StakeAction)
Stake NEAR for validation. (discriminant = 4)
AddKey(AddKeyAction)
Add an access key. (discriminant = 5)
DeleteKey(DeleteKeyAction)
Delete an access key. (discriminant = 6)
DeleteAccount(DeleteAccountAction)
Delete the account. (discriminant = 7)
Delegate(Box<SignedDelegateAction>)
Delegate action (for meta-transactions). (discriminant = 8)
DeployGlobalContract(DeployGlobalContractAction)
Publish a contract to global registry. (discriminant = 9)
UseGlobalContract(UseGlobalContractAction)
Deploy from a previously published global contract. (discriminant = 10)
DeterministicStateInit(DeterministicStateInitAction)
NEP-616: Deploy with deterministically derived account ID. (discriminant = 11)
TransferToGasKey(TransferToGasKeyAction)
Transfer NEAR to a gas key. (discriminant = 12)
WithdrawFromGasKey(WithdrawFromGasKeyAction)
Withdraw NEAR from a gas key. (discriminant = 13)
Implementations§
Source§impl Action
impl Action
Sourcepub fn create_account() -> Self
pub fn create_account() -> Self
Create a CreateAccount action.
Sourcepub fn deploy_contract(code: Vec<u8>) -> Self
pub fn deploy_contract(code: Vec<u8>) -> Self
Create a DeployContract action.
Sourcepub fn function_call(
method_name: impl Into<String>,
args: Vec<u8>,
gas: Gas,
deposit: NearToken,
) -> Self
pub fn function_call( method_name: impl Into<String>, args: Vec<u8>, gas: Gas, deposit: NearToken, ) -> Self
Create a FunctionCall action.
Sourcepub fn add_full_access_key(public_key: PublicKey) -> Self
pub fn add_full_access_key(public_key: PublicKey) -> Self
Create an AddKey action for full access.
Sourcepub fn add_function_call_key(
public_key: PublicKey,
receiver_id: AccountId,
method_names: Vec<String>,
allowance: Option<NearToken>,
) -> Self
pub fn add_function_call_key( public_key: PublicKey, receiver_id: AccountId, method_names: Vec<String>, allowance: Option<NearToken>, ) -> Self
Create an AddKey action for function call access.
Sourcepub fn delete_key(public_key: PublicKey) -> Self
pub fn delete_key(public_key: PublicKey) -> Self
Create a DeleteKey action.
Sourcepub fn delete_account(beneficiary_id: AccountId) -> Self
pub fn delete_account(beneficiary_id: AccountId) -> Self
Create a DeleteAccount action.
Sourcepub fn delegate(signed_delegate: SignedDelegateAction) -> Self
pub fn delegate(signed_delegate: SignedDelegateAction) -> Self
Create a Delegate action from a signed delegate action.
Sourcepub fn publish_contract(code: Vec<u8>, by_hash: bool) -> Self
pub fn publish_contract(code: Vec<u8>, by_hash: bool) -> Self
Publish a contract to the global registry.
Global contracts are deployed once and can be referenced by multiple accounts, saving storage costs.
§Arguments
code- The WASM code to publishby_hash- If true, contract is identified by its code hash (immutable). If false (default), contract is identified by the signer’s account ID (updatable).
§Example
// Publish updatable contract (identified by your account)
near.transaction("alice.near")
.publish_contract(wasm_code, false)
.send()
.await?;
// Publish immutable contract (identified by its hash)
near.transaction("alice.near")
.publish_contract(wasm_code, true)
.send()
.await?;Sourcepub fn deploy_from_hash(code_hash: CryptoHash) -> Self
pub fn deploy_from_hash(code_hash: CryptoHash) -> Self
Deploy a contract from the global registry by code hash.
References a previously published immutable contract.
Sourcepub fn deploy_from_account(account_id: AccountId) -> Self
pub fn deploy_from_account(account_id: AccountId) -> Self
Deploy a contract from the global registry by account ID.
References a contract published by the given account. The contract can be updated by the publisher.
Sourcepub fn state_init(
state_init: DeterministicAccountStateInit,
deposit: NearToken,
) -> Self
pub fn state_init( state_init: DeterministicAccountStateInit, deposit: NearToken, ) -> Self
Create a NEP-616 deterministic state init action.
The account ID is derived from the state init data:
"0s" + hex(keccak256(borsh(state_init))[12..32])
Sourcepub fn state_init_by_hash(
code_hash: CryptoHash,
data: BTreeMap<Vec<u8>, Vec<u8>>,
deposit: NearToken,
) -> Self
pub fn state_init_by_hash( code_hash: CryptoHash, data: BTreeMap<Vec<u8>, Vec<u8>>, deposit: NearToken, ) -> Self
Create a NEP-616 deterministic state init action with code hash reference.
Sourcepub fn state_init_by_account(
account_id: AccountId,
data: BTreeMap<Vec<u8>, Vec<u8>>,
deposit: NearToken,
) -> Self
pub fn state_init_by_account( account_id: AccountId, data: BTreeMap<Vec<u8>, Vec<u8>>, deposit: NearToken, ) -> Self
Create a NEP-616 deterministic state init action with account reference.
Sourcepub fn transfer_to_gas_key(public_key: PublicKey, deposit: NearToken) -> Self
pub fn transfer_to_gas_key(public_key: PublicKey, deposit: NearToken) -> Self
Transfer NEAR to a gas key.
Sourcepub fn withdraw_from_gas_key(public_key: PublicKey, amount: NearToken) -> Self
pub fn withdraw_from_gas_key(public_key: PublicKey, amount: NearToken) -> Self
Withdraw NEAR from a gas key.
Trait Implementations§
Source§impl BorshDeserialize for Action
impl BorshDeserialize for Action
fn deserialize_reader<__R: Read>(reader: &mut __R) -> Result<Self, Error>
Source§fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
Source§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where
R: Read,
Source§impl BorshSerialize for Action
impl BorshSerialize for Action
Source§impl From<NonDelegateAction> for Action
impl From<NonDelegateAction> for Action
Source§fn from(action: NonDelegateAction) -> Self
fn from(action: NonDelegateAction) -> Self
Source§impl TryFrom<Action> for NonDelegateAction
impl TryFrom<Action> for NonDelegateAction
impl Eq for Action
impl StructuralPartialEq for Action
Auto Trait Implementations§
impl Freeze for Action
impl RefUnwindSafe for Action
impl Send for Action
impl Sync for Action
impl Unpin for Action
impl UnsafeUnpin for Action
impl UnwindSafe for Action
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.