diff --git a/.github/workflows/build-check.yml b/.github/workflows/build-check.yml
index d2412c96109..9df05eedbe3 100644
--- a/.github/workflows/build-check.yml
+++ b/.github/workflows/build-check.yml
@@ -1,6 +1,10 @@
name: build-check
-on: [push, pull_request]
+on:
+ pull_request:
+ push:
+ branches:
+ - main
jobs:
build-check:
diff --git a/docs/integrations/accounts.md b/docs/integrations/accounts.md
index 4c6e2ec9125..6a8f4a5d732 100644
--- a/docs/integrations/accounts.md
+++ b/docs/integrations/accounts.md
@@ -5,9 +5,6 @@ sidebar_label: Accounts
description: "Learn about NEAR account management for exchanges and integrations, including account creation, key management, and balance tracking."
---
-import Tabs from '@theme/Tabs';
-import TabItem from '@theme/TabItem';
-
This document provides relevant information about NEAR accounts for exchanges looking forward to integrate the NEAR token
Please see the [documentation for accounts](/protocol/account-model) for basic information.
@@ -37,43 +34,17 @@ Below we include examples from the contracts that are likely to be used to perfo
A contract `evgeny.lockup.near` is deployed and we can check its owner by
-
-
-
- ```bash
- near view evgeny.lockup.near get_owner_account_id
- # View call: evgeny.lockup.near.get_owner_account_id()
- # 'evgeny.near'
- ```
-
-
-
-
- ```bash
- near contract call-function as-read-only evgeny.lockup.near get_owner_account_id json-args '{}' network-config testnet now
- # View call: evgeny.lockup.near.get_owner_account_id()
- # 'evgeny.near'
- ```
-
-
+```bash
+near contract call-function as-read-only evgeny.lockup.near get_owner_account_id json-args '{}' network-config testnet now
+# View call: evgeny.lockup.near.get_owner_account_id()
+# 'evgeny.near'
+```
Now we want to transfer some unlocked tokens (1 NEAR) with the following call
-
-
-
- ```bash
- near call evgeny.lockup.near transfer '{"amount":"1000000000000000000000000", "receiver_id": "evgeny.near"}' --accountId=evgeny.near
- ```
-
-
-
-
- ```bash
- near contract call-function as-transaction evgeny.lockup.near transfer json-args '{"amount":"1000000000000000000000000", "receiver_id": "evgeny.near"}' prepaid-gas '100.0 Tgas' attached-deposit '0 NEAR' sign-as evgeny.near network-config testnet sign-with-keychain send
- ```
-
-
+```bash
+near contract call-function as-transaction evgeny.lockup.near transfer json-args '{"amount":"1000000000000000000000000", "receiver_id": "evgeny.near"}' prepaid-gas '100.0 Tgas' attached-deposit '0 NEAR' sign-as evgeny.near network-config testnet sign-with-keychain send
+```
**Note**: the response below can be obtained by hitting the RPC with the transaction hash and NEAR account like this:
diff --git a/docs/integrations/balance.md b/docs/integrations/balance.md
index aa8e2c3e855..402919ee6e3 100644
--- a/docs/integrations/balance.md
+++ b/docs/integrations/balance.md
@@ -5,9 +5,6 @@ sidebar_label: Balance Changes
description: "Learn how to query and track account balances in NEAR protocol, including native NEAR tokens, fungible tokens, and balance management for integrations."
---
-import Tabs from '@theme/Tabs';
-import TabItem from '@theme/TabItem';
-
This document provides an overview of how to track balance changes on NEAR accounts, including sending tokens and viewing balance changes using the NEAR CLI and RPC endpoints.
- [NEAR Account](https://testnet.mynearwallet.com/create)
@@ -22,22 +19,9 @@ This document provides an overview of how to track balance changes on NEAR accou
- Send tokens using [`near send`](../tools/cli.md#send-near)
-
-
-
-
- ```bash
- near send sender.testnet receiver.testnet 1
- ```
-
-
-
-
- ```bash
- near tokens sender.testnet send-near receiver.testnet '1 NEAR' network-config testnet sign-with-keychain send
- ```
-
-
+```bash
+near tokens sender.testnet send-near receiver.testnet '1 NEAR' network-config testnet sign-with-keychain send
+```
- You should see a result in your terminal that looks something like this:
diff --git a/docs/integrations/implicit-accounts.md b/docs/integrations/implicit-accounts.md
index 5399d360dfb..3ad479d25b3 100644
--- a/docs/integrations/implicit-accounts.md
+++ b/docs/integrations/implicit-accounts.md
@@ -5,9 +5,6 @@ sidebar_label: Implicit Accounts
description: "Learn about implicit accounts in NEAR, how they work with Ethereum-style addresses, and their role in chain abstraction and multi-chain integration."
---
-import Tabs from '@theme/Tabs';
-import TabItem from '@theme/TabItem';
-
This document provides an overview of implicit accounts in the NEAR Protocol, including how to create them, use them for transactions, and manage them effectively. Implicit accounts are particularly useful for exchanges and other services that need to facilitate transactions without requiring user interaction.
## Background {#background}
@@ -55,43 +52,17 @@ export ACCOUNT="8bca86065be487de45e795b2c3154fe834d53ffa07e0a44f29e76a2a5f075df8
Assuming you've received tokens on your new account, you can transfer from it using the following command:
-
-
-
-
- ```bash
- near send $ACCOUNT
- ```
-
-
-
-
- ```bash
- near tokens $ACCOUNT send-near ' NEAR' network-config testnet sign-with-keychain send
- ```
-
-
+```bash
+near tokens $ACCOUNT send-near ' NEAR' network-config testnet sign-with-keychain send
+```
## Transferring to the implicit account {#transferring-to-the-implicit-account}
Let's say someone gives you their account ID `0861ea8ddd696525696ccf3148dd706c4fda981c64d8a597490472594400c223`. You can just transfer to it by running:
-
-
-
-
- ```bash
- near send 0861ea8ddd696525696ccf3148dd706c4fda981c64d8a597490472594400c223
- ```
-
-
-
-
- ```bash
- near tokens send-near 0861ea8ddd696525696ccf3148dd706c4fda981c64d8a597490472594400c223 ' NEAR' network-config testnet sign-with-keychain send
- ```
-
-
+```bash
+near tokens send-near 0861ea8ddd696525696ccf3148dd706c4fda981c64d8a597490472594400c223 ' NEAR' network-config testnet sign-with-keychain send
+```
## BONUS: Converting public key using python (for learning purposes) {#bonus-converting-public-key-using-python-for-learning-purposes}
diff --git a/docs/integrations/tokens.md b/docs/integrations/tokens.md
index 7ed2f6fef38..a3a6df1253b 100644
--- a/docs/integrations/tokens.md
+++ b/docs/integrations/tokens.md
@@ -5,9 +5,6 @@ sidebar_label: Fungible Tokens
description: "Learn how to integrate NEAR tokens (NEAR, FT, and NFT) into your application, including balance queries, transfers, and token metadata."
---
-import Tabs from '@theme/Tabs';
-import TabItem from '@theme/TabItem';
-
This document provides an overview of the NEAR fungible token standard, including how to check balances, get metadata, and perform transfers. It also covers the storage requirements for fungible tokens and how to manage storage deposits.
## Introduction {#introduction}
@@ -272,21 +269,9 @@ If there is not enough deposit for the storage or returned value is `null` - you
- using NEAR CLI, don't forget to convert from yoctoⓃ to Ⓝ:
-
-
-
- ```bash
- near call storage_deposit '{"account_id": ""}' --accountId --deposit
- ```
-
-
-
-
- ```bash
- near contract call-function as-transaction storage_deposit json-args '{"account_id": ""}' prepaid-gas '100.0 Tgas' attached-deposit ' NEAR' sign-as network-config testnet sign-with-keychain send
- ```
-
-
+```bash
+near contract call-function as-transaction storage_deposit json-args '{"account_id": ""}' prepaid-gas '100.0 Tgas' attached-deposit ' NEAR' sign-as network-config testnet sign-with-keychain send
+```
Result example:
@@ -549,21 +534,9 @@ http post https://rpc.testnet.near.org jsonrpc=2.0 id=dontcare method=broadcast_
Transfer the tokens:
- using NEAR CLI:
-
-
-
- ```bash
- near call ft_transfer '{"receiver_id": "", "amount": "1"}' --accountId --amount 0.000000000000000000000001
- ```
-
-
-
-
- ```bash
- near contract call-function as-transaction ft_transfer json-args '{"receiver_id": "", "amount": "1"}' prepaid-gas '100.0 Tgas' attached-deposit '1 yoctoNEAR' sign-as network-config testnet sign-with-keychain send
- ```
-
-
+```bash
+near contract call-function as-transaction ft_transfer json-args '{"receiver_id": "", "amount": "1"}' prepaid-gas '100.0 Tgas' attached-deposit '1 yoctoNEAR' sign-as network-config testnet sign-with-keychain send
+```
Result example:
@@ -807,21 +780,9 @@ near tx-status --accountId
Let's create test transaction that should fail and investigate the response. We will try to send more tokens that are available on this account:
- using NEAR CLI:
-
-
-
- ```bash
- near call ft_transfer '{"receiver_id": "", "amount": "10000000000"}' --accountId --amount 0.000000000000000000000001
- ```
-
-
-
-
- ```bash
- near contract call-function as-transaction ft_transfer json-args '{"receiver_id": "", "amount": "1"}' prepaid-gas '100.0 Tgas' attached-deposit '1 yoctoNEAR' sign-as network-config testnet sign-with-keychain send
- ```
-
-
+```bash
+near contract call-function as-transaction ft_transfer json-args '{"receiver_id": "", "amount": "1"}' prepaid-gas '100.0 Tgas' attached-deposit '1 yoctoNEAR' sign-as network-config testnet sign-with-keychain send
+```
- with JSON RPC call:
@@ -1114,21 +1075,9 @@ Let's call `ft_transfer_call` function on `ft` contract (receiver) and examine s
- using NEAR CLI
-
-
-
- ```bash
- near call ft_transfer_call '{"receiver_id": "", "amount": "10", "msg": "take-my-money"}' --accountId --amount 0.000000000000000000000001
- ```
-
-
-
-
- ```bash
- near contract call-function as-transaction ft_transfer_call json-args '{"receiver_id": "", "amount": "10", "msg": "take-my-money"}' prepaid-gas '100.0 Tgas' attached-deposit '1 yoctoNEAR' sign-as network-config testnet sign-with-keychain send
- ```
-
-
+ ```bash
+ near contract call-function as-transaction ft_transfer_call json-args '{"receiver_id": "", "amount": "10", "msg": "take-my-money"}' prepaid-gas '100.0 Tgas' attached-deposit '1 yoctoNEAR' sign-as network-config testnet sign-with-keychain send
+ ```
- with JSON RPC call
@@ -1514,21 +1463,9 @@ Let's try to send more tokens than the account has:
- using NEAR CLI
-
-
-
- ```bash
- near call ft_transfer_call '{"receiver_id": "", "amount": "1000000000", "msg": "take-my-money"}' --accountId --amount 0.000000000000000000000001
- ```
-
-
-
-
- ```bash
- near contract call-function as-transaction ft_transfer_call json-args '{"receiver_id": "", "amount": "1000000000", "msg": "take-my-money"}' prepaid-gas '100.0 Tgas' attached-deposit '1 yoctoNEAR' sign-as network-config testnet sign-with-keychain send
- ```
-
-
+```bash
+near contract call-function as-transaction ft_transfer_call json-args '{"receiver_id": "", "amount": "1000000000", "msg": "take-my-money"}' prepaid-gas '100.0 Tgas' attached-deposit '1 yoctoNEAR' sign-as network-config testnet sign-with-keychain send
+```
Transaction representation:
diff --git a/docs/protocol/account-id.md b/docs/protocol/account-id.md
index fc1609d92de..15cdecb5e9c 100644
--- a/docs/protocol/account-id.md
+++ b/docs/protocol/account-id.md
@@ -65,7 +65,7 @@ near account create-account fund-later use-auto-generation save-to-folder ~/.nea
cat ~/.near-credentials/implicit/8bca86065be487de45e795b2c3154fe834d53ffa07e0a44f29e76a2a5f075df8.json
```
-or `near-seed-phrase` library:
+or using the `near-seed-phrase` library:
```js
import { generateSeedPhrase } from "near-seed-phrase";
@@ -84,10 +84,8 @@ You can derive the implicit account address from a public key by removing the `e
// vanilla js
import { decode } from 'bs58';
Buffer.from(decode(publicKey.replace('ed25519:', ''))).toString('hex')
-```
-```js
-// near-api-js
+// or using near-api-js
import { utils } from 'near-api-js';
utils.keyToImplicitAddress(publicKey);
```
@@ -114,76 +112,32 @@ Anyone can create a `.near` or `.testnet` account, you just need to call the `cr
- 🧑💻 Technical: How to create a named account
-
-Named accounts are created by calling the `create_account` method of the network's top-level account - `testnet` on testnet, and `near` on mainnet.
-
-
-
-
- ```bash
- near call testnet create_account '{"new_account_id": "new-acc.testnet", "new_public_key": "ed25519:"}' --deposit 0.00182 --accountId funding-account.testnet --networkId testnet
- ```
-
-
-
-
- ```bash
- near contract call-function as-transaction testnet create_account json-args '{"new_account_id": "new-acc.testnet", "new_public_key": "ed25519:"}' prepaid-gas '100.0 Tgas' attached-deposit '0.00182 NEAR' sign-as funding-account.testnet network-config testnet sign-with-keychain send
- ```
-
-
-
-We abstract this process in the [NEAR CLI](../tools/cli.md) with the following command:
-
-
-
-
- ```bash
- near create-account new-acc.testnet --useAccount funding-account.testnet --publicKey ed25519:
- ```
-
+ 🧑💻 Technical: How Are Named Accounts Created?
-
+In NEAR, named accounts are created using the [`CreateAccount`](./transaction-anatomy.md#actions) action. Both `testnet` and `near` accounts expose the function `create_account`, which triggers `CreateAccount` to create sub-accounts of themselves.
- ```bash
- near account create-account fund-myself new-acc.testnet '1 NEAR' use-manually-provided-public-key ed25519: sign-as funding-account.testnet network-config testnet sign-with-keychain send
- ```
-
-
+For example, if we want to create the account `alice.testnet` with `0.1 NEAR`, we would need to call the `create_account` method of `testnet` using an existing account (e.g. `funding-account.testnet`):
-You can use the same command to create sub-accounts of an existing named account:
-
-
-
+```bash
+near call testnet create_account '{"new_account_id": "alice.testnet", "new_public_key": "ed25519:"}' --useAccount funding-account.testnet --networkId testnet
+```
- ```bash
- near create-account sub-acc.new-acc.testnet --useAccount new-acc.testnet
- ```
-
+If we then want to create a sub-account of `alice.testnet` - which we control - we can simply trigger the `CreateAccount` action ourselves:
-
+```bash
+near create-account sub-acc.new-acc.testnet --useAccount new-acc.testnet
+```
- ```bash
- near account create-account fund-myself sub-acc.new-acc.testnet '1 NEAR' autogenerate-new-keypair save-to-keychain sign-as new-acc.testnet network-config testnet sign-with-keychain send
- ```
-
-
+> Note: if you want the accounts to have some initial balance, you can add the `--deposit ` flag to the command above
-:::tip Creating Named Accounts
+:::info Creating Named Accounts
If you are not going through an intermediary (i.e. the CLI, or a wallet), then you can create an implicit account, fund it, and call `create_account` on `near` / `testnet`
:::
-:::note
-
-Accounts have **no control** over their sub-accounts, they are different entities. This means that `near` cannot control `bob.near`, and `bob.near` cannot control `sub.bob.near`.
-
-:::
-
---
## Ethereum-like Address
diff --git a/docs/protocol/network/staking.md b/docs/protocol/network/staking.md
index f718d8448cd..5a078d273ac 100644
--- a/docs/protocol/network/staking.md
+++ b/docs/protocol/network/staking.md
@@ -11,7 +11,7 @@ import {CodeTabs, Language, Github} from "@site/src/components/UI/Codetabs"
import { LantstoolLabel } from "@site/src/components/lantstool/LantstoolLabel/LantstoolLabel";
import { TryOutOnLantstool } from "@site/src/components/lantstool/TryOutOnLantstool";
-The NEAR blockchain uses a Proof-of-Stake (PoS) consensus mechanism, where participants (validators) secure the network by staking NEAR tokens. Users who don't want to run a validator node can still participate by delegating their tokens to a staking pool.
+NEAR uses a Proof-of-Stake (PoS), meaning that users chose the active node validators by delegating their tokens to them.
In this article you'll find a detailed explanation of the staking process, including delegating, viewing balances, and withdrawing using the [NEAR CLI](../../tools/cli.md).
@@ -19,222 +19,67 @@ In this article you'll find a detailed explanation of the staking process, inclu
You can review the Staking pool smart contract source code in [this GitHub repository](https://github.com/near/core-contracts/tree/master/staking-pool).
:::
-## Staking overview
-
-When you stake your NEAR tokens, you help secure the network and participate in the consensus process.
-Delegating your tokens means you are entrusting them to a validator, who will stake them on your behalf. You earn rewards based on the performance of the validator.
-
-:::info Staking concepts
-
-- **Staking**: Locking up NEAR tokens to support the network's security and operations.
-- **Validators**: Nodes that validate transactions and produce blocks. They must stake a minimum amount of NEAR to participate.
-- **Delegators**: Users who delegate their NEAR tokens to validators to earn rewards without running a node themselves.
-- **Staking Pool**: A smart contract that aggregates delegated tokens and distributes rewards.
-
-:::
-
-
-## How delegating works
-
-When you delegate NEAR tokens to a staking pool:
-- Your tokens are locked in the pool and used to support a validator.
-- You earn staking rewards proportional to your stake.
-- The validator takes a commission (a percentage of the rewards) for their services.
-
-:::tip Key Considerations
-
-- **Rewards**: Staking rewards are distributed at the end of each epoch and depend on the total stake in the network and the validator's performance. (note: an epoch is approximately 12 hours)
-- **Commission**: Validators charge a commission on rewards, so choose one with a fair rate.
-- **Liquidity**: Staked tokens are locked and cannot be transferred until unstaked and withdrawn.
-- **Validator Performance**: If a validator underperforms (e.g., goes offline), they may be slashed, reducing your rewards.
-
-:::
-
-## Delegating NEAR tokens
-
-Before delegating, you need to choose a validator (a node that participates in staking). You can find a list of validators on [NearBlocks](https://nearblocks.io/node-explorer) Node explorer or through various blockchain explorers like [Pikespeak](https://pikespeak.ai/validators/overview) and [Near Staking](https://near-staking.com/).
-
-Once you select a validator and the stake transaction is confirmed, your tokens are delegated to the staking pool.
-You will start earning staking rewards after the next epoch (approximately 12 hours).
-
-:::info Delegation without a staking pool
-
-For validators, there's also an option to stake NEAR tokens without deploying a staking pool smart contract.
-Check [this section](../../tools/cli.md#staking) to learn how to stake using the [`near-validator`](../../tools/cli.md#validator-extension) CLI.
-
-:::
-
-### Selecting a Staking Pool
-
-Use [NearBlocks](https://nearblocks.io/node-explorer), [Pikespeak](https://pikespeak.ai/validators/overview) or [Near Staking](https://near-staking.com/) to find a validator and their staking pool.
-Look for validators with a good track record, uptime, and reasonable commission rates.
-
-:::tip Validator selection tips
-
-- **Validator Selection**: It's wise to research validators based on their performance, fees, and community reputation before making a selection.
-- **Regular Monitoring**: Keep an eye on the validator’s performance; continuously delegating to a poorly performing validator can affect your staking rewards.
-- **Fees**: Be aware that validators may charge fees from the rewards earned.
-
-:::
-
-If you prefer, you can get the list of current validators by using the [`near-validator`](../../tools/cli.md#validator-extension) CLI:
-
-
-
-
-
-```sh
-near-validator validators network-config mainnet now
-```
-
-
- }>
-
-
-
-
+---
-### Staking using CLI
+## Delegate NEAR tokens
-Once you have chosen a validator you want to delegate your tokens to, follow these steps to stake them using the NEAR CLI:
+Before delegating, you need to choose a validator (a node that participates in staking).
-1. Connect your wallet to the CLI and ensure you have NEAR tokens to delegate.
+Check [NearBlocks](https://nearblocks.io/node-explorer), [Pikespeak](https://pikespeak.ai/validators/overview) or [Near Staking](https://near-staking.com/), and look for validators with a good track record, uptime, and reasonable commission rates.
-
-
+
-```sh
-near account import-account using-web-wallet network-config mainnet
-```
+ List validators using CLI
-
-
+ If you prefer, you can get the list of current validators by using the [`near-validator`](../../tools/cli.md#validator-extension) CLI:
-```sh
-near login
-```
+ ```sh
+ near-validator validators network-config mainnet now
+ ```
-
-
+
+
-2. Deposit and stake tokens to the `` staking pool:
+### Stake Tokens
-
-
-```sh
-near staking delegation deposit-and-stake '100 NEAR' network-config mainnet sign-with-keychain
-```
-
+
+ ```sh
+ near staking delegation deposit-and-stake '100 NEAR' network-config mainnet sign-with-keychain
+ ```
-
-
-Deposit the tokens to the staking pool:
-
-```sh
-near call deposit '{}' --accountId --deposit 100
-```
-
-Stake the deposited tokens by calling the `stake` method:
-
-```sh
-near call stake '{"amount": "100000000000000000000000000"}' --accountId
-```
-
+
+ ```sh
+ near call deposit_and_stake --useAccount --deposit 100
+ ```
}>
-:::tip Interactive CLI
-
-If you want to manage your staking actions with an interactive CLI, use this command and follow the prompts on your screen:
+:::tip
-```sh
-near staking delegation
-```
+You will start earning staking rewards after the next epoch (approximately 12 hours)
:::
-3. Confirm Delegation:
+
-Once the transaction is confirmed, your tokens are delegated to the staking pool.
+### Staked Balance
+To check your staked balance on the `` pool for the `` account, run the following command:
-
-
-```sh
-near staking delegation view-balance network-config mainnet now
-```
-
+
+ ```sh
+ near staking delegation view-balance network-config mainnet now
+ ```
-
-
-```sh
-near view get_account_staked_balance '{"account_id": ""}'
-```
-
-
- }>
-
-
-
-
-:::info Using a wallet to check your staked tokens
-
-You can see your staked balance, rewards earned, and the validator you delegated to using a web3 wallet. For example, you can try `https://app.mynearwallet.com/profile/`.
-
-:::
-
-## Viewing staked balances and rewards
-
-After delegating, you can view your staked tokens and accrued rewards.
-The rewards are typically distributed periodically, and you will be able to see how many rewards you have earned based on your validator's performance.
-
-#### User total balance
-
-To check your total balance on the `` pool:
-
-
-
-
-```sh
-near staking delegation view-balance network-config mainnet now
-```
-
-
-
-
-```sh
-near view get_account_total_balance '{"account_id": ""}'
-```
-
-
- }>
-
-
-
-
-#### User staked balance
-
-To check your staked balance on the `` pool:
-
-
-
-
-```sh
-near staking delegation view-balance network-config mainnet now
-```
-
-
-
-
-```sh
-near view get_account_staked_balance '{"account_id": ""}'
-```
-
+
+ ```sh
+ near view get_account_staked_balance '{"account_id": ""}'
+ ```
}>
@@ -242,100 +87,90 @@ near view get_account_staked_balance '{"account_id": "
-Staking pool balances
-
-You can view additional information and balances from the staking pool using the following CLI commands:
-
-#### Total staked balance of the entire pool
-
-
-
-```sh
-near view get_total_staked_balance '{}'
-```
-
-
- }>
-
-
-
-
-
-#### Owner of the staking pool
-
-
-
-```sh
-near view get_owner_id '{}'
-```
-
-
- }>
-
-
-
-
-
-#### Current reward fee
-
-
-
-```sh
-near view get_reward_fee_fraction '{}'
-```
-
-
- }>
-
-
-
-
-
-#### Owner's balance
-
-
-
-```sh
-near view get_account_total_balance '{"account_id": "owner"}'
-```
-
-
- }>
-
-
-
-
-
-#### Staking key
-
-
-
-```sh
-near view get_staking_key '{}'
-```
-
-
- }>
-
-
-
-
+ Staking pool balances
+
+ You can view additional information and balances from the staking pool using the following CLI commands:
+
+ #### Total staked balance of the entire pool
+
+
+ ```sh
+ near view get_total_staked_balance '{}'
+ ```
+
+ }>
+
+
+
+
+
+ #### Owner of the staking pool
+
+
+ ```sh
+ near view get_owner_id '{}'
+ ```
+
+ }>
+
+
+
+
+
+ #### Current reward fee
+
+
+ ```sh
+ near view get_reward_fee_fraction '{}'
+ ```
+
+ }>
+
+
+
+
+
+ #### Owner's balance
+
+
+ ```sh
+ near view get_account_total_balance '{"account_id": "owner"}'
+ ```
+
+ }>
+
+
+
+
+
+ #### Staking key
+
+
+ ```sh
+ near view get_staking_key '{}'
+ ```
+
+ }>
+
+
+
-## Withdrawing staked tokens
+---
+
+## Withdrawing Staked Tokens
-To withdraw your staked tokens, first you need to "un-delegate" them from your validator. Your tokens will enter a 4 epoch (approximately 48 hours) unbonding period before they can be withdrawn.
-Once they're unlocked, you can execute the withdrawal, and once the transaction is processed, your funds will be available in your account.
+To withdraw your staked tokens, you will first need to "un-delegate" them from the validator.
-### Unstaking using CLI
+Your tokens will enter a 4 epoch (~24 hours) unbonding period before they can be withdrawn.
-To un-delegate the tokens:
+
-1. First execute the `unstake` method on the `` contract:
+### Unstake Tokens
-
+
```sh
near staking delegation unstake '1 NEAR' network-config mainnet sign-with-keychain
@@ -343,7 +178,7 @@ near staking delegation unstake '1 NEAR' netw
:::info
-If you want to unstake all tokens, you can use the `unstake-all` command:
+Use the `unstake-all` command to to unstake all tokens at once:
```sh
near staking delegation unstake-all network-config mainnet sign-with-keychain
@@ -352,11 +187,15 @@ near staking delegation unstake-all network-c
:::
-
+
-```sh
-near call unstake '{"amount": "100000000000000000000000000"}' --accountId
-```
+ ```sh
+ near call unstake '{"amount": "100000000000000000000000000"}' --useAccount
+ ```
+
+ :::info
+ Call the `unstake_all` method to unstake all tokens at once
+ :::
}>
@@ -364,17 +203,19 @@ near call unstake '{"amount": "100000000000000000000000000"}' --a
-2. Check the unstaked balance for your `` account:
+
+
+### Query Unstaked Balance
-
+
```sh
near staking delegation view-balance network-config mainnet now
```
-
+
```sh
near view get_account_unstaked_balance '{"account_id": ""}'
@@ -386,34 +227,14 @@ near view get_account_unstaked_balance '{"account_id": "
-3. After 4 epochs, check if you can withdraw:
-
-
-
-
-```sh
-near contract call-function as-read-only is_account_unstaked_balance_available json-args '{"account_id": ""}' network-config mainnet now
-```
-
-
-
-
-```sh
-near view is_account_unstaked_balance_available '{"account_id": ""}'
-```
-
-
- }>
-
-
-
+
-If the Validator's response is `true`, then your tokens are ready for the last step.
+### Withdraw Tokens
-4. Finally, withdraw the unstaked tokens:
+Once the unbonding period has passed, you can withdraw your unstaked tokens:
-
+
```sh
near staking delegation withdraw '1 NEAR' network-config mainnet sign-with-keychain
@@ -430,10 +251,10 @@ near staking delegation withdraw-all network-
:::
-
+
```sh
-near call withdraw '{"amount": "100000000000000000000000000"}' --accountId
+near call withdraw '{"amount": "100000000000000000000000000"}' --useAccount
```
diff --git a/docs/smart-contracts/anatomy/serialization-interface.md b/docs/smart-contracts/anatomy/serialization-interface.md
index ce82beaa9f9..5600be75964 100644
--- a/docs/smart-contracts/anatomy/serialization-interface.md
+++ b/docs/smart-contracts/anatomy/serialization-interface.md
@@ -55,21 +55,9 @@ Note that this is using this simple struct:
To call this with NEAR CLI, use a command similar to this:
-
-
-
-```bash
-near call rust-status-message.demo.testnet set_status_borsh --base64 'DAAAAEFsb2hhIGhvbnVhIQ==' --accountId demo.testnet
-```
-
-
-
```bash
near contract call-function as-transaction rust-status-message.demo.testnet set_status_borsh base64-args 'DAAAAEFsb2hhIGhvbnVhIQ==' prepaid-gas '30 TeraGas' attached-deposit '0 NEAR' sign-as demo.testnet network-config testnet sign-with-keychain send
```
-
-
-
See more details in [this GitHub gist](https://gist.github.com/mfornet/d8a94af333a68d67affd8cb78464c7c0) from [Marcelo](https://gist.github.com/mfornet).
diff --git a/docs/smart-contracts/anatomy/serialization.md b/docs/smart-contracts/anatomy/serialization.md
index bb2a52fb39b..aeaf4c27dd2 100644
--- a/docs/smart-contracts/anatomy/serialization.md
+++ b/docs/smart-contracts/anatomy/serialization.md
@@ -4,9 +4,6 @@ title: Notes on Serialization
description: "Learn how contract serialize data for function calls and storage."
---
-import Tabs from '@theme/Tabs';
-import TabItem from '@theme/TabItem';
-
Smart contracts need to be able to **communicate complex data** in a simple way, while also **reading and storing** such data into their states efficiently.
To achieve such simple communication and efficient storage, smart contracts morph the data
@@ -167,50 +164,22 @@ impl Contract {
If we deploy the contract into a new account and immediately ask for the state we will see
it is empty:
-
-
-
- ```bash
- near view-state $CONTRACT --finality optimistic
-
- # Result is: []
- ```
-
-
-
+```bash
+near view-state $CONTRACT --finality optimistic
- ```bash
- near contract view-storage $CONTRACT all as-json network-config testnet now
- ```
-
-
+# Result is: []
+```
#### Initializing the State
If we initialize the state we can see how Borsh is used to serialize the state
-
-
-
- ```bash
- # initialize with the string "hi" and 0
- near call $CONTRACT init '{"string":"hi", "first_u8":0}' --accountId $CONTRACT
-
- # check the state
- near view-state $CONTRACT --utf8 --finality optimistic
- ```
-
-
-
-
- ```bash
- # initialize with the string "hi" and 0
- near contract call-function as-transaction $CONTRACT init json-args '{"string":"hi", "first_u8":0}' prepaid-gas '30.0 Tgas' attached-deposit '0 NEAR' sign-as $CONTRACT network-config testnet sign-with-keychain send
+```bash
+# initialize with the string "hi" and 0
+near call $CONTRACT init '{"string":"hi", "first_u8":0}' --accountId $CONTRACT
- # check the state
- near contract view-storage $CONTRACT all as-json network-config testnet now
- ```
-
-
+# check the state
+near view-state $CONTRACT --utf8 --finality optimistic
+```
@@ -251,21 +220,9 @@ value: '\x00'
#### Modifying the State
If we modify the stored string and add a new number, the state changes accordingly:
-
-
-
- ```bash
- near call $CONTRACT change_state '{"string":"bye", "number":1}' --accountId $CONTRACT
- ```
-
-
-
-
- ```bash
- near contract call-function as-transaction $CONTRACT change_state json-args '{"string":"bye", "number":1}' prepaid-gas '30.0 Tgas' attached-deposit '0 NEAR' sign-as $CONTRACT network-config testnet sign-with-keychain send
- ```
-
-
+```bash
+near call $CONTRACT change_state '{"string":"bye", "number":1}' --accountId $CONTRACT
+```
diff --git a/docs/smart-contracts/release/deploy.md b/docs/smart-contracts/release/deploy.md
index 50d56a4db8d..501ac9c7cee 100644
--- a/docs/smart-contracts/release/deploy.md
+++ b/docs/smart-contracts/release/deploy.md
@@ -49,57 +49,24 @@ Thanks to the `NEAR CLI` deploying a contract is as simple as:
### Create an Account and Deploy
+```bash
+# Create a new account pre-funded by a faucet
+near create-account --useFaucet
-
-
-
- ```bash
- # Create a new account pre-funded by a faucet
- near create-account --useFaucet
-
- # deploy the contract
- near deploy
- ```
-
-
-
-
- ```bash
- # Create a new account pre-funded by a faucet
- near account create-account sponsor-by-faucet-service .testnet autogenerate-new-keypair save-to-keychain network-config testnet create
-
- # deploy the contract
- near contract deploy .testnet use-file without-init-call network-config testnet sign-with-keychain
- ```
-
-
+# deploy the contract
+near deploy
+```
### Deploy in an Existing Account
-
-
+```bash
+# login into your account
+near login
- ```bash
- # login into your account
- near login
-
- # deploy the contract
- near deploy
- ```
-
-
-
-
- ```bash
- # login into your account
- near account import-account using-web-wallet network-config testnet
-
- # deploy the contract
- near contract deploy use-file without-init-call network-config testnet sign-with-keychain send
- ```
-
-
+# deploy the contract
+near deploy
+```
:::tip
You can overwrite a contract by deploying another on top of it. In this case, the account's logic
@@ -122,23 +89,10 @@ Considering this, we advise to name methods using `snake_case` in all SDKs as th
If your contract has an [initialization method](../anatomy/storage.md) you can call it to
initialize the state. This is not necessary if your contract implements `default` values for the state.
-
-
-
- ```bash
- # Call the initialization method (`init` in our examples)
- near call [] --accountId
- ```
-
-
-
-
- ```bash
- # Call the initialization method (`init` in our examples)
- near contract call-function as-transaction json-args [] prepaid-gas '30 TeraGas' attached-deposit '0 NEAR' sign-as network-config testnet sign-with-keychain send
- ```
-
-
+```bash
+# Call the initialization method (`init` in our examples)
+near call [] --accountId
+```
:::info
You can initialize your contract [during deployment](#deploying-the-contract) using the `--initFunction` & `--initArgs` arguments.
@@ -155,21 +109,9 @@ Once your contract is deployed you can interact with it right away using [NEAR C
### View methods
View methods are those that perform **read-only** operations. Calling these methods is free, and do not require to specify which account is being used to make the call:
-
-
-
- ```bash
- near view
- ```
-
-
-
-
- ```bash
- near contract call-function as-read-only text-args '' network-config testnet now
- ```
-
-
+```bash
+near view
+```
:::tip
View methods have by default 200 TGAS for execution
@@ -182,18 +124,6 @@ View methods have by default 200 TGAS for execution
Change methods are those that perform both read and write operations. For these methods we do need to specify the account being used to make the call,
since that account will expend GAS in the call.
-
-
-
- ```bash
- near call --accountId [--deposit ] [--gas ]
- ```
-
-
-
-
- ```bash
- near contract call-function as-transaction json-args prepaid-gas attached-deposit sign-as network-config testnet sign-with-keychain send
- ```
-
-
+```bash
+near call --accountId [--deposit ] [--gas ]
+```
diff --git a/docs/smart-contracts/release/lock.md b/docs/smart-contracts/release/lock.md
index fb1774ca7a2..d67a026b000 100644
--- a/docs/smart-contracts/release/lock.md
+++ b/docs/smart-contracts/release/lock.md
@@ -14,33 +14,13 @@ Removing all [full access keys](/tools/near-cli#delete-key) from an account will
When an account is locked nobody can perform transactions in the account's name (e.g. update the code or transfer money).
#### How to Lock an Account
-
-
- ```bash
- near keys
- # result: [access_key: {"nonce": ..., "public_key": ''}]
+```bash
+near list-keys
+# result: [access_key: {"nonce": ..., "public_key": ''}]
- near delete-key ''
- ```
-
-
-
-
- ```bash
- near account list-keys network-config testnet now
- # result:
-
- +---+------------+-------+-------------+
- | # | Public Key | Nonce | Permissions |
- +---+------------+-------+-------------+
- .. '' ... ...
- +---+------------+-------+-------------+
-
- near account delete-key '' network-config testnet sign-with-keychain send
- ```
-
-
+near delete-key ''
+```
#### Why Locking an Account
@@ -49,6 +29,6 @@ contract or balance.
:::tip Upgrading Locked Contracts
-Please do note that, while no external actor can update the contract, the contract **can still upgrade itself**. See [this article](upgrade.md#programmatic-update) for details.
+While no external actor can update the contract, the contract **can still upgrade itself**, see [this article](upgrade.md#programmatic-update) for details
:::
diff --git a/docs/smart-contracts/release/upgrade.md b/docs/smart-contracts/release/upgrade.md
index b81ac2d69ad..c9b582572e3 100644
--- a/docs/smart-contracts/release/upgrade.md
+++ b/docs/smart-contracts/release/upgrade.md
@@ -28,9 +28,6 @@ Contract's can be updated in two ways:
Simply re-deploy another contract using your preferred tool, for example, using
[NEAR CLI](../../tools/cli.md):
-
-
-
```bash
# (optional) If you don't have an account, create one
near create-account --useFaucet
@@ -39,22 +36,6 @@ near create-account --useFaucet
near deploy
```
-
-
-
-
-```bash
-# (optional) If you don't have an account, create one
-near account create-account sponsor-by-faucet-service somrnd.testnet autogenerate-new-keypair save-to-keychain network-config testnet create
-
-# Deploy the contract
-near contract deploy use-file without-init-call network-config testnet sign-with-keychain send
-```
-
-
-
-
-
---
## Programmatic Update
@@ -77,19 +58,7 @@ A smart contract can also update itself by implementing a method that:
#### How to Invoke Such Method?
-
-
-```bash
-# Load the contract's raw bytes
-CONTRACT_BYTES=`cat ./path/to/wasm.wasm | base64`
-
-# Call the update_contract method
-near call update_contract "$CONTRACT_BYTES" --base64 --accountId --gas 300000000000000
-```
-
-
-
-
+
```bash
# Call the update_contract method