NEAR CLI
near CLI is your human-friendly companion that helps to interact with NEAR Protocol from command line.
Just run near and let it guide you through!
Install
Visit Releases page to see the latest updates.
https://github.com/user-attachments/assets/607f797b-0412-4741-984b-6b6032d05262
|
https://github.com/user-attachments/assets/7d5d090e-4885-4c27-9d0f-045905952071
|
https://github.com/user-attachments/assets/4a7e4633-1957-4dc2-a032-827fa9c06c29
Install it with cargo, just make sure you have Rust installed on your computer.
NOTE: On Linux, near-cli-rs is built with Ledger devices support by default, and that requires
libudev-devpackage. On Debian/Ubuntu, install it withapt install libudev-dev.
or, install the most recent version from git repository:
It is often desirable to use near CLI from CI to automate some actions, so here is an example of how you can make a function call during CI:
name: Release
on:
push:
branches:
jobs:
deploy-widgets:
runs-on: ubuntu-latest
name: Make a function call on mainnet
env:
NEAR_NETWORK_CONNECTION: mainnet
NEAR_CONTRACT_ACCOUNT_ID: ${{ vars.NEAR_CONTRACT_ACCOUNT_ID }}
NEAR_SIGNER_ACCOUNT_ID: ${{ vars.NEAR_SIGNER_ACCOUNT_ID }}
NEAR_SIGNER_ACCOUNT_PUBLIC_KEY: ${{ vars.NEAR_SIGNER_ACCOUNT_PUBLIC_KEY }}
NEAR_SIGNER_ACCOUNT_PRIVATE_KEY: ${{ secrets.NEAR_SIGNER_ACCOUNT_PRIVATE_KEY }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install near CLI
run: |
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/near-cli-rs/releases/download/v0.7.4/near-cli-rs-installer.sh | sh
- name: Call some function
run: |
near contract call-function as-transaction "$NEAR_CONTRACT_ACCOUNT_ID" 'function_name_here' json-args '{}' prepaid-gas '100 TeraGas' attached-deposit '0 NEAR' sign-as "$NEAR_SIGNER_ACCOUNT_ID" network-config "$NEAR_NETWORK_CONNECTION" sign-with-plaintext-private-key --signer-public-key "$NEAR_SIGNER_ACCOUNT_PUBLIC_KEY" --signer-private-key "$NEAR_SIGNER_ACCOUNT_PRIVATE_KEY" send
You will need to configure GitHub Actions Secrets and Variables and once it is ready, this CI will only take a couple of seconds to complete!
See how it is used by DevHub.
Run
Once installed, you just run it with near command:
)
> account
)
The CLI interactively guides you through some pretty complex topics, helping you make informed decisions along the way. Also, you can enable shell history integration