> ## Documentation Index
> Fetch the complete documentation index at: https://docs.near.org/llms.txt
> Use this file to discover all available pages before exploring further.

# NEAR CLI

> Interact with NEAR through the terminal.

The NEAR [Command Line Interface](https://github.com/near/near-cli-rs) (CLI) is a tool that enables you to interact with the NEAR network directly from the shell. Among other things, the NEAR CLI enables you to create and manage accounts, send tokens such as NEAR, FTs and NFTs, deploy smart contracts, call functions on those contracts, and manage access keys.

## Installation

<Tabs>
  <Tab title="npm">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    npm install -g near-cli-rs@latest
    ```
  </Tab>

  <Tab title="Cargo">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    cargo install near-cli-rs
    ```
  </Tab>

  <Tab title="Mac and Linux (binaries)">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/near-cli-rs/releases/latest/download/near-cli-rs-installer.sh | sh
    ```
  </Tab>

  <Tab title="Windows (binaries)">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    irm https://github.com/near/near-cli-rs/releases/latest/download/near-cli-rs-installer.ps1 | iex
    ```
  </Tab>
</Tabs>

## Configuration file

The directory with access keys and available connection networks are defined in the configuration file (`near-cli/config.toml`), which is located depending on the operating system in the following places:

* macOS: `$HOME/Library/Application Support` (e.g. `/Users/Alice/Library/Application Support`)
* Linux: `$XDG_CONFIG_HOME` or `$HOME/.config` (e.g. `/home/alice/.config`)
* Windows: `{FOLDERID_RoamingAppData}` (e.g. `C:\Users\Alice\AppData\Roaming`)

You can learn more about working with the configuration file [here](https://github.com/near/near-cli-rs/blob/main/docs/GUIDE.en.md#config---manage-connections-in-a-configuration-file).

<Tip>
  You can set up a custom [RPC server](/api/rpc/providers) by changing the `rpc_url` parameter in `near-cli` settings:

  ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
  near config edit-connection testnet --key rpc_url --value https://archival-rpc.testnet.near.org/
  ```
</Tip>

## Interactive mode

To use the `near-cli` simply run the following in your terminal.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
near
```

You should then see the following. Use the arrow keys and hit `enter` or simply type out one of the available options to select an option.

<img src="https://mintcdn.com/neardocs/qO2GD-gji1aakHqN/assets/docs/tools/near-cli-rs.png?fit=max&auto=format&n=qO2GD-gji1aakHqN&q=85&s=035ed109b136f96248526e6635383326" alt="NEAR CLI interactive mode" width="2212" height="398" data-path="assets/docs/tools/near-cli-rs.png" />

<Note>
  We provide examples only of the most used commands. Such commands may have two versions — a **full** one and a **short** one. If you want to explore all options provided by `near-cli`, use the interactive mode described above.
</Note>

## Account

This option will allow you to manage, control, and retrieve information on your accounts.

### Summary

`view-account-summary` - view properties for an account.

<Tabs>
  <Tab title="Full">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    export ACCOUNT_ID=bob.testnet
    near account view-account-summary $ACCOUNT_ID network-config testnet now
    ```
  </Tab>

  <Tab title="Short">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    export ACCOUNT_ID=bob.testnet
    near state $ACCOUNT_ID --networkId testnet
    ```
  </Tab>
</Tabs>

### Import

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

<Tabs>
  <Tab title="Full">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    near account import-account using-web-wallet network-config testnet
    ```
  </Tab>

  <Tab title="Short">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    near login --networkId testnet
    ```
  </Tab>
</Tabs>

### Export

`export-account` - export existing account.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
export ACCOUNT_ID=bob.testnet
near account export-account $ACCOUNT_ID using-web-wallet network-config testnet
```

### Create

`create-account` - create a new account.

<Tabs>
  <Tab title="Full">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    export ACCOUNT_ID=bob.testnet
    near account create-account sponsor-by-faucet-service $ACCOUNT_ID autogenerate-new-keypair save-to-keychain network-config testnet create
    ```
  </Tab>

  <Tab title="Short">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    export ACCOUNT_ID=bob.testnet
    near create-account $ACCOUNT_ID --useFaucet --networkId testnet
    ```
  </Tab>
</Tabs>

### Delete

`delete-account` - delete an account.

<Tabs>
  <Tab title="Full">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    export ACCOUNT_ID=bob.testnet
    export BENEFICIARY_ID=alice.testnet

    near account delete-account $ACCOUNT_ID beneficiary $BENEFICIARY_ID network-config testnet sign-with-keychain send
    ```
  </Tab>

  <Tab title="Short">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    export ACCOUNT_ID=bob.testnet
    export BENEFICIARY_ID=alice.testnet

    near delete-account $ACCOUNT_ID $BENEFICIARY_ID --networkId testnet
    ```
  </Tab>
</Tabs>

## Keys

Showing, adding and removing account keys.

### List keys

`list-keys` - view a list of keys for an account.

<Tabs>
  <Tab title="Full">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    export ACCOUNT_ID=bob.testnet
    near account list-keys $ACCOUNT_ID network-config testnet now
    ```
  </Tab>

  <Tab title="Short">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    export ACCOUNT_ID=bob.testnet
    near list-keys $ACCOUNT_ID --networkId testnet
    ```
  </Tab>
</Tabs>

### Add key

`add-key` - add an access key to an account.

<Tabs>
  <Tab title="Full">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    export ACCOUNT_ID=bob.testnet
    near account add-key $ACCOUNT_ID grant-full-access use-manually-provided-public-key ed25519:CXqAs8c8kZz81josLw82RQsnZXk8CAdUo7jAuN7uSht2 network-config testnet sign-with-keychain send
    ```
  </Tab>

  <Tab title="Short">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    export ACCOUNT_ID=bob.testnet
    near add-key $ACCOUNT_ID ed25519:CXqAs8c8kZz81josLw82RQsnZXk8CAdUo7jAuN7uSht2 --networkId testnet
    ```
  </Tab>
</Tabs>

### Delete key

`delete-keys` - delete an access key from an account.

<Tabs>
  <Tab title="Full">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    export ACCOUNT_ID=bob.testnet
    near account delete-keys $ACCOUNT_ID public-keys ed25519:HdkFZFEPoWfgrrLK3R4t5dWtNoLC8WymBzhCXoP3zrjh network-config testnet sign-with-keychain send
    ```
  </Tab>

  <Tab title="Short">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    export ACCOUNT_ID=bob.testnet
    near delete-key $ACCOUNT_ID ed25519:HdkFZFEPoWfgrrLK3R4t5dWtNoLC8WymBzhCXoP3zrjh --networkId testnet
    ```
  </Tab>
</Tabs>

## Tokens

This will allow you to manage your token assets such as NEAR, FTs and NFTs.

### Send NEAR

`send-near` - transfers NEAR to a specified recipient in units of NEAR or yoctoNEAR.

<Tabs>
  <Tab title="Full">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    export ACCOUNT_ID=bob.testnet
    export RECEIVER_ID=alice.testnet
    near tokens $ACCOUNT_ID send-near $RECEIVER_ID '0.5 NEAR' network-config testnet sign-with-keychain send
    ```
  </Tab>

  <Tab title="Short">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    export ACCOUNT_ID=bob.testnet
    export RECEIVER_ID=alice.testnet

    near send-near $ACCOUNT_ID $RECEIVER_ID 0.5 --networkId testnet
    ```
  </Tab>
</Tabs>

### Send FT

`send-ft` - transfer Fungible Tokens to a specified user.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
export ACCOUNT_ID=bob.testnet
export RECEIVER_ID=alice.testnet
export FT_CONTRACT_ID=0c97251cd1f630c444dbusdt.testnet

near tokens $ACCOUNT_ID send-ft $FT_CONTRACT_ID $RECEIVER_ID amount-ft '1 USDT' prepaid-gas '100.0 Tgas' attached-deposit '1 yoctoNEAR' network-config testnet sign-with-keychain send
```

### Send NFT

`send-nft` - transfers NFTs between accounts.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
export ACCOUNT_ID=bob.testnet
export RECEIVER_ID=alice.testnet
export NFT_CONTRACT_ID=nft.examples.testnet

near tokens $ACCOUNT_ID send-nft $NFT_CONTRACT_ID $RECEIVER_ID 1 --prepaid-gas '100.0 Tgas' --attached-deposit '1 yoctoNEAR' network-config testnet sign-with-keychain send
```

### View NEAR balance

`view-near-balance` - view the balance of NEAR tokens.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
export ACCOUNT_ID=bob.testnet
near tokens $ACCOUNT_ID view-near-balance network-config testnet now
```

### View FT balance

`view-ft-balance` - view the balance of Fungible Tokens.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
export ACCOUNT_ID=bob.testnet
export FT_CONTRACT_ID=0c97251cd1f630c444dbusdt.testnet
near tokens $ACCOUNT_ID view-ft-balance $FT_CONTRACT_ID network-config testnet now
```

### View NFT balance

`view-nft-assets` - view the balance of NFT tokens.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
export ACCOUNT_ID=bob.testnet
export NFT_CONTRACT_ID=nft.examples.testnet
near tokens $ACCOUNT_ID view-nft-assets $NFT_CONTRACT_ID network-config testnet now
```

## Contract

This option allows you to manage and interact with your smart contracts.

### Call

`call-function` - execute function (contract method).

<Tabs>
  <Tab title="Full">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    # View method
    export CONTRACT_ID=nft.examples.testnet
    near contract call-function as-read-only $CONTRACT_ID nft_tokens json-args '{"from_index": "0", "limit": 2}' network-config testnet now

    # Call method
    export ACCOUNT_ID=bob.testnet
    near contract call-function as-transaction $CONTRACT_ID nft_mint json-args '{"metadata": {"copies": 1, "description": "The Team Goes", "media": "https://bafybeidl4hjbpdr6u6xvlrizwxbrfcyqurzvcnn5xoilmcqbxfbdwrmp5m.ipfs.dweb.link/", "title": "GO TEAM"}, "receiver_id": "bob.testnet", "token_id": "5895"}' prepaid-gas '100.0 Tgas' attached-deposit '0.1 NEAR' sign-as $ACCOUNT_ID network-config testnet sign-with-keychain send
    ```
  </Tab>

  <Tab title="Short">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    # View method
    export CONTRACT_ID=nft.examples.testnet
    near view $CONTRACT_ID nft_tokens '{"from_index": "0", "limit": 2}' --networkId testnet

    # Call method
    export ACCOUNT_ID=bob.testnet
    near call $CONTRACT_ID nft_mint '{"metadata": {"copies": 1, "description": "The Team Goes", "media": "https://bafybeidl4hjbpdr6u6xvlrizwxbrfcyqurzvcnn5xoilmcqbxfbdwrmp5m.ipfs.dweb.link/", "title": "GO TEAM"}, "receiver_id": "bob.testnet", "token_id": "5896"}' --deposit 0.1 --useAccount $ACCOUNT_ID --networkId testnet
    ```
  </Tab>
</Tabs>

### Deploy

`deploy` - add a new contract code.

<Tabs>
  <Tab title="Full">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    export CONTRACT_ID=contract.testnet
    near contract deploy $CONTRACT_ID use-file ../target/near/contract.wasm without-init-call network-config testnet sign-with-keychain send
    ```
  </Tab>

  <Tab title="Short">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    export CONTRACT_ID=contract.testnet
    near deploy $CONTRACT_ID ../target/near/contract.wasm --networkId testnet
    ```
  </Tab>
</Tabs>

### Inspect

`inspect` - get a list of available function names.

<Tabs>
  <Tab title="Full">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    export CONTRACT_ID=nft.examples.testnet
    near contract view-storage $CONTRACT_ID all as-text network-config testnet now
    ```
  </Tab>

  <Tab title="Short">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    export CONTRACT_ID=nft.examples.testnet
    near storage $CONTRACT_ID --finality final --utf8 --networkId testnet
    ```
  </Tab>
</Tabs>

## Transaction

Operate transactions.

### View status

`view-status` - view a transaction status.

<Tabs>
  <Tab title="Full">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    near transaction view-status BFrVVtjqD2p1zYX1UCvn4nJpy7zPHpY5cTgQaKCZjBvw network-config testnet
    ```
  </Tab>

  <Tab title="Short">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    near tx-status BFrVVtjqD2p1zYX1UCvn4nJpy7zPHpY5cTgQaKCZjBvw --networkId testnet
    ```
  </Tab>
</Tabs>

## Config

Manage the connection parameters inside the `config.toml` file for `near-cli`.

This will allow you to change or modify the network connections for your CLI.

### Show connections

`show-connections` - show a list of network connections.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
near config show-connections
```

### Edit connection

`edit-connection` - edit a network connection.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
near config edit-connection testnet --key rpc_url --value https://test.rpc.fastnear.com
```

<Note>
  We provide examples only of the most used commands. If you want to explore all options provided by `near-cli`, use the [interactive mode](#interactive-mode).
</Note>

## Validators

You can use the following commands to interact with the blockchain and view validator stats. There are three reports used to monitor validator status:

* [Proposals](#proposals)
* [Current validators](#current-validators)
* [Next validators](#next-validators)

<Tip>
  To use these commands, you **must** install the CLI [validator extension](#validator-extension).
</Tip>

### Validator extension

If you want to interact with [NEAR Validators](https://pages.near.org/papers/economics-in-sharded-blockchain/#validators) from command line, you can install the [NEAR Validator CLI Extension](https://github.com/near-cli-rs/near-validator-cli-rs):

<Tabs>
  <Tab title="npm">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    npm install -g near-validator
    ```
  </Tab>

  <Tab title="Cargo">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    cargo install near-validator
    ```
  </Tab>

  <Tab title="Mac and Linux (binaries)">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near-cli-rs/near-validator-cli-rs/releases/latest/download/near-validator-installer.sh | sh
    ```
  </Tab>

  <Tab title="Windows (binaries)">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    irm https://github.com/near-cli-rs/near-validator-cli-rs/releases/latest/download/near-validator-installer.ps1 | iex
    ```
  </Tab>
</Tabs>

### Proposals

A proposal by a validator indicates they would like to enter the validator set. In order for a proposal to be accepted it must meet the minimum seat price.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
near-validator proposals network-config mainnet
```

### Current validators

This shows a list of active validators in the current epoch, the number of blocks produced, number of blocks expected, and online rate. Used to monitor if a validator is having issues.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
near-validator validators network-config mainnet now
```

### Next validators

This shows validators whose proposal was accepted one epoch ago, and that will enter the validator set in the next epoch.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
near-validator validators network-config mainnet next
```

### Staking

For validators, there's also an option to stake NEAR tokens without deploying a staking pool smart contract.

#### View validator stake

To view the validator's stake on the last block:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
near-validator staking view-stake examples.testnet network-config testnet now
```

#### Stake directly without a staking pool

To stake the amount:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
near-validator staking stake-proposal examples.testnet ed25519:AiEo5xepXjY7ChihZJ6AsfoDAaUowhPgvQp997qnFuRP '1500 NEAR' network-config testnet sign-with-keychain send
```

#### Unstake directly without a staking pool

To unstake:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
near-validator staking unstake-proposal examples.testnet ed25519:AiEo5xepXjY7ChihZJ6AsfoDAaUowhPgvQp997qnFuRP network-config testnet sign-with-keychain send
```
