| name | near-cli-rs |
| description | Generate near-cli-rs v0.14+ commands for NEAR Protocol — account management, NEAR/FT/NFT token transfers, staking delegation, contract deployment and calls, transaction signing (keychain, Ledger, seed phrase, MPC, offline), and network config |
SKILL: near-cli-rs — NEAR Protocol CLI Reference for AI Agents
Purpose: This file is for LLMs generating non-interactive near commands. When a user request maps to a CLI action, look up the correct syntax here, construct the complete one-liner, show it to the user for approval, then execute it.
Rule: Always produce complete commands from near through the final action token (send, display, now, create, etc.). Never omit network-config <NETWORK>.
Version: near-cli-rs v0.14+ (tested through v0.24)
Command Grammar
near [GLOBAL_FLAGS] <COMMAND_GROUP> [ENTITY_ARGS] <SUBCOMMAND> [SUB_ARGS] network-config <NETWORK> [SIGNING_OPTION] [FINAL_ACTION]
- View commands end with:
now | at-block-height <N> | at-block-hash <HASH>
- Transaction commands end with a signing option followed by
send or display
- Account creation via faucet ends with
create
network-config keyword is always required (even for view commands)
Global Flags
| Flag | Effect |
|---|
--offline | Create/sign tx without network access |
--quiet | Suppress progress output (recommended for scripting) |
--teach-me | Print all RPC calls and their parameters |
Networks and View Qualifiers
| Item | Value |
|---|
| Built-in networks | mainnet, testnet |
| Custom network | any <connection-name> from near config show-connections |
| View: latest block | now |
| View: specific height | at-block-height <BLOCK_HEIGHT> |
| View: specific hash | at-block-hash <BLOCK_HASH> |
Amount and Gas Formats
| Asset | Format | Notes |
|---|
| NEAR | '1 NEAR' or '0.5 NEAR' | Quoted, space before unit |
| yoctoNEAR | '1 yoctoNEAR' | Required deposit for many contract calls |
| Gas | '30 Tgas' to '300 Tgas' | Default '100 Tgas', max '300 Tgas' |
| FT amount | '10 usn' | Number + FT symbol, quoted |
| FT all | all | Transfer entire balance |
Signing Options Reference
Replace <SIGNING_OPTION> in any transaction command with one of:
| Option | Full syntax |
|---|
| OS keychain (recommended) | sign-with-keychain send |
Legacy keychain (~/.near-credentials/) | sign-with-legacy-keychain send |
| Ledger hardware wallet | sign-with-ledger send |
| Plaintext private key | sign-with-plaintext-private-key --signer-public-key ed25519:<PUBKEY> --signer-private-key ed25519:<PRIVKEY> send |
| Access key file | sign-with-access-key-file /path/to/key.json send |
| Seed phrase | sign-with-seed-phrase 'word1 ... word12' --seed-phrase-hd-path 'm/44'"'"'/397'"'"'/0'"'"'' send |
| MPC | sign-with-mpc send |
| Produce unsigned tx (sign later) | sign-later |
Replace send with display to print the signed transaction in base64 without broadcasting.
account Commands
view-account-summary
near account view-account-summary <ACCOUNT_ID> network-config <NETWORK> now
near account view-account-summary <ACCOUNT_ID> network-config <NETWORK> at-block-height <BLOCK_HEIGHT>
near account view-account-summary <ACCOUNT_ID> network-config <NETWORK> at-block-hash <BLOCK_HASH>
import-account
near account import-account using-seed-phrase '<SEED_PHRASE>' --seed-phrase-hd-path 'm/44'"'"'/397'"'"'/0'"'"'' network-config <NETWORK>
near account import-account using-private-key ed25519:<PRIVATE_KEY> network-config <NETWORK>
export-account
near account export-account <ACCOUNT_ID> using-seed-phrase network-config <NETWORK>
near account export-account <ACCOUNT_ID> using-private-key network-config <NETWORK>
create-account
near account create-account sponsor-by-faucet-service <NEW_ACCOUNT_ID> autogenerate-new-keypair save-to-keychain network-config testnet create
near account create-account sponsor-by-faucet-service <NEW_ACCOUNT_ID> use-manually-provided-seed-phrase '<SEED_PHRASE>' network-config testnet create
near account create-account sponsor-by-faucet-service <NEW_ACCOUNT_ID> use-manually-provided-public-key ed25519:<PUBKEY> network-config testnet create
near account create-account fund-myself <NEW_ACCOUNT_ID> '<INITIAL_BALANCE>' autogenerate-new-keypair save-to-keychain sign-as network-config <NETWORK> sign-with-keychain send
near account create-account fund-myself <NEW_ACCOUNT_ID> '<INITIAL_BALANCE>' autogenerate-new-keypair save-to-keychain sign-as <SIGNER_ACCOUNT_ID> network-config <NETWORK> sign-with-keychain send
near account create-account fund-myself <NEW_ACCOUNT_ID> '<INITIAL_BALANCE>' use-manually-provided-seed-phrase '<SEED_PHRASE>' sign-as <SIGNER_ACCOUNT_ID> network-config <NETWORK> sign-with-keychain send
near account create-account fund-myself <NEW_ACCOUNT_ID> '<INITIAL_BALANCE>' use-manually-provided-public-key ed25519:<PUBKEY> sign-as <SIGNER_ACCOUNT_ID> network-config <NETWORK> sign-with-keychain send
delete-account
near account delete-account <ACCOUNT_ID> beneficiary <BENEFICIARY_ACCOUNT_ID> network-config <NETWORK> sign-with-keychain send
list-keys
near account list-keys <ACCOUNT_ID> network-config <NETWORK> now
get-public-key
near account get-public-key from-seed-phrase '<SEED_PHRASE>' --seed-phrase-hd-path "m/44'/397'/0'"
near account get-public-key from-plaintext-private-key ed25519:<PRIVATE_KEY>
near account get-public-key from-keychain <ACCOUNT_ID> network-config <NETWORK>
near account get-public-key from-legacy-keychain <ACCOUNT_ID> network-config <NETWORK>
near account get-public-key from-ledger --seed-phrase-hd-path "m/44'/397'/0'/0'/1'"
add-key
near account add-key <ACCOUNT_ID> grant-full-access use-manually-provided-public-key ed25519:<PUBKEY> network-config <NETWORK> sign-with-keychain send
near account add-key <ACCOUNT_ID> grant-function-call-access --allowance '<ALLOWANCE>' --contract-account-id <CONTRACT_ID> --function-names '<METHOD1>, <METHOD2>' autogenerate-new-keypair save-to-keychain network-config <NETWORK> sign-with-keychain send
near account add-key <ACCOUNT_ID> grant-function-call-access --allowance '<ALLOWANCE>' --contract-account-id <CONTRACT_ID> --function-names '' use-manually-provided-public-key ed25519:<PUBKEY> network-config <NETWORK> sign-with-keychain send
delete-keys
near account delete-keys <ACCOUNT_ID> public-keys ed25519:<PUBKEY> network-config <NETWORK> sign-with-keychain send
manage-storage-deposit
near account manage-storage-deposit <CONTRACT_ID> view-balance <ACCOUNT_ID> network-config <NETWORK> now
near account manage-storage-deposit <CONTRACT_ID> deposit <ACCOUNT_ID> '<AMOUNT>' sign-as <SIGNER_ACCOUNT_ID> network-config <NETWORK> sign-with-keychain send
near account manage-storage-deposit <CONTRACT_ID> withdraw '<AMOUNT>' sign-as <ACCOUNT_ID> network-config <NETWORK> sign-with-keychain send
update-social-profile
near account update-social-profile <ACCOUNT_ID> json-args '{"name":"<NAME>","image":{"ipfs_cid":"<CID>"}}' sign-as <ACCOUNT_ID> network-config <NETWORK> sign-with-keychain send
near account update-social-profile <ACCOUNT_ID> file-args /path/to/profile.json sign-as <ACCOUNT_ID> network-config <NETWORK> sign-with-keychain send
tokens Commands
view-near-balance
near tokens <ACCOUNT_ID> view-near-balance network-config <NETWORK> now
view-ft-balance
near tokens <ACCOUNT_ID> view-ft-balance <FT_CONTRACT_ID> network-config <NETWORK> now
view-nft-assets
near tokens <ACCOUNT_ID> view-nft-assets <NFT_CONTRACT_ID> network-config <NETWORK> now
send-near
near tokens <SENDER_ACCOUNT_ID> send-near <RECEIVER_ACCOUNT_ID> '<AMOUNT>' network-config <NETWORK> sign-with-keychain send
send-ft
near tokens <SENDER_ACCOUNT_ID> send-ft <FT_CONTRACT_ID> <RECEIVER_ACCOUNT_ID> '<AMOUNT>' memo '<MEMO>' network-config <NETWORK> sign-with-keychain send
near tokens <SENDER_ACCOUNT_ID> send-ft <FT_CONTRACT_ID> <RECEIVER_ACCOUNT_ID> all memo '' --prepaid-gas '300.0 Tgas' --attached-deposit '1 yoctoNEAR' network-config <NETWORK> sign-with-keychain send
Note: Default prepaid-gas is '100.0 Tgas' and attached-deposit is '1 yoctoNEAR'.
send-nft
near tokens <SENDER_ACCOUNT_ID> send-nft <NFT_CONTRACT_ID> <RECEIVER_ACCOUNT_ID> <TOKEN_ID> --prepaid-gas '300.0 Tgas' --attached-deposit '1 yoctoNEAR' network-config <NETWORK> sign-with-keychain send
staking Commands
validator-list
near staking validator-list network-config <NETWORK>
delegation
near staking delegation <ACCOUNT_ID> view-balance <POOL_ID> network-config <NETWORK> now
near staking delegation <ACCOUNT_ID> deposit-and-stake '<AMOUNT>' <POOL_ID> network-config <NETWORK> sign-with-keychain send
near staking delegation <ACCOUNT_ID> stake '<AMOUNT>' <POOL_ID> network-config <NETWORK> sign-with-keychain send
near staking delegation <ACCOUNT_ID> stake-all <POOL_ID> network-config <NETWORK> sign-with-keychain send
near staking delegation <ACCOUNT_ID> unstake '<AMOUNT>' <POOL_ID> network-config <NETWORK> sign-with-keychain send
near staking delegation <ACCOUNT_ID> unstake-all <POOL_ID> network-config <NETWORK> sign-with-keychain send
near staking delegation <ACCOUNT_ID> withdraw '<AMOUNT>' <POOL_ID> network-config <NETWORK> sign-with-keychain send
near staking delegation <ACCOUNT_ID> withdraw-all <POOL_ID> network-config <NETWORK> sign-with-keychain send
Note: Unstaked funds require approximately 2 epochs (~48 hours) before they can be withdrawn.
contract Commands
call-function (view/read-only)
near contract call-function as-read-only <CONTRACT_ID> <METHOD_NAME> json-args '{"key":"value"}' network-config <NETWORK> now
near contract call-function as-read-only <CONTRACT_ID> <METHOD_NAME> empty-args network-config <NETWORK> now
near contract call-function as-read-only <CONTRACT_ID> <METHOD_NAME> text-args '<STRING>' network-config <NETWORK> now
near contract call-function as-read-only <CONTRACT_ID> <METHOD_NAME> base64-args '<BASE64>' network-config <NETWORK> now
call-function (transaction/state-changing)
near contract call-function as-transaction <CONTRACT_ID> <METHOD_NAME> json-args '{"key":"value"}' prepaid-gas '<GAS>' attached-deposit '<DEPOSIT>' sign-as <SIGNER_ACCOUNT_ID> network-config <NETWORK> sign-with-keychain send
near contract call-function as-transaction <CONTRACT_ID> <METHOD_NAME> empty-args prepaid-gas '<GAS>' attached-deposit '<DEPOSIT>' sign-as <SIGNER_ACCOUNT_ID> network-config <NETWORK> sign-with-keychain send
deploy
near contract deploy <ACCOUNT_ID> use-file /path/to/contract.wasm without-init-call network-config <NETWORK> sign-with-keychain send
near contract deploy <ACCOUNT_ID> use-file /path/to/contract.wasm with-init-call <INIT_METHOD> json-args '{}' prepaid-gas '100 Tgas' attached-deposit '0 NEAR' network-config <NETWORK> sign-with-keychain send
inspect
near contract inspect <CONTRACT_ID> network-config <NETWORK> now
verify
near contract verify deployed-at <CONTRACT_ID> network-config <NETWORK> now
download-abi
near contract download-abi <CONTRACT_ID> save-to-file <OUTPUT_FILE_PATH> network-config <NETWORK> now
download-wasm
near contract download-wasm <CONTRACT_ID> save-to-file <OUTPUT_FILE_PATH> network-config <NETWORK> now
view-storage
near contract view-storage <CONTRACT_ID> all as-json network-config <NETWORK> now
near contract view-storage <CONTRACT_ID> keys-start-with-string '<PREFIX>' as-json network-config <NETWORK> now
near contract view-storage <CONTRACT_ID> keys-start-with-bytes-as-base64 '<BASE64_PREFIX>' as-json network-config <NETWORK> now
transaction Commands
view-status
near transaction view-status <TX_HASH> network-config <NETWORK>
reconstruct-transaction
near transaction reconstruct-transaction <TX_HASH> network-config <NETWORK>
sign-transaction
near transaction sign-transaction '<UNSIGNED_TX_BASE64>' network-config <NETWORK> sign-with-keychain send
send-signed-transaction
near transaction send-signed-transaction '<SIGNED_TX_BASE64>' network-config <NETWORK>
print-transaction
near transaction print-transaction signed '<SIGNED_TX_BASE64>'
near transaction print-transaction unsigned '<UNSIGNED_TX_BASE64>'
send-meta-transaction
near transaction send-meta-transaction '<SIGNED_DELEGATE_BASE64>' network-config <NETWORK>
config Commands
show-connections
near config show-connections
add-connection
near config add-connection --network-name <NETWORK_NAME> --connection-name <CONNECTION_NAME> --rpc-url <RPC_URL> --wallet-url <WALLET_URL> --explorer-transaction-url <EXPLORER_TX_URL> [--rpc-api-key '<API_KEY>'] [--linkdrop-account-id <LINKDROP_ID>] [--faucet-url <FAUCET_URL>] [--meta-transaction-relayer-url <RELAYER_URL>]
delete-connection
near config delete-connection <CONNECTION_NAME>
Common Patterns (Cookbook)
Quick-reference one-liners for the most frequent tasks. Substitute placeholders with real values.
1. Check NEAR balance
near tokens alice.near view-near-balance network-config mainnet now
2. Transfer NEAR tokens
near tokens alice.near send-near bob.near '5 NEAR' network-config mainnet sign-with-keychain send
3. View account details
near account view-account-summary alice.near network-config mainnet now
4. List access keys
near account list-keys alice.near network-config mainnet now
5. Send fungible tokens
near tokens alice.near send-ft usdt.tether-token.near bob.near '10 USDT' memo '' network-config mainnet sign-with-keychain send
6. View FT balance
near tokens alice.near view-ft-balance usdt.tether-token.near network-config mainnet now
7. Call a view-only contract method
near contract call-function as-read-only wrap.near ft_balance_of json-args '{"account_id":"alice.near"}' network-config mainnet now
8. Call a state-changing contract method
near contract call-function as-transaction wrap.near ft_transfer json-args '{"receiver_id":"bob.near","amount":"1000000000000000000000000"}' prepaid-gas '100 Tgas' attached-deposit '1 yoctoNEAR' sign-as alice.near network-config mainnet sign-with-keychain send
9. Stake NEAR with a validator
near staking delegation alice.near deposit-and-stake '10 NEAR' aurora.pool.near network-config mainnet sign-with-keychain send
10. Unstake from a validator
near staking delegation alice.near unstake-all aurora.pool.near network-config mainnet sign-with-keychain send
11. Withdraw unstaked NEAR (after ~2 epoch wait)
near staking delegation alice.near withdraw-all aurora.pool.near network-config mainnet sign-with-keychain send
12. Create a testnet account (faucet-funded)
near account create-account sponsor-by-faucet-service myaccount.testnet autogenerate-new-keypair save-to-keychain network-config testnet create
13. Create a sub-account (self-funded)
near account create-account fund-myself sub.alice.testnet '1 NEAR' autogenerate-new-keypair save-to-keychain sign-as alice.testnet network-config testnet sign-with-keychain send
14. Deploy a contract
near contract deploy mycontract.testnet use-file ./contract.wasm without-init-call network-config testnet sign-with-keychain send
15. Delete an access key
near account delete-keys alice.testnet public-keys ed25519:<PUBKEY_TO_REMOVE> network-config testnet sign-with-keychain send
16. Add a full-access key
near account add-key alice.testnet grant-full-access use-manually-provided-public-key ed25519:<NEW_PUBKEY> network-config testnet sign-with-keychain send
Offline Mode and Scripting Tips
Offline signing workflow (air-gapped / two-machine)
near --offline tokens alice.near send-near bob.near '1 NEAR' network-config mainnet sign-with-seed-phrase '<SEED_PHRASE>' --seed-phrase-hd-path 'm/44'"'"'/397'"'"'/0'"'"'' display
near transaction send-signed-transaction '<SIGNED_TX_BASE64>' network-config mainnet
sign-later workflow
near tokens alice.near send-near bob.near '1 NEAR' network-config mainnet sign-later
near transaction sign-transaction '<UNSIGNED_TX_BASE64>' network-config mainnet sign-with-keychain display
near transaction send-signed-transaction '<SIGNED_TX_BASE64>' network-config mainnet
Scripting tips
- Always add
--quiet to suppress progress output in scripts
- Always quote amounts:
'1 NEAR', '0.5 NEAR', '1 yoctoNEAR'
- Seed phrase HD path shell escaping:
'm/44'"'"'/397'"'"'/0'"'"''
- Use
display instead of send to inspect signed tx before broadcasting
Key Format Reference
| Item | Format | Example |
|---|
| Public key | ed25519:<BASE58> | ed25519:8h7kFK4... |
| Private key | ed25519:<BASE58> | ed25519:2qM8v3N... |
| Transaction hash | 44-char base58 | F3eZmht... |
| Named account | name.near / name.testnet | alice.near |
| Implicit account | 64-char lowercase hex | a4b05ef3... |
| Standard HD path | m/44'/397'/0' | NEAR BIP44 |
| Ledger HD path | m/44'/397'/0'/0'/N' | 5-component required for Ledger |
Common Errors
| Error | Likely cause / fix |
|---|
| "Account does not exist" | Wrong network, or account not yet funded |
| "Access key not found" | Use sign-with-legacy-keychain or sign-with-seed-phrase |
| "Exceeded prepaid gas" | Increase gas: '300 Tgas' |
| FT transfer fails silently | FT ft_transfer requires attached-deposit '1 yoctoNEAR' |
| "Method not found" | Check method name with near contract inspect |
| Seed phrase HD path error | Escape single quotes: 'm/44'"'"'/397'"'"'/0'"'"'' |