Skip to content

Latest commit

 

History

History
2156 lines (1780 loc) · 88.5 KB

GUIDE.en.md

File metadata and controls

2156 lines (1780 loc) · 88.5 KB

User Guide

This guide is intended to give a detailed description of near CLI and an overview of its capabilities. This guide assumes that near CLI is installed and that readers have passing familiarity with using command line tools. This also assumes a Unix-like system, although most commands are probably easily translatable to any command line shell environment.

With near CLI you can create, sign and send transactions in online mode, which is enabled by default. In offline mode, you can create and sign a transaction. The base64 encoding transaction can be signed or sent later (even from another computer). To enter the offline mode, you need to set the --offline flag in the command:

near --offline tokens \
    fro_volod.testnet \
    send-near volodymyr.testnet 0.1NEAR \
    network-config testnet \
    sign-later

Before proceeding to the description of specific commands, it is necessary to consider two points common to these commands:

  1. Sign transaction

    near CLI offers several ways to sign the created transaction. Let's take a closer look at each.

    • sign-with-keychain - Sign the transaction with a key saved in the secure keychain

      near CLI stores and retrieves passwords in a secure OS storage. There near CLI will independently find the access keys and sign the created transaction.

    • sign-with-legacy-keychain - Sign the transaction with a key saved in legacy keychain (compatible with the old near CLI)

      near CLI will independently find access keys and sign the created transaction. Directory with access keys defined in config. The access keys must be in the public-key.json file located in /Users/user/.near-credentials/network-name/user-name/ For example, /Users/frovolod/.near-credentials/testnet/volodymyr.testnet/ed25519_8h7kFK4quSUJRkUwo3LLiK83sraEm2jnQTECuZhWu8HC.json

      Demonstration of the command in interactive mode
    • sign-with-ledger - Sign the transaction with Ledger Nano device

      This option involves signing the created transaction using a ledger.

    • sign-with-plaintext-private-key - Sign the transaction with a plaintext private key

      When choosing this signature option, near CLI will ask the user to enter access keys:

      • "public_key":"ed25519:Ebx7...",
      • "private_key":"ed25519:2qM8..."
    • sign-with-access-key-file - Sign the transaction using the account access key file (access-key-file.json)

      When choosing this signature option, near CLI will ask the user to enter the path to a file that contains information about account access keys.

    • sign-with-seed-phrase - Sign the transaction using the seed phrase

      When choosing this signature option, near CLI will ask the user to enter the mnemonic phrase associated with the account.

    • sign-later - Prepare unsigned transaction (we'll use base64 encoding to simplify copy-pasting)

      This option involves signing the created transaction later.

  2. Actions with a signed transaction

    near CLI support for meta transactions as specified in NEP-366. To create it, you just need to specify a network that supports meta transactions. You can find out about such support in config. The meta_transaction_relayer_url field is responsible for the ability to support meta transactions. For example:

    meta_transaction_relayer_url = "https://near-testnet.api.pagoda.co/relay"

    A signed transaction / meta transactions can be sent for immediate execution:

    • send - Send the transaction to the network

    or display in base64 format to send:

    • display - Print only the signed transaction in base64 encoding. We will use it to send it later. (Example: near transaction send-signed-transaction 'EQAAAHZvb...' ...)

Command groups

account - Manage accounts

View account details (View properties for an account) and view account access keys (View a list of access keys of an account) is possible at the current time (now) and at a certain point in the past by specifying the block (at-block-height or at-block-hash). The examples below show how these modes can be used.

view-account-summary - View properties for an account

now - View properties in the final block

To view an account summary for the last block, in the terminal command line type:

near account \
    view-account-summary fro_volod.testnet \
    network-config testnet \
    now
The result of this command will be as follows:
Account details for 'fro_volod.testnet' at block #97804915 (5G8HHWMJMHRMMaHTjeZLSvL7ruYMtH9tXq25Q6BPUivu)
Native account balance: 182.685021399504861699999997 NEAR
Validator stake: 0 NEAR
Storage used by the account: 288962 bytes
Contract code SHA-256 checksum (hex): fd999145baf49ece7d09fca7d030d384c4ea8ed4df651c6e87a015c4dfa6c0ec
Number of access keys: 14
   1. ed25519:2QFAeUutKUDpmgKDyHXm7Wcz1uhjxk92fK6zY2dB7FCD (nonce: 97492076000000) is granted to only do [] function calls on v2.ref-farming.testnet with an allowance of 0.25 NEAR
   2. ed25519:3p1HbrTDYxY4q3V6QznW14qkuv3Bq1phFpCTsbrJpbEC (nonce: 94363284000000) is granted to full access
   3. ed25519:5UJE4PzyxECS42hBZSD1QQCLdq5j39vCtzshFPbnGdm1 (nonce: 73069087000002) is granted to full access
   4. ed25519:6YU78BezKwQNrz5vmtkSCALtx7cPDC1JBs9DhjeSJ39X (nonce: 97490513000000) is granted to only do [] function calls on v2.ref-farming.testnet with an allowance of 0.25 NEAR
   5. ed25519:7YCfA1KrToJtAYGTBgAMe4LWfQEi4iwLGcH2q5SvGKzD (nonce: 94982716000000) is granted to only do [] function calls on mintspace2.testnet with an allowance of 0.25 NEAR
   6. ed25519:95w5YFsJ3iktzDwRBWUGqLF6Gv5CoJuVifBjcEEdJs8s (nonce: 72253433000003) is granted to full access
   7. ed25519:9nyDySTNAGPywxC9pG4DPdnF3eEVexDgrfzZYsoahPsV (nonce: 76057805000000) is granted to full access
   8. ed25519:AEC4szaeNzT8PQAifsnisdivq4mwswJbBM65DdkT6kdS (nonce: 72263674000000) is granted to full access
   9. ed25519:D31un5TFeABdNUVMaf3QzeBz3Z3yau2GZA2VPe8XX6GB (nonce: 72325441000021) is granted to full access
  10. ed25519:DZz4r5oLSBVcLuqFzSoLUEJ3Qv67cpgGbsRHy8SvbGiU (nonce: 72253481000000) is granted to full access
  11. ed25519:DyKmdLkWMqC1HFs6t6PfNhVemjQE16W2RNofWPpW5ZZh (nonce: 72325378000007) is granted to full access
  12. ed25519:EWoYxHNZHtApUfu1nTGC49XHW5dNinoDKABcauHnjevZ (nonce: 73069042000001) is granted to full access
  13. ed25519:EYtsL67TpgfpE1udnga2m41vDoBqeZ2DB32onhsxsVUb (nonce: 72251760000002) is granted to full access
  14. ed25519:G2U7aZ91pgG3TS96gCWov5L1DkNWSi3756RRkwuspZ4L (nonce: 72251684000002) is granted to full access
Demonstration of the command in interactive mode
at-block-height - View properties in a height-selected block

To view an account summary for a specific block, you can specify the height of that block. To do this, at the terminal command line, type:

near account \
    view-account-summary fro_volod.testnet \
    network-config testnet \
    at-block-height 73069245
The result of this command will be as follows:
Account details for 'fro_volod.testnet' at block #73069245 (HCUJq3vQ3ztyCZAhmRmHR3cwSDcoE4zEbaWkhAjFuxUY)
Native account balance: 198.9924766125790117 NEAR
Validator stake: 0 NEAR
Storage used by the account: 288660 bytes
Contract code SHA-256 checksum (hex): fd999145baf49ece7d09fca7d030d384c4ea8ed4df651c6e87a015c4dfa6c0ec
Number of access keys: 12
   1. ed25519:5UJE4PzyxECS42hBZSD1QQCLdq5j39vCtzshFPbnGdm1 (nonce: 73069087000001) is granted to full access
   2. ed25519:95w5YFsJ3iktzDwRBWUGqLF6Gv5CoJuVifBjcEEdJs8s (nonce: 72253433000003) is granted to full access
   3. ed25519:AEC4szaeNzT8PQAifsnisdivq4mwswJbBM65DdkT6kdS (nonce: 72263674000000) is granted to full access
   4. ed25519:D31un5TFeABdNUVMaf3QzeBz3Z3yau2GZA2VPe8XX6GB (nonce: 72325441000009) is granted to full access
   5. ed25519:DZz4r5oLSBVcLuqFzSoLUEJ3Qv67cpgGbsRHy8SvbGiU (nonce: 72253481000000) is granted to full access
   6. ed25519:DyKmdLkWMqC1HFs6t6PfNhVemjQE16W2RNofWPpW5ZZh (nonce: 72325378000001) is granted to full access
   7. ed25519:EWoYxHNZHtApUfu1nTGC49XHW5dNinoDKABcauHnjevZ (nonce: 73069042000001) is granted to full access
   8. ed25519:EYtsL67TpgfpE1udnga2m41vDoBqeZ2DB32onhsxsVUb (nonce: 72251760000002) is granted to full access
   9. ed25519:G2U7aZ91pgG3TS96gCWov5L1DkNWSi3756RRkwuspZ4L (nonce: 72251684000002) is granted to full access
  10. ed25519:H5A5WfckocSLeXC7h22PcnscrWWrADHaRzrVWFMYT5o9 (nonce: 72254265000000) is granted to full access
  11. ed25519:HXHM2GTqDzCZnd7UQzPtL7VwcFfcm7n8Z8voo1ArE4Tr (nonce: 72263503000002) is granted to full access
  12. ed25519:HjzSeCGdWT15iSj2TybmKV2dZteu1VYYAaYvNYVNZY2W (nonce: 72253750000000) is granted to full access
Demonstration of the command in interactive mode
at-block-hash - View properties in a hash-selected block

To view an account summary for a specific block, you can specify the hash of that block. To do this, at the terminal command line, type:

near account \
    view-account-summary fro_volod.testnet \
    network-config testnet \
    at-block-hash HCUJq3vQ3ztyCZAhmRmHR3cwSDcoE4zEbaWkhAjFuxUY
The result of this command will be as follows:
Account details for 'fro_volod.testnet' at block #73069245 (HCUJq3vQ3ztyCZAhmRmHR3cwSDcoE4zEbaWkhAjFuxUY)
Native account balance: 198.9924766125790117 NEAR
Validator stake: 0 NEAR
Storage used by the account: 288660 bytes
Contract code SHA-256 checksum (hex): fd999145baf49ece7d09fca7d030d384c4ea8ed4df651c6e87a015c4dfa6c0ec
Number of access keys: 12
   1. ed25519:5UJE4PzyxECS42hBZSD1QQCLdq5j39vCtzshFPbnGdm1 (nonce: 73069087000001) is granted to full access
   2. ed25519:95w5YFsJ3iktzDwRBWUGqLF6Gv5CoJuVifBjcEEdJs8s (nonce: 72253433000003) is granted to full access
   3. ed25519:AEC4szaeNzT8PQAifsnisdivq4mwswJbBM65DdkT6kdS (nonce: 72263674000000) is granted to full access
   4. ed25519:D31un5TFeABdNUVMaf3QzeBz3Z3yau2GZA2VPe8XX6GB (nonce: 72325441000009) is granted to full access
   5. ed25519:DZz4r5oLSBVcLuqFzSoLUEJ3Qv67cpgGbsRHy8SvbGiU (nonce: 72253481000000) is granted to full access
   6. ed25519:DyKmdLkWMqC1HFs6t6PfNhVemjQE16W2RNofWPpW5ZZh (nonce: 72325378000001) is granted to full access
   7. ed25519:EWoYxHNZHtApUfu1nTGC49XHW5dNinoDKABcauHnjevZ (nonce: 73069042000001) is granted to full access
   8. ed25519:EYtsL67TpgfpE1udnga2m41vDoBqeZ2DB32onhsxsVUb (nonce: 72251760000002) is granted to full access
   9. ed25519:G2U7aZ91pgG3TS96gCWov5L1DkNWSi3756RRkwuspZ4L (nonce: 72251684000002) is granted to full access
  10. ed25519:H5A5WfckocSLeXC7h22PcnscrWWrADHaRzrVWFMYT5o9 (nonce: 72254265000000) is granted to full access
  11. ed25519:HXHM2GTqDzCZnd7UQzPtL7VwcFfcm7n8Z8voo1ArE4Tr (nonce: 72263503000002) is granted to full access
  12. ed25519:HjzSeCGdWT15iSj2TybmKV2dZteu1VYYAaYvNYVNZY2W (nonce: 72253750000000) is granted to full access
Demonstration of the command in interactive mode

import-account - Import existing account (a.k.a. "sign in")

using-web-wallet - Import existing account using NEAR Wallet (a.k.a. "sign in")

To authorize the user, in the terminal command line type:

near account \
    import-account \
    using-web-wallet \
    network-config testnet

You will be redirected to the browser for authorization. Default wallet url is https://app.mynearwallet.com/ (for testnet - https://testnet.mynearwallet.com/). But if you want to change to a different wallet url, you can use --wallet-url option:

near account \
    import-account \
    using-web-wallet \
    network-config testnet\
    --wallet-url 'https://wallet.testnet.near.org/'

After successful authorization in NEAR Wallet, you need to return to the terminal and enter your login.

The result of this command will be as follows:
The data for the access key is saved in macOS Keychain
Demonstration of the command in interactive mode

using-seed-phrase - Import existing account using a seed phrase

To authorize the user, in the terminal command line type:

near account \
    import-account \
    using-seed-phrase 'rapid cover napkin accuse junk drill sick tooth poem patch evil fan' \
        --seed-phrase-hd-path 'm/44'\''/397'\''/0'\''' \
    network-config testnet
The result of this command will be as follows:
The data for the access key is saved in macOS Keychain
Demonstration of the command in interactive mode

using-private-key - Import existing account using a private key

To authorize the user, in the terminal command line type:

near account \
    import-account \
    using-private-key ed25519:5YhAaEe3G4VtiBavJMvpzPPmknfsTauzVjwK1ZjPVw2MFM6zFyUv4tSiSfCbCn78mEnMifE6iX5qbhFsWEwErcC2 \
    network-config testnet
The result of this command will be as follows:
The data for the access key is saved in macOS Keychain
Demonstration of the command in interactive mode

export-account - Export existing account

using-web-wallet - Export existing account using NEAR Wallet

To export an existing account, enter in the terminal command line:

near account \
    export-account volodymyr.testnet \
    using-web-wallet \
    network-config testnet

You will be redirected to the browser for authorization. Default wallet url is https://app.mynearwallet.com/ (for testnet - https://testnet.mynearwallet.com/). But if you want to change to a different wallet url, you can use --wallet-url option:

near account \
    export-account volodymyr.testnet \
    using-web-wallet \
    network-config testnet\
    --wallet-url 'https://wallet.testnet.near.org/'
Demonstration of the command in interactive mode

using-seed-phrase - Export existing account using a seed phrase

To export an existing account, enter in the terminal command line:

near account \
    export-account volodymyr.testnet \
    using-seed-phrase \
    network-config testnet
The result of this command will be as follows:
Here is the secret recovery seed phrase for account <volodymyr.testnet>: "feature army carpet ..." (HD Path: m/44'/397'/0').

using-private-key - Export existing account using a private key

To export an existing account, enter in the terminal command line:

near account \
    export-account volodymyr.testnet \
    using-private-key \
    network-config testnet
The result of this command will be as follows:
Here is the private key for account <volodymyr.testnet>: ed25519:4TKr1c7p...y7p8BvGdB

create-account - Create a new account

sponsor-by-faucet-service - I would like the faucet service sponsor to cover the cost of creating an account (testnet only for now)

testnet has a faucet (helper service) that can sponsor account creation. When adding your own network in the add-connection configurator, you can specify your service in the faucet_url field. Access keys to the created account can be added in several ways:

autogenerate-new-keypair - Automatically generate a key pair

In order to create an account, in the terminal command line type:

near account \
    create-account sponsor-by-faucet-service test_fro.testnet \
    autogenerate-new-keypair \
    save-to-keychain \
    network-config testnet \
    create
The result of this command will be as follows:
The data for the access key is saved in a file /Users/frovolod/.near-credentials/testnet/test_fro.testnet/ed25519_CCwvhsp3Y3BfLbfYJQJqXJA2CaSP7CRjn1t7PyEtsjej.json
The data for the access key is saved in a file /Users/frovolod/.near-credentials/testnet/test_fro.testnet.json

New account <test_fro.testnet> created successfully.
Transaction ID: FnsrXbnzH1jjTWpAo1M8cZhEN5p7jyqgRPa1aqnRzxp3
To see the transaction in the transaction explorer, please open this url in your browser:
https://explorer.testnet.near.org/transactions/FnsrXbnzH1jjTWpAo1M8cZhEN5p7jyqgRPa1aqnRzxp3
Demonstration of the command in interactive mode
use-manually-provided-seed-prase - Use the provided seed phrase manually

This command adds a previously known mnemonic phrase to the account. In order to execute this command, in the terminal command line type:

near account \
    create-account sponsor-by-faucet-service test_fro1.testnet \
    use-manually-provided-seed-phrase 'start vote foot cereal link cabin fantasy universe hero drama bird fiction' \
    network-config testnet \
    create
The result of this command will be as follows:
New account <test_fro1.testnet> created successfully.
Transaction ID: D1rRpZx5AcYWzC91Jdt69qF1iqai7knUAtvdvqNA2bv
To see the transaction in the transaction explorer, please open this url in your browser:
https://explorer.testnet.near.org/transactions/D1rRpZx5AcYWzC91Jdt69qF1iqai7knUAtvdvqNA2bv
Demonstration of the command in interactive mode
use-manually-provided-public-key - Use the provided public key manually

This command adds a pre-known public access key to the account. In order to execute this command, in the terminal command line type:

near account \
    create-account sponsor-by-faucet-service test_fro2.testnet \
    use-manually-provided-public-key ed25519:HVPgAsZkZ7cwLZDqK313XJsDyqAvgBxrATcD7VacA8KE \
    network-config testnet \
    create
The result of this command will be as follows:
New account <test_fro2.testnet> created successfully.
Transaction ID: E7rKjJiYg1BwXa6e7xMueDS8NUNjqZSN5zDRpB5sARTi
To see the transaction in the transaction explorer, please open this url in your browser:
https://explorer.testnet.near.org/transactions/E7rKjJiYg1BwXa6e7xMueDS8NUNjqZSN5zDRpB5sARTi
Demonstration of the command in interactive mode
use-ledger - Use a ledger

This command adds access keys to an account using a ledger. In order to execute this command, in the terminal command line type:

near account \
    create-account sponsor-by-faucet-service test_fro3.testnet \
    use-ledger \
    network-config testnet \
    create
The result of this command will be as follows:
New account <test_fro3.testnet> created successfully.
Transaction ID: BStBXVisyR5FUj3ZfCAeQ1ohfwTnx2vTbYaRPLTQ5Uek
To see the transaction in the transaction explorer, please open this url in your browser:
https://explorer.testnet.near.org/transactions/BStBXVisyR5FUj3ZfCAeQ1ohfwTnx2vTbYaRPLTQ5Uek
Demonstration of the command in interactive mode

fund-myself - I would like fund myself to cover the cost of creating an account

With this command, you can create both a sub account and a "short name" account. Access keys to the created account can be added in several ways:

autogenerate-new-keypair - Automatically generate a key pair

In order to create a sub-account, in the terminal command line type:

near account \
    create-account fund-myself new.fro_volod.testnet '1 NEAR' \
    autogenerate-new-keypair \
    save-to-keychain \
    sign-as \
    network-config testnet \
    sign-with-keychain \
    send
The result of this command will be as follows:
Transaction sent ...
New account <new.fro_volod.testnet> created successfully.
Transaction ID: DRT3EpCK9iT5APyGgfcgSoLPCLCYYKtnrVgDhGLDEZFo
To see the transaction in the transaction explorer, please open this url in your browser:
https://explorer.testnet.near.org/transactions/DRT3EpCK9iT5APyGgfcgSoLPCLCYYKtnrVgDhGLDEZFo

The data for the access key is saved in a file /Users/frovolod/.near-credentials/testnet/new.fro_volod.testnet/ed25519_3ngtirechhepHKrzfkdgqqtwqSMtdbSLR6N1c4ivnzu6.json
The data for the access key is saved in a file "/Users/frovolod/.near-credentials/testnet/new.fro_volod.testnet.json"
Demonstration of the command in interactive mode

In order to create a "short name" account, in the terminal command line type:

near account \
    create-account fund-myself new7.testnet '0.1 NEAR' \
    autogenerate-new-keypair \
    save-to-keychain \
    sign-as fro_volod.testnet \
    network-config testnet \
    sign-with-keychain \
    send
The result of this command will be as follows:
Transaction sent ...
New account <new7.testnet> created successfully.
Transaction ID: GxZRjmYxZyo6X6Mn1kfuRJhfUnxsUVCiHZAZKqrLtR27
To see the transaction in the transaction explorer, please open this url in your browser:
https://explorer.testnet.near.org/transactions/GxZRjmYxZyo6X6Mn1kfuRJhfUnxsUVCiHZAZKqrLtR27

The data for the access key is saved in a file "/Users/frovolod/.near-credentials/testnet/new7.testnet/ed25519_EX1qK1S1T4WxXJFLH7qZvKxnGQtcKfEEsiA4BNxAZ6mP.json"
The file: /Users/frovolod/.near-credentials/testnet/new7.testnet.json already exists! Therefore it was not overwritten.
Demonstration of the command in interactive mode
use-manually-provided-seed-prase - Use the provided seed phrase manually

This command adds a previously known mnemonic phrase to the account. In order to execute this command, in the terminal command line type:

near account \
    create-account fund-myself seed.volodymyr.testnet '0.1 NEAR' \
    use-manually-provided-seed-phrase 'start vote foot cereal link cabin fantasy universe hero drama bird fiction' \
    sign-as volodymyr.testnet \
    network-config testnet \
    sign-with-keychain \
    send
The result of this command will be as follows:
Transaction sent ...
New account <seed.volodymyr.testnet> created successfully.
Transaction ID: 31iA2SsxtrRzb3fD5KtsFTZni8yUi2iZboNQih9bZuDt
To see the transaction in the transaction explorer, please open this url in your browser:
https://explorer.testnet.near.org/transactions/31iA2SsxtrRzb3fD5KtsFTZni8yUi2iZboNQih9bZuDt
Demonstration of the command in interactive mode
use-manually-provided-public-key - Use the provided public key manually

This command adds a pre-known public access key to the account. In order to execute this command, in the terminal command line type:

near account \
    create-account fund-myself pk.volodymyr.testnet '0.1 NEAR' \
    use-manually-provided-public-key ed25519:6jm8hWUgwoEeGmpdEyk9zrCqtXM8kHhvg8M236ZaGusS \
    sign-as volodymyr.testnet \
    network-config testnet \
    sign-with-keychain \
    send
The result of this command will be as follows:
Transaction sent ...
New account <pk.volodymyr.testnet> created successfully.
Transaction ID: CAVAR7jx2ofnbjxFFL2JVNbLsGNWF2q2tqMEtHxXmRLi
To see the transaction in the transaction explorer, please open this url in your browser:
https://explorer.testnet.near.org/transactions/CAVAR7jx2ofnbjxFFL2JVNbLsGNWF2q2tqMEtHxXmRLi
Demonstration of the command in interactive mode
use-ledger - Use a ledger

This command adds access keys to an account using a ledger. In order to execute this command, in the terminal command line type:

near account \
    create-account fund-myself ledger1.volodymyr.testnet '0.1 NEAR' \
    use-ledger \
    sign-as volodymyr.testnet \
    network-config testnet \
    sign-with-keychain \
    send
The result of this command will be as follows:
Transaction sent ...
New account <ledger1.volodymyr.testnet> created successfully.
Transaction ID: BKJp3QdaLtnXA8xwfqyk6JfrDsDxbxqADVyuNzQmKGNL
To see the transaction in the transaction explorer, please open this url in your browser:
https://explorer.testnet.near.org/transactions/BKJp3QdaLtnXA8xwfqyk6JfrDsDxbxqADVyuNzQmKGNL
Demonstration of the command in interactive mode

fund-later - Create an implicit-account

use-auto-generation - Use auto-generation to create an implicit account

This command automatically generates access keys and saves them to a file named implicit-account-id. In order to execute this command, in the terminal command line type:

near account \
    create-account \
    fund-later \
    use-auto-generation \
    save-to-folder /Users/frovolod/.near-credentials/implicit
The result of this command will be as follows:
The file "/Users/frovolod/.near-credentials/implicit/1573066d3fa7a2d56357aa5ddbc84295d94c61590390000981f5900b04e2f55f.json" was saved successfully
Demonstration of the command in interactive mode
use-ledger - Use ledger to create an implicit account

This command generates access keys using the ledger and saves them in a file named implicit-account-id. In order to execute this command, in the terminal command line type:

near account \
    create-account \
    fund-later \
    use-ledger \
    save-to-folder /Users/frovolod/.near-credentials/implicit/ledger
The result of this command will be as follows:
The file "/Users/frovolod/.near-credentials/implicit/ledger/739c872c3057cd5d812c49345248b9fdd318c8ad33ace6cf0468109eae972c8e.json" was saved successfully
Demonstration of the command in interactive mode
use-seed-phrase - Use seed phrase to create an implicit account

This command generates access keys using a mnemonic phrase and saves them in a file named implicit-account-id. In order to execute this command, in the terminal command line type:

near account \
    create-account \
    fund-later \
    use-seed-phrase 'start vote foot cereal link cabin fantasy universe hero drama bird fiction' \
        --seed-phrase-hd-path 'm/44'\''/397'\''/0'\''' \
    save-to-folder /Users/frovolod/.near-credentials/implicit
The result of this command will be as follows:
The file "/Users/frovolod/.near-credentials/implicit/eca9e1a6e0fa9a6af6d046bcffa6508f90f98e646836647ecd883d1d2b1989e5.json" was saved successfully
Demonstration of the command in interactive mode

update-social-profile - Update NEAR Social profile

json-args - Valid JSON arguments (e.g. {"token_id": "42"})

To update the contract account profile using JSON arguments, enter the following at the terminal command line:

near account \
    update-social-profile fro_volod.testnet \
    json-args '{"name":"frovolod","image":{"ipfs_cid":"bafkreifdzusz6hp3j4njdtqqxr3tlvx4agedgh7znyac4wbuiao3gtppde"},"linktree":{"github":"FroVolod","telegram":"frovolod"},"tags": {"rust":"","near":"","developer":""}}' \
    sign-as fro_volod.testnet \
    network-config testnet \
    sign-with-keychain \
    send
The result of this command will be as follows:
Profile for fro_volod.testnet updated successfully
Demonstration of the command in interactive mode
file-args - Read from file (e.g. reusable JSON or binary data)

To update the account profile on the contract using the prepared file, you must enter in the terminal command line:

near account \
    update-social-profile fro_volod.testnet \
    file-args profile.txt \
    sign-as fro_volod.testnet \
    network-config testnet \
    sign-with-keychain \
    send
The result of this command will be as follows:
Profile for fro_volod.testnet updated successfully
Demonstration of the command in interactive mode
manually - Interactive input of arguments

To update the account profile on the contract in interactive mode, you must use the prompts of the dialog or enter in the terminal command line:

near account \
    update-social-profile fro_volod.testnet \
    manually \
        --name fro_volod.testnet \
        --image-ipfs-cid bafkreifdzusz6hp3j4njdtqqxr3tlvx4agedgh7znyac4wbuiao3gtppde \
        --description 'This is my profile' \
        --github FroVolod \
        --website https://example.com/ \
        --tags dev,rust \
    sign-as fro_volod.testnet \
    network-config testnet \
    sign-with-keychain \
    send
The result of this command will be as follows:
Profile for fro_volod.testnet updated successfully
Demonstration of the command in interactive mode

delete-account - Delete an account

This command is designed to delete the current account. It is important to remember that all tokens of the deleted account will be transferred to the "beneficiary" account. In order to execute this command, in the terminal command line type:

near account \
    delete-account 2.fro_volod.testnet \
    beneficiary volodymyr.testnet \
    network-config testnet \
    sign-with-keychain \
    send
The result of this command will be as follows:
Transaction sent ...
Successful transaction
Account <2.fro_volod.testnet> has been successfully deleted.
Transaction ID: EHvB47npN8Z46qhsrw5XpKmD3n3jDn4MGiD85YSqw7cy
To see the transaction in the transaction explorer, please open this url in your browser:
https://explorer.testnet.near.org/transactions/EHvB47npN8Z46qhsrw5XpKmD3n3jDn4MGiD85YSqw7cy
Demonstration of the command in interactive mode

list-keys - View a list of access keys of an account

Viewing account access keys is possible at the current time (now) and at a certain point in the past by specifying a block (at-block-height or at-block-hash). Examples of the use of these parameters are discussed in the (View properties for an account).

To view the list of access keys, type the following in the terminal command line:

near account \
    list-keys fro_volod.testnet \
    network-config testnet \
    now
The result of this command will be as follows:
Number of access keys: 14
   1. ed25519:2QFAeUutKUDpmgKDyHXm7Wcz1uhjxk92fK6zY2dB7FCD (nonce: 97492076000000) is granted to only do [] function calls on v2.ref-farming.testnet with an allowance of 0.25 NEAR
   2. ed25519:3p1HbrTDYxY4q3V6QznW14qkuv3Bq1phFpCTsbrJpbEC (nonce: 94363284000000) is granted to full access
   3. ed25519:5UJE4PzyxECS42hBZSD1QQCLdq5j39vCtzshFPbnGdm1 (nonce: 73069087000002) is granted to full access
   4. ed25519:6YU78BezKwQNrz5vmtkSCALtx7cPDC1JBs9DhjeSJ39X (nonce: 97490513000000) is granted to only do [] function calls on v2.ref-farming.testnet with an allowance of 0.25 NEAR
   5. ed25519:7YCfA1KrToJtAYGTBgAMe4LWfQEi4iwLGcH2q5SvGKzD (nonce: 94982716000000) is granted to only do [] function calls on mintspace2.testnet with an allowance of 0.25 NEAR
   6. ed25519:95w5YFsJ3iktzDwRBWUGqLF6Gv5CoJuVifBjcEEdJs8s (nonce: 72253433000003) is granted to full access
   7. ed25519:9nyDySTNAGPywxC9pG4DPdnF3eEVexDgrfzZYsoahPsV (nonce: 76057805000000) is granted to full access
   8. ed25519:AEC4szaeNzT8PQAifsnisdivq4mwswJbBM65DdkT6kdS (nonce: 72263674000000) is granted to full access
   9. ed25519:D31un5TFeABdNUVMaf3QzeBz3Z3yau2GZA2VPe8XX6GB (nonce: 72325441000021) is granted to full access
  10. ed25519:DZz4r5oLSBVcLuqFzSoLUEJ3Qv67cpgGbsRHy8SvbGiU (nonce: 72253481000000) is granted to full access
  11. ed25519:DyKmdLkWMqC1HFs6t6PfNhVemjQE16W2RNofWPpW5ZZh (nonce: 72325378000007) is granted to full access
  12. ed25519:EWoYxHNZHtApUfu1nTGC49XHW5dNinoDKABcauHnjevZ (nonce: 73069042000001) is granted to full access
  13. ed25519:EYtsL67TpgfpE1udnga2m41vDoBqeZ2DB32onhsxsVUb (nonce: 72251760000002) is granted to full access
  14. ed25519:G2U7aZ91pgG3TS96gCWov5L1DkNWSi3756RRkwuspZ4L (nonce: 72251684000002) is granted to full access
Demonstration of the command in interactive mode

add-key - Add an access key to an account

Let's execute the command to add a new pair of access keys to the account with the following conditions:

  • the public key will be entered manually
  • keys will have full access
  • the transaction will be signed automatically (if there is a file with access keys) In order to execute this command, in the terminal command line type:
near account \
    add-key fro_volod.testnet \
    grant-full-access \
    use-manually-provided-public-key ed25519:75a5ZgVZ9DFTxs4THtFxPtLj7AY3YzpxtapTQBdcMXx3 \
    network-config testnet \
    sign-with-keychain \
    send
The result of this command will be as follows:
Transaction sent ...
Successful transaction
Added access key = ed25519:75a5ZgVZ9DFTxs4THtFxPtLj7AY3YzpxtapTQBdcMXx3 to fro_volod.testnet.
Transaction ID: 2oVDKopcWphN3qrUoq7XjFMpRuCUjz6jSU327q8trAQ5
To see the transaction in the transaction explorer, please open this url in your browser:
https://explorer.testnet.near.org/transactions/2oVDKopcWphN3qrUoq7XjFMpRuCUjz6jSU327q8trAQ5
Demonstration of the command in interactive mode

Let's change our parameters to add access keys:

  • keys will be generated automatically
  • keys will have functional access
  • the transaction will be signed with key pair In order to execute this command, in the terminal command line type:
near account \
    add-key fro_volod.testnet \
    grant-function-call-access \
        --allowance '1 NEAR' \
        --receiver-account-id 'meta.pool.testnet' \
        --method-names 'set_a, set_b' \
    autogenerate-new-keypair \
    save-to-keychain \
    network-config testnet \
    sign-with-plaintext-private-key \
        --signer-public-key ed25519:D31un5TFeABdNUVMaf3QzeBz3Z3yau2GZA2VPe8XX6GB \
        --signer-private-key  ed25519:3UVo1GAatRz12iX3CRuKAuK3MPLDD9bPf4LXJD5DkHs13er3UeJLW7aRPAVsFQ2FjopUw6DEApEngac8FPtnnkYB \
    send
The result of this command will be as follows:
Transaction sent ...
Successful transaction
Added access key = ed25519:27R66L6yevyHbsk4fESZDC8QUQBwCdx6vvkk1uQmG7NY to fro_volod.testnet.
Transaction ID: DaJySrNtSUZU7KPyvfUMbh6xYi9vZeMvnj4Umo7ZzdB3
To see the transaction in the transaction explorer, please open this url in your browser:
https://explorer.testnet.near.org/transactions/DaJySrNtSUZU7KPyvfUMbh6xYi9vZeMvnj4Umo7ZzdB3
Demonstration of the command in interactive mode

delete-key - Delete an access key from an account

In order to remove access keys, in the terminal command line type:

near account \
    delete-key fro_volod.testnet \
    ed25519:75a5ZgVZ9DFTxs4THtFxPtLj7AY3YzpxtapTQBdcMXx3 \
    network-config testnet \
    sign-with-keychain \
    send
The result of this command will be as follows:
Transaction sent ...
Successful transaction
Access key <ed25519:75a5ZgVZ9DFTxs4THtFxPtLj7AY3YzpxtapTQBdcMXx3> for account <fro_volod.testnet> has been successfully deleted.
Transaction ID: 6S7bJ76QNFypUvP7PCB1hkLM7X5GxPxP2gn4rnDHMzPz
To see the transaction in the transaction explorer, please open this url in your browser:
https://explorer.testnet.near.org/transactions/6S7bJ76QNFypUvP7PCB1hkLM7X5GxPxP2gn4rnDHMzPz
Demonstration of the command in interactive mode

manage-storage-deposit - Storage management: deposit, withdrawal, balance review

view-balance - View storage balance for an account

To view the account balance on the contract on the last block, you must enter in the terminal command line:

near account \
    manage-storage-deposit v1.social08.testnet \
    view-balance volodymyr.testnet \
    network-config testnet \
    now
The result of this command will be as follows:
storage balance for <volodymyr.testnet>:
 available:        1.6 MB   (15.878059999854543210876557 NEAR [  15878059999854543210876557 yoctoNEAR])
 total:            1.6 MB   (16.238949999854543210876557 NEAR [  16238949999854543210876557 yoctoNEAR])
Demonstration of the command in interactive mode
deposit - Make a storage deposit for the account

To add a deposit to the account balance under the contract, you must enter in the terminal command line:

near account \
    manage-storage-deposit v1.social08.testnet \
    deposit volodymyr.testnet '1 NEAR' \
    sign-as fro_volod.testnet \
    network-config testnet \
    sign-with-macos-keychain \
    send
The result of this command will be as follows:
<fro_volod.testnet> has successfully added a deposit of 1 NEAR to <volodymyr.testnet> on contract <v1.social08.testnet>.
Demonstration of the command in interactive mode
withdraw - Withdraw a deposit from storage for an account ID

To withdraw funds from the account balance under the contract, you must enter in the terminal command line:

near account \
    manage-storage-deposit v1.social08.testnet \
    withdraw '0.5 NEAR' \
    sign-as volodymyr.testnet \
    network-config testnet \
    sign-with-keychain \
    send
The result of this command will be as follows:
<volodymyr.testnet> has successfully withdraw 0.5 NEAR from <v1.social08.testnet>.
Demonstration of the command in interactive mode

tokens - Manage token assets such as NEAR, FT, NFT

send-near - The transfer is carried out in NEAR tokens

This command is used to transfer tokens between accounts. Please note that the amount of tokens forwarded is indicated together with the dimensional unit (this is NEAR or yoctoNEAR). In order to execute this command, in the terminal command line type:

near tokens \
    fro_volod.testnet \
    send-near volodymyr.testnet 0.1NEAR \
    network-config testnet \
    sign-with-keychain \
    send
The result of this command will be as follows:
Transaction sent ...
Successful transaction
<fro_volod.testnet> has transferred 0.1 NEAR to <volodymyr.testnet> successfully.
Transaction ID: 8BbB674VDxeg36egMzdHFsCUExpkLWAWeYqEfd9u9ZaD
To see the transaction in the transaction explorer, please open this url in your browser:
https://explorer.testnet.near.org/transactions/8BbB674VDxeg36egMzdHFsCUExpkLWAWeYqEfd9u9ZaD
Demonstration of the command in interactive mode

send-ft - The transfer is carried out in FT tokens

This command is used to transfer FT tokens between accounts. Please note that the amount of tokens forwarded is indicated together in dimensionless units. In order to execute this command, in the terminal command line type:

near tokens \
    fro_volod.testnet \
    send-ft usdn.testnet volodymyr.testnet 10000000000000000000 \
        --prepaid-gas 100.000TeraGas \
        --attached-deposit 1yoctoNEAR \
    network-config testnet \
    sign-with-keychain \
    send
The result of this command will be as follows:
Transaction sent ...
Successful transaction
The "ft_transfer" call to <usdn.testnet> on behalf of <fro_volod.testnet> succeeded.
Transaction ID: 5a7YmANdpimiqUm6WC6n4dd91b6A9PafNNhad8HWKugN
To see the transaction in the transaction explorer, please open this url in your browser:
https://explorer.testnet.near.org/transactions/5a7YmANdpimiqUm6WC6n4dd91b6A9PafNNhad8HWKugN
Demonstration of the command in interactive mode

send-nft - The transfer is carried out in NFT tokens

This command is used to transfer NFT tokens between accounts. In order to execute this command, in the terminal command line type:

near tokens \
    fro_volod.testnet \
    send-nft paras-token-v2.testnet volodymyr.testnet 1604:4 \
        --prepaid-gas 100.000TeraGas \
        --attached-deposit 1yoctoNEAR \
    network-config testnet \
    sign-with-keychain \
    send
The result of this command will be as follows:
Transaction sent ...
Successful transaction
The "nft_transfer" call to <paras-token-v2.testnet> on behalf of <fro_volod.testnet> succeeded.
Transaction ID: 9q2VbakZbj5ja6GAFXpFnbtbYHijEHyT7Ry34GQ6cvLB
To see the transaction in the transaction explorer, please open this url in your browser:
https://explorer.testnet.near.org/transactions/9q2VbakZbj5ja6GAFXpFnbtbYHijEHyT7Ry34GQ6cvLB
Demonstration of the command in interactive mode

view-near-balance - View the balance of Near tokens

Viewing the account balance is possible at the current time (now) and at a certain moment in the past by specifying the block (at-block-height or at-block-hash). Examples of the use of these parameters are discussed in the (View properties for an account).

To view the amount in NEAR tokens on the account, type the following in the terminal command line:

near tokens \
    fro_volod.testnet \
    view-near-balance \
    network-config testnet \
    now
The result of this command will be as follows:
fro_volod.testnet account has 169.589001320890476999999994 NEAR available for transfer (the total balance is 172.482461320890476999999994 NEAR, but 2.89246 NEAR is locked for storage and the transfer transaction fee is ~0.001 NEAR)
Demonstration of the command in interactive mode

view-ft-balance - View the balance of FT tokens

Viewing the account balance is possible at the current time (now) and at a certain moment in the past by specifying the block (at-block-height or at-block-hash). Examples of the use of these parameters are discussed in the (View properties for an account).

To view funds in FT tokens on the account, type the following in the terminal command line:

near tokens \
    fro_volod.testnet \
    view-ft-balance usdn.testnet \
    network-config testnet \
    now
The result of this command will be as follows:
fro_volod.testnet account has "31942967677775774595" FT tokens (FT-contract: usdn.testnet)
Demonstration of the command in interactive mode

view-nft-assets - View the balance of NFT tokens

Viewing the account balance is possible at the current time (now) and at a certain moment in the past by specifying the block (at-block-height or at-block-hash). Examples of the use of these parameters are discussed in the (View properties for an account).

To view funds in NFT tokens on the account, type the following in the terminal command line:

near tokens \
    fro_volod.testnet \
    view-nft-assets paras-token-v2.testnet \
    network-config testnet \
    now
The result of this command will be as follows:
fro_volod.testnet account has NFT tokens:
[
  {
    "approved_account_ids": {},
    "metadata": {
      "copies": 100,
      "description": null,
      "expires_at": null,
      "extra": null,
      "issued_at": "1657613801537412611",
      "media": "bafybeib65t37t2tagukok4m7f5rldfirzb5ykvdq3yqbwnbcrtllpggg6u",
      "media_hash": null,
      "reference": "bafkreidmbv4j2qylxc2mngsup7cxakw7gwyd7lu2zycznrdtqw4kc52cwu",
      "reference_hash": null,
      "starts_at": null,
      "title": "Apollo42 #01 #4",
      "updated_at": null
    },
    "owner_id": "fro_volod.testnet",
    "token_id": "1604:4"
  }
]
Demonstration of the command in interactive mode

staking - Manage staking: view, deposit, and withdraw delegated stake

validator-list - View the list of validators to delegate

To view a list of validators, enter at the terminal command line:

near staking \
    validator-list \
    network-config mainnet
The result of this command will be as follows:
+-----+----------------------------------------------+----------+------------+----------------------------------------+
| #   | Validator Id                                 | Fee      | Delegators | Stake                                  |
+-----+----------------------------------------------+----------+------------+----------------------------------------+
| 1   | staked.poolv1.near                           |     10 % |     3207   | 44135674.18356215181482959363448 NEAR  |
| 2   | figment.poolv1.near                          |     10 % |     1911   | 43158696.364374348313201031661037 NEAR |
| 3   | astro-stakers.poolv1.near                    |      1 % |    11528   | 26760042.204197815051321354819805 NEAR |
| 4   | bzam6yjpnfnxsdmjf6pw.poolv1.near             |    100 % |      772   | 23347900.996610021010359525969384 NEAR |
| 5   | zavodil.poolv1.near                          |      1 % |     7116   | 20700903.223980192761611953425855 NEAR |
| 6   | binancenode1.poolv1.near                     |      5 % |     1250   | 14209385.916611355199355410152982 NEAR |
| 7   | staking_yes_protocol1.poolv1.near            |    100 % |       65   | 13590245.381034035922399111793022 NEAR |
| 8   | pinnacle1.poolv1.near                        |    100 % |        4   | 13509874.537453205747773186007329 NEAR |
| 9   | priory.poolv1.near                           |    100 % |       15   | 12727257.514716521676379711750814 NEAR |
| 10  | stake1.poolv1.near                           |      3 % |      754   | 12449700.095021989100340879377004 NEAR |
| 11  | mockingbird.poolv1.near                      |    100 % |       28   | 11501759.018634341466180769487983 NEAR |
| 12  | dqw9k3e4422cxt92masmy.poolv1.near            |    100 % |       36   | 11122519.385245577197951932017032 NEAR |
| 13  | flipside.pool.near                           |    100 % |        9   | 11087540.718366137730589600283212 NEAR |
| 14  | sweat_validator.poolv1.near                  |    100 % |      112   | 10900424.272450229667472212076621 NEAR |
| 15  | epic.poolv1.near                             |      1 % |     5363   | 10769900.629411406438519703653828 NEAR |
| 16  | future_is_near.poolv1.near                   |      9 % |      355   | 10243082.132364573976720438585765 NEAR |
| 17  | cosmose.poolv1.near                          |    100 % |       10   | 10064982.806109296980776431396738 NEAR |
| 18  | aurora.pool.near                             |     99 % |     3301   | 9298278.181302142009939675438401 NEAR  |
...
Demonstration of the command in interactive mode

delegation - Stake delegation management

view-balance - View the delegated stake balance for a given account

To view the delegated stake account balance on a validator staking pool, enter at the terminal command line:

near staking \
    delegation volodymyr.testnet \
    view-balance aurora.pool.f863973.m0 \
    network-config testnet \
    now
The result of this command will be as follows:
Delegated stake balance with validator <aurora.pool.f863973.m0> by <volodymyr.testnet>:
      Staked balance:           38.021465232511349340052266 NEAR
      Unstaked balance:          0.000000000000000000000001 NEAR
      Total balance:            38.021465232511349340052267 NEAR
Demonstration of the command in interactive mode
deposit-and-stake - Delegate NEAR tokens to a validator's staking pool

To delegate your NEAR tokens to a staking pool to support a validator and gain staking rewards, deposit NEAR tokens and stake with a selected staking pool, you may use the following command (note that you need to use your own account id, adjust the amount of NEAR tokens to deposit and stake, and choose the staking pool account id):

near staking \
    delegation volodymyr.testnet \
    deposit-and-stake '15 NEAR' aurora.pool.f863973.m0 \
    network-config testnet \
    sign-with-legacy-keychain \
    send
The result of this command will be as follows:
<volodymyr.testnet> has successfully delegated 15 NEAR to stake with <aurora.pool.f863973.m0>.
Demonstration of the command in interactive mode
stake - Delegate a certain amount of previously deposited or unstaked NEAR tokens to a validator's staking pool

To delegate your NEAR tokens to a staking pool to support a validator and gain staking rewards, stake deposited NEAR tokens with a selected staking pool. You may use the following command (note that you need to use your own account id, adjust the amount of NEAR tokens to stake, choose the staking pool account id, and use the appropriate network):

near staking \
    delegation volodymyr.testnet \
    stake '5 NEAR' aurora.pool.f863973.m0 \
    network-config testnet \
    sign-with-legacy-keychain \
    send
The result of this command will be as follows:
<volodymyr.testnet> has successfully delegated 5 NEAR to stake with <aurora.pool.f863973.m0>.
Demonstration of the command in interactive mode
stake-all - Delegate all previously deposited or unstaked NEAR tokens to a validator's staking pool

To delegate your NEAR tokens to a staking pool to support a validator and gain staking rewards, stake all previously deposited or unstaked NEAR tokens with a selected staking pool. You may use the following command (note that you need to use your own account id, and choose the staking pool account id):

near staking \
    delegation volodymyr.testnet \
    stake-all aurora.pool.f863973.m0 \
    network-config testnet \
    sign-with-legacy-keychain \
    send
The result of this command will be as follows:
<volodymyr.testnet> has successfully delegated all previously unstaked NEAR tokens to stake with <aurora.pool.f863973.m0>.
Demonstration of the command in interactive mode
unstake - Unstake a certain amount of delegated NEAR tokens from a avalidator's staking pool

To unstake your delegated NEAR tokens from a staking pool, you can use the following command (note that you need to use your own account id, adjust the amount of NEAR tokens to unstake, and choose the staking pool account id):

near staking \
    delegation volodymyr.testnet \
    unstake '7 NEAR' aurora.pool.f863973.m0 \
    network-config testnet \
    sign-with-legacy-keychain \
    send
The result of this command will be as follows:
<volodymyr.testnet> has successfully unstaked 7 NEAR from <aurora.pool.f863973.m0>.
Demonstration of the command in interactive mode
unstake-all - Unstake all delegated NEAR tokens from a avalidator's staking pool

To unstake your delegated NEAR tokens from a staking pool, you can use the following command (note that you need to use your own account id, and choose the staking pool account id):

near staking \
    delegation volodymyr.testnet \
    unstake-all aurora.pool.f863973.m0 \
    network-config testnet \
    sign-with-legacy-keychain \
    send
The result of this command will be as follows:
<volodymyr.testnet> has successfully unstaked the entire amount from <aurora.pool.f863973.m0>.
Demonstration of the command in interactive mode
withdraw - Withdraw a certain amount of unstaked NEAR tokens from a avalidator's staking pool

To withdraw your delegated NEAR tokens from a staking pool after you unstaked and waited for 4 epochs, you can use the following command (note that you need to use your own account id, adjust the amount of NEAR tokens to withdraw, and choose the staking pool account id):

near staking \
    delegation volodymyr.testnet \
    withdraw '3 NEAR' aurora.pool.f863973.m0 \
    network-config testnet \
    sign-with-legacy-keychain \
    send
The result of this command will be as follows:
<volodymyr.testnet> has successfully withdrawn 3 NEAR from <aurora.pool.f863973.m0>.
Demonstration of the command in interactive mode
withdraw-all - Withdraw all unstaked NEAR tokens from a avalidator's staking pool

To withdraw all your delegated NEAR tokens from a staking pool after you unstaked them and waited for 4 epochs, you can use the following command (note that you need to use your own account id, and choose the staking pool account id):

near staking \
    delegation volodymyr.testnet \
    withdraw-all aurora.pool.f863973.m0 \
    network-config testnet \
    sign-with-legacy-keychain \
    send
The result of this command will be as follows:
<volodymyr.testnet> has successfully withdrawn the entire amount from <aurora.pool.f863973.m0>.
Demonstration of the command in interactive mode

contract - Manage smart-contracts: deploy code, call functions

call-function - Execute function (contract method)

as-read-only - Calling a view method

Viewing data is possible at the current time (now) and at a certain point in the past by specifying a block (at-block-height or at-block-hash). Examples of the use of these parameters are discussed in the (View properties for an account).

To run this command, type the following in the terminal command line:

near contract \
    call-function \
    as-read-only zavodil.poolv1.near get_accounts \
    json-args '{"from_index": 0, "limit": 3}' \
    network-config mainnet \
    now
The result of this command will be as follows:
[
  {
    "account_id": "zavodil.near",
    "can_withdraw": false,
    "staked_balance": "107480661091559500516766891",
    "unstaked_balance": "1307739180247557404925470405"
  },
  {
    "account_id": "gagdiez.near",
    "can_withdraw": true,
    "staked_balance": "4387193990112136827894210960",
    "unstaked_balance": "1"
  },
  {
    "account_id": "gibby49.near",
    "can_withdraw": true,
    "staked_balance": "1105950300133283278041226",
    "unstaked_balance": "1"
  }
]
Demonstration of the command in interactive mode
as-transaction - Calling a change method

To run this command, type the following in the terminal command line:

near contract \
    call-function \
    as-transaction turbo.volodymyr.testnet rate \
    json-args '{"other_user":"volodymyr.testnet", "vote":5}' \
    prepaid-gas '3 Tgas' \
    attached-deposit '1 NEAR' \
    sign-as fro_volod.testnet \
    network-config testnet \
    sign-with-keychain \
    send
The result of this command will be as follows:
Transaction sent ...
Successful transaction
The "rate" call to <turbo.volodymyr.testnet> on behalf of <fro_volod.testnet> succeeded.
Transaction ID: 7RuoSAdCctSEw63GKsfQJg1YXRzH3msUCo4oygzauPko
To see the transaction in the transaction explorer, please open this url in your browser:
https://explorer.testnet.near.org/transactions/7RuoSAdCctSEw63GKsfQJg1YXRzH3msUCo4oygzauPko
Demonstration of the command in interactive mode

deploy - Add a new contract code

In order to add a new contract, in the terminal command line type:

near contract \
    deploy \
    262.volodymyr.testnet \
    use-file /Users/frovolod/Documents/NEAR/rust-counter/contract/target/wasm32-unknown-unknown/release/rust_counter_tutorial.wasm \
    with-init-call increment \
    json-args {} \
    prepaid-gas '1 TGas' \
    attached-deposit '0 NEAR' \
    network-config testnet \
    sign-with-keychain \
    send
The result of this command will be as follows:
Transaction sent ...
Successful transaction
Contract code has been successfully deployed.
The "increment" call to <262.volodymyr.testnet> on behalf of <262.volodymyr.testnet> succeeded.
Transaction ID: 4YGGhF88aevNGpF5uaXNGHfQprHRqkia7eTpyxegJVms
To see the transaction in the transaction explorer, please open this url in your browser:
https://explorer.testnet.near.org/transactions/4YGGhF88aevNGpF5uaXNGHfQprHRqkia7eTpyxegJVms
Demonstration of the command in interactive mode

download-wasm - Download wasm

You can download the contract file for the current moment (now) and for a certain moment in the past by specifying the block (at-block-height or at-block-hash). Examples of the use of these parameters are discussed in the (View properties for an account).

In order to get the contract file, type the following in the terminal command line:

near contract \
    download-wasm 262.volodymyr.testnet \
    to-folder /Users/frovolod/Downloads \
    network-config testnet \
    now
The result of this command will be as follows: ```txt The file "/Users/frovolod/Downloads/contract_262_volodymyr_testnet.wasm" was downloaded successfully ```
Demonstration of the command in interactive mode

view-storage - View contract storage state

You can view the contract key values at the current moment in time (now) and at a certain point in the past by specifying a block (at-block-height or at-block-hash). Examples of the use of these parameters are discussed in the (View properties for an account). The keys themselves can be viewed all (all) or filtered using keys-start-with-string or keys-start-with-bytes-as-base64.

To view contract keys, enter at the terminal command line:

near contract \
    view-storage turbo.volodymyr.testnet \
    all \
    as-json \
    network-config testnet \
    now
The result of this command will be as follows: ```txt Contract state (values): [ { "key": "MjF2b2xvZHlteXIudGVzdG5ldA==", "value": "JwAAAAAAAAAIAAAAAAAAAA==" }, { "key": "U1RBVEU=", "value": "" }, { "key": "ZnJvX3ZvbG9kLnRlc3RuZXQ=", "value": "HQAAAAAAAAAGAAAAAAAAAA==" }, { "key": "dm9sb2R5bXlyLnRlc3RuZXQ=", "value": "QAEAAAAAAABAAAAAAAAAAA==" } ] Contract state (proof): [] ```
Demonstration of the command in interactive mode

transaction - Operate transactions

view-status - View a transaction status

To view the status of the desired transaction, type its hash in the terminal command line:

near transaction \
    view-status GDoinMecpvnqahzJz9tXLxYycznL4cAoxKTPEnJZ3ank \
    network-config testnet
The result of this command will be as follows:
Transaction status: FinalExecutionOutcomeWithReceiptView {
    final_outcome: FinalExecutionOutcome {
        status: SuccessValue(``),
        transaction: SignedTransactionView {
            signer_id: AccountId(
                "volodymyr.testnet",
            ),
            public_key: ed25519:7FmDRADa1v4BcLiiR9MPPdmWQp3Um1iPdAYATvBY1YzS,
            nonce: 165,
            receiver_id: AccountId(
                "qweqweqwe.volodymyr.testnet",
            ),
            actions: [
                CreateAccount,
                Transfer {
                    deposit: 100000000000000000000000000,
                },
                AddKey {
                    public_key: ed25519:AgVv8qjZ7yix3pTo7BimT1zoDYUSTGcg73RBssC5JMRf,
                    access_key: AccessKeyView {
                        nonce: 0,
                        permission: FullAccess,
                    },
                },
            ],
            signature: ed25519:266jBRjvnaxe4mDyHRGwv3TJesvgRo2umJBqkZU26fRwmhVHciu3tBSLqRZFjEuqLTiwDTrFvfxpJ8Sbd2PqHHhv,
            hash: `GDoinMecpvnqahzJz9tXLxYycznL4cAoxKTPEnJZ3ank`,
        },
        transaction_outcome: ExecutionOutcomeWithIdView {
            proof: [],
            block_hash: `AQH6jDqqxpBYj5NSZv3Skg5hUZQRsn16jvDuphCTugSQ`,
            id: `GDoinMecpvnqahzJz9tXLxYycznL4cAoxKTPEnJZ3ank`,
            outcome: ExecutionOutcomeView {
                logs: [],
                receipt_ids: [
                    `5DmuFwQaiSbEDiR7dx6sDurjyDyF92c1tK7gfN7bXqPh`,
                ],
                gas_burnt: 424555062500,
                tokens_burnt: 42455506250000000000,
                executor_id: AccountId(
                    "volodymyr.testnet",
                ),
                status: SuccessReceiptId(5DmuFwQaiSbEDiR7dx6sDurjyDyF92c1tK7gfN7bXqPh),
                metadata: ExecutionMetadataView {
                    version: 1,
                    gas_profile: None,
                },
            },
        },
        receipts_outcome: [
            ExecutionOutcomeWithIdView {
                proof: [],
                block_hash: `DBUpiLVVDBQwSAPU8ZTE8KQnX5skDD1dTsBjJQ8kV24R`,
                id: `5DmuFwQaiSbEDiR7dx6sDurjyDyF92c1tK7gfN7bXqPh`,
                outcome: ExecutionOutcomeView {
                    logs: [],
                    receipt_ids: [
                        `851GMnZZ5FJ2aDSHM34N99yVb1ZkwY8n7F8rUcvuRpUU`,
                    ],
                    gas_burnt: 424555062500,
                    tokens_burnt: 42455506250000000000,
                    executor_id: AccountId(
                        "qweqweqwe.volodymyr.testnet",
                    ),
                    status: SuccessValue(``),
                    metadata: ExecutionMetadataView {
                        version: 1,
                        gas_profile: None,
                    },
                },
            },
            ExecutionOutcomeWithIdView {
                proof: [],
                block_hash: `BSjrH3WyKnXhD17drR94YfM725Ho59us9N4msXrrgHEw`,
                id: `851GMnZZ5FJ2aDSHM34N99yVb1ZkwY8n7F8rUcvuRpUU`,
                outcome: ExecutionOutcomeView {
                    logs: [],
                    receipt_ids: [],
                    gas_burnt: 0,
                    tokens_burnt: 0,
                    executor_id: AccountId(
                        "volodymyr.testnet",
                    ),
                    status: SuccessValue(``),
                    metadata: ExecutionMetadataView {
                        version: 1,
                        gas_profile: None,
                    },
                },
            },
        ],
    },
    receipts: [
        ReceiptView {
            predecessor_id: AccountId(
                "volodymyr.testnet",
            ),
            receiver_id: AccountId(
                "qweqweqwe.volodymyr.testnet",
            ),
            receipt_id: `5DmuFwQaiSbEDiR7dx6sDurjyDyF92c1tK7gfN7bXqPh`,
            receipt: Action {
                signer_id: AccountId(
                    "volodymyr.testnet",
                ),
                signer_public_key: ed25519:7FmDRADa1v4BcLiiR9MPPdmWQp3Um1iPdAYATvBY1YzS,
                gas_price: 103000000,
                output_data_receivers: [],
                input_data_ids: [],
                actions: [
                    CreateAccount,
                    Transfer {
                        deposit: 100000000000000000000000000,
                    },
                    AddKey {
                        public_key: ed25519:AgVv8qjZ7yix3pTo7BimT1zoDYUSTGcg73RBssC5JMRf,
                        access_key: AccessKeyView {
                            nonce: 0,
                            permission: FullAccess,
                        },
                    },
                ],
            },
        },
        ReceiptView {
            predecessor_id: AccountId(
                "system",
            ),
            receiver_id: AccountId(
                "volodymyr.testnet",
            ),
            receipt_id: `851GMnZZ5FJ2aDSHM34N99yVb1ZkwY8n7F8rUcvuRpUU`,
            receipt: Action {
                signer_id: AccountId(
                    "volodymyr.testnet",
                ),
                signer_public_key: ed25519:7FmDRADa1v4BcLiiR9MPPdmWQp3Um1iPdAYATvBY1YzS,
                gas_price: 0,
                output_data_receivers: [],
                input_data_ids: [],
                actions: [
                    Transfer {
                        deposit: 1273665187500000000,
                    },
                ],
            },
        },
    ],
}
Demonstration of the command in interactive mode

reconstruct-transaction - Use any existing transaction from the chain to construct NEAR CLI command (helpful tool for re-submitting similar transactions)

Let's consider an example when it is necessary to repeat a previously completed transaction:

near transaction \
    reconstruct-transaction GDoinMecpvnqahzJz9tXLxYycznL4cAoxKTPEnJZ3ank \
    network-config testnet
The result of this command will be as follows:
Transaction GDoinMecpvnqahzJz9tXLxYycznL4cAoxKTPEnJZ3ank:

signer_id:    volodymyr.testnet
receiver_id:  qweqweqwe.volodymyr.testnet
actions:
   -- create account:      qweqweqwe.volodymyr.testnet
   -- transfer deposit:    100 NEAR
   -- add access key:     
                   public key:   ed25519:AgVv8qjZ7yix3pTo7BimT1zoDYUSTGcg73RBssC5JMRf
                   nonce:        0
                   permission:   FullAccess

Here is your console command to run archive transaction. You can to edit it or re-run:
near transaction construct-transaction volodymyr.testnet qweqweqwe.volodymyr.testnet add-action create-account add-action transfer '100 NEAR' add-action add-key grant-full-access use-manually-provided-public-key ed25519:AgVv8qjZ7yix3pTo7BimT1zoDYUSTGcg73RBssC5JMRf skip network-config testnet
Demonstration of the command in interactive mode

construct-transaction - Construct a new transaction

Let's consider an example when it is necessary to perform several actions within one transaction:

  1. Create an account
  2. Add access keys to the created account
  3. Transfer tokens to the created account

To do this, we will use the transaction constructor:

Demonstration of the command in interactive mode

sign-transaction - Sign previously prepared unsigned transaction

Consider an example of using the ability to create a transaction in offline:

  1. Create a transaction.
  2. When choosing how to sign a transaction, select the sign later option and follow the instructions.
  3. The displayed transaction in base64 format can be used here to sign it and/or send it later.
Demonstration of the command in interactive mode

send-signed-transaction - Send a signed transaction

Let's look at the previous example, using the capabilities of sending a signed transaction:

  1. Create a transaction.
  2. Sign the transaction with your access keys.
  3. Display the transaction on the screen in base64 format.
  4. Send transaction.
Demonstration of the command in interactive mode

send-meta-transaction - Act as a relayer to send a signed delegate action (meta-transaction)

Consider an example of using metatransaction functions:

  1. Create a transaction.
  2. Specify a network that supports meta-transactions.
  3. Sign the transaction with your access keys.
  4. Display the transaction on the screen in base64 format and transfer it to the relay for sending.

Send signed delegated transaction:

Demonstration of the command in interactive mode

config - Manage connections in a configuration file

show-connections - Show a list of network connections

To view the data of the configuration file (config.toml), you can use the interactive mode or type in the terminal command line:

near config show-connections
The result of this command will be as follows:
credentials_home_dir = "/Users/frovolod/.near-credentials"
[network_connection.mainnet]
network_name = "mainnet"
rpc_url = "https://archival-rpc.mainnet.near.org/"
wallet_url = "https://wallet.near.org/"
explorer_transaction_url = "https://explorer.near.org/transactions/"
linkdrop_account_id = "near"

[network_connection.testnet]
network_name = "testnet"
rpc_url = "https://archival-rpc.testnet.near.org/"
wallet_url = "https://wallet.testnet.near.org/"
explorer_transaction_url = "https://explorer.testnet.near.org/transactions/"
linkdrop_account_id = "testnet"
faucet_url = "https://helper.nearprotocol.com/account"

[network_connection.pagoda-testnet]
network_name = "testnet"
rpc_url = "https://near-testnet.api.pagoda.co/rpc/v1/"
rpc_api_key = "c0a25b3c-39c2-4f62-a621-50e208b88e64"
wallet_url = "https://wallet.testnet.near.org/"
explorer_transaction_url = "https://explorer.testnet.near.org/transactions/"
linkdrop_account_id = "testnet"
faucet_url = "https://helper.nearprotocol.com/account"
meta_transaction_relayer_url = "https://near-testnet.api.pagoda.co/relay"

add-connection - Add a network connection

To add network details to the configuration file (config.toml), you can use interactive mode or type in the terminal command line:

near config \
    add-connection \
        --network-name testnet \
        --connection-name pagoda-testnet \
        --rpc-url https://near-testnet.api.pagoda.co/rpc/v1/ \
        --wallet-url https://wallet.testnet.near.org/ \
        --explorer-transaction-url https://explorer.testnet.near.org/transactions/ \
        --rpc-api-key 'c0a25b3c-39c2-4f62-a621-50e208b88e64' \
        --linkdrop-account-id testnet \
        --faucet-url https://helper.nearprotocol.com/account \
        --meta-transaction-relayer-url https://near-testnet.api.pagoda.co/relay
The result of this command will be as follows:
Configuration data is stored in a file "/Users/frovolod/Library/Application Support/near-cli/config.toml"
Network connection "pagoda-testnet" was successfully added to config.toml
Demonstration of the command in interactive mode

delete-connection - Delete a network connection

To remove the network from the configuration file (config.toml), you can use interactive mode or type in the terminal command line:

near config delete-connection pagoda-testnet
The result of this command will be as follows:
Configuration data is stored in a file "/Users/frovolod/Library/Application Support/near-cli/config.toml"
Network connection "pagoda-testnet" was successfully removed from config.toml