Skip to content

near CLI is your human-friendly companion that helps to interact with NEAR Protocol from command line.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

near/near-cli-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

bb7a244 · Nov 21, 2023
Sep 28, 2023
Dec 8, 2021
Oct 31, 2023
Oct 1, 2021
Nov 21, 2023
Sep 28, 2023
Mar 20, 2021
Sep 30, 2022
Nov 21, 2023
Nov 21, 2023
Nov 21, 2023
Dec 8, 2021
Dec 20, 2022
Dec 20, 2022
Apr 6, 2023
Apr 17, 2023
Jun 6, 2023

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

Locally

Download pre-compiled version of near CLI for your OS from the Releases page.

Alternatively, install it with cargo if you have Rust installed on your computer:

$ cargo install near-cli-rs

Here is the expected output when you run it:

$ near

?  What are you up to? (select one of the options with the up-down arrows on your keyboard and press Enter)
> account     - Manage accounts
  tokens      - Manage token assets such as NEAR, FT, NFT
  contract    - Manage smart-contracts: deploy code, call functions
  transaction - Operate transactions
  config      - Manage connections in a configuration file (config.toml)
[↑↓ to move, enter to select, type to filter]

or, install the most recent version from git repository:

$ cargo install --git https://github.com/near/near-cli-rs

GitHub Actions

It is often desirable to use near CLI from CI to automate some actions, and so you can use this following script if you want to make a function call during CI:

name: Release
on:
  push:
    branches: [main]

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.3.1/near-cli-rs-v0.3.1-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 it in action used in near/devgigsboard.