#near #command-line #helps #interact #human-friendly #protocols #companion

bin+lib near-cli-rs

人性化的控制台工具,帮助您从命令行与 NEAR 协议交互

42 个版本 (12 个重大更新)

新版本 0.14.3 2024 年 8 月 21 日
0.13.0 2024 年 7 月 30 日
0.8.1 2024 年 2 月 26 日
0.7.6 2023 年 12 月 21 日
0.2.1 2022 年 12 月 20 日

#161 in 魔法豆

Download history 412/week @ 2024-05-04 104/week @ 2024-05-11 393/week @ 2024-05-18 251/week @ 2024-05-25 157/week @ 2024-06-01 153/week @ 2024-06-08 372/week @ 2024-06-15 290/week @ 2024-06-22 600/week @ 2024-06-29 583/week @ 2024-07-06 264/week @ 2024-07-13 393/week @ 2024-07-20 1116/week @ 2024-07-27 1026/week @ 2024-08-03 1824/week @ 2024-08-10 756/week @ 2024-08-17

4,809 每月下载量
7 个crate中使用 (3 个直接使用)

MIT/Apache 和可能 GPL-3.0-or-later

1MB
20K SLoC

NEAR CLI

near CLI 是您的 人性化 伴侣,帮助您从命令行与 NEAR 协议 交互。

只需运行 near 并让它引导您即可!

安装

访问 发布页面 以查看最新更新。

通过 Windows 安装程序安装 (Windows)

https://github.com/user-attachments/assets/607f797b-0412-4741-984b-6b6032d05262

通过 powershell 脚本安装 (Windows)
irm https://github.com/near/near-cli-rs/releases/latest/download/near-cli-rs-installer.ps1 | iex

https://github.com/user-attachments/assets/7d5d090e-4885-4c27-9d0f-045905952071

通过 shell 脚本安装 (macOS, Linux, Windows/WSL)
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/near-cli-rs/releases/latest/download/near-cli-rs-installer.sh | sh
通过 npx 运行 (Windows, Linux, macOS 上的 Node.js)
npx near-cli-rs
在 package.json 脚本中使用 (Windows, Linux, macOS 上的 Node.js)
npm install near-cli-rs
获取便携式版本 (Windows, Linux, macOS)

https://github.com/user-attachments/assets/4a7e4633-1957-4dc2-a032-827fa9c06c29

从源代码编译和安装 (Windows, Linux, macOS 上的 Cargo)

使用 cargo 安装,确保您的计算机已安装 Rust

cargo install near-cli-rs

或者,从 git 仓库安装最新版本

$ cargo install --git https://github.com/near/near-cli-rs
在 CI 上安装 (GitHub Actions)

通常,我们希望使用来自CI的near CLI来自动化一些操作,以下是一个如何在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.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

您需要配置GitHub Actions Secrets和Variables,一旦准备就绪,这个CI只需要几秒钟就能完成!

请参考DevHub的用法(点击此处查看)

运行

安装完成后,只需使用near命令即可运行它。

$ 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
  staking     - Manage staking: view, add and withdraw stake
  contract    - Manage smart-contracts: deploy code, call functions
  transaction - Operate transactions
  config      - Manage connections in a configuration file (config.toml)
  extension   - Manage near CLI and extensions
[↑↓ to move, enter to select, type to filter]

CLI会交互式地引导您通过一些相当复杂的话题,帮助您在过程中做出明智的决策。

英文阅读更多

更多信息请参阅俄语版本 (in Russian)

依赖项

~51–73MB
~1M SLoC