Actions such as transferring NEAR, or calling other contracts.
An important property of Actions is that they can be batched together when acting on the same contract. Batched actions act as a unit: they execute in the same receipt, and if any fails, then they all get reverted.
Actions can be batched only when they act on the same contract. You can batch calling two methods on a contract,
but cannot call two methods on different contracts.Transfer NEAR β
You can send$NEAR from your contract to any other account on the network. The Gas cost for transferring $NEAR is fixed and is based on the protocolβs genesis config. Currently, it costs ~0.45 TGas.
- π¦ Rust
- π JavaScript
- π Python
- πΉ GO
Function Call
Your smart contract can call methods in another contract. In the snippet below we call a method in a deployed Hello NEAR contract, and check if everything went right in the callback.- π¦ Rust
- π JavaScript
- π Python
- πΉ GO
Create a Sub Account
Your contract can create direct sub accounts of itself, for example,user.near can create sub.user.near.
Accounts do NOT have control over their sub-accounts, since they have their own keys.
Sub-accounts are simply useful for organizing your accounts (e.g. dao.project.near, token.project.near).
- π¦ Rust
- π JavaScript
- π Python
- πΉ GO
Creating .testnet / .near Accounts
Accounts can only create immediate sub-accounts of themselves.
If your contract wants to create a .mainnet or .testnet account, then it needs to call
the create_account method of near or testnet root contracts.
- π¦ Rust
- π JavaScript
- π Python
- πΉ GO
Deploy a Contract
When creating an account you can also batch the action of deploying a contract to it. Note that for this, you will need to pre-load the byte-code you want to deploy in your contract.- π¦ Rust
- π Python
- πΉ GO
Add Keys
When you use actions to create a new account, the created account does not have any access keys, meaning that it cannot sign transactions (e.g. to update its contract, delete itself, transfer money). There are two options for adding keys to the account:add_access_key: adds a key that can only call specific methods on a specified contract.add_full_access_key: adds a key that has full access to the account.
- π¦ Rust
- π JavaScript
- π Python
- πΉ GO
The
public_key can use any of NEARβs signature schemes β ed25519, secp256k1, or the post-quantum ml-dsa-65. Adding an ml-dsa-65 key needs no code changes: pass an ml-dsa-65:... key exactly like the examples above.Delete Account
There are two scenarios in which you can use thedelete_account action:
- As the last action in a chain of batched actions.
- To make your smart contract delete its own account.
- π¦ Rust
- π JavaScript
- π Python
- πΉ GO