A simple CLI tool to manage NEAR smart contract projects. Supports creating, building, deploying contracts, and managing accounts on the NEAR blockchain. Compatible with Linux, macOS, and Windows.
Before using the near-go CLI, ensure you have the following tools installed on your PC:
near-go CLI.
This CLI acts as a proxy to TinyGo.
curl -LO https://github.com/vlmoon99/near-cli-go/releases/latest/download/install.sh && bash install.sh && rm install.shThis script installs the near-go binary to your ~/bin directory and adds it to your PATH.
Alternatively, download from GitHub Releases and move it manually to your bin.
-
Get path of
near-gobinary:which near-go
-
Remove it:
rm -rf /home/your-user/bin/near-go
Once installed, use the following commands to manage NEAR smart contracts.
1. Create a new project
near-go create -p <projectName> -m <moduleName> -t <type of project>
near-go create -p "test1" -m "test1" -t "smart-contract-empty"2. Build the project
near-go buildGenerates a main.wasm using TinyGo.
3. Run tests
near-go testRuns smart contract tests using TinyGo.
4. Manage blockchain accounts
near-go account <subcommand>Examples:
near-go account create -n "testnet" -a "accountid.testnet"
near-go account import5. Deploy the smart contract
near-go deploy -id "accountid.testnet" -n "testnet"6. Call smart contract functions
near-go call --from <signer> --to <contract> --function <method> [--args <json>] [--gas <amount>] [--deposit <amount>] --network <network>Examples:
Call a view or change method with default args and values:
near-go call \
--from neargocli.testnet \
--to neargocli.testnet \
--function ReadIncommingTxData \
--network testnetCall with all parameters set explicitly:
near-go call \
--from neargocli.testnet \
--to neargocli.testnet \
--function ReadIncommingTxData \
--args '{}' \
--gas '100 Tgas' \
--deposit '0 NEAR' \
--network testnetCall a method with arguments:
near-go call \
--from neargocli.testnet \
--to neargocli.testnet \
--function WriteData \
--args '{"key": "testKey", "data": "test1"}' \
--gas '100 Tgas' \
--deposit '0 NEAR' \
--network testnet7. View help
near-go helpDisplays list of all available commands and help for individual commands.
(base) test1@test1:~/dev/near-cli-go$ go run main.go
All necessary programs are installed.
NAME:
near-go - CLI tool for managing projects on Near Blockchain
USAGE:
[global options] command [command options] [arguments...]
COMMANDS:
create Create a new project
build Build the project
test Run tests
account Manage blockchain accounts
deploy Deploy the project to production
call Call a smart contract function
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--help, -h show helpIf you want to contribute to this project, follow these steps to set up your environment and build the CLI from source.
Run the following script to download and install all required internal binaries:
bash setup.shThis will fetch the necessary NEAR CLI binaries and place them in:
/near-cli-go/bindata/tools
To build the CLI for all supported platforms and architectures, run:
bash build.shThis script will:
- Build the CLI for:
- Linux (
amd64andarm64) - macOS (
amd64andarm64)
- Linux (
- Output binaries named according to their platform and architecture (e.g.,
near-cli-linux-amd64). - Zip each binary for easy distribution (e.g.,
near-cli-linux-amd64.zip).
After running the script, you will find the zipped binaries in the project directory, ready for distribution or testing.
Now you are ready to contribute!