Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.
/ near-cli Public archive
forked from near/near-cli

General purpose command line tools for interacting with NEAR Protocol

License

MIT, Apache-2.0 licenses found

Licenses found

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

near-guildnet/near-cli

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

NEAR CLI (command line interface)

Build Status Gitpod Ready-to-Code

NEAR CLI is a Node.js application that relies on near-api-js to generate secure keys, connect to the NEAR platform and send transactions to the network on your behalf.

note that Node.js version 10+ is required to run NEAR CLI

Installation

Before you proceed, make sure you have to following software installed :

sudo apt install python3 git curl
sudo apt install clang
sudo apt install build-essential
sudo apt install nodejs
sudo apt install npm
sudo npm install -g n
sudo n stable
PATH="$PATH"

Uninstall near-cli

# sudo may be needed.
npm uninstall -g near-cli

Install near-cli

git clone https://github.com/near-guildnet/near-cli.git
cd near-cli
# sudo may be needed.
npm install -g

Usage

In command line, from the directory with your project:

export NODE_ENV=guildnet|testnet|mainnet|betanet
near <command>

Account creation

Without a wallet this is how I created master accounts. Maybe there's a different way. Account creation requires httpie

near generate-key <Account_id>.guildnet
http post http://164.90.144.140:3000/account newAccountId=account_id.guildnet newAccountPublicKey=account_public_key

Commands

For a list of up-to-date commands, run near in your terminal with no arguments. If you need to find a command that isn't listed here, look in the /commands folder. And add it here :)

For account:

  near login                                       # logging in through NEAR protocol wallet
  near create-account <accountId>                  # create a developer account with --masterAccount (required), publicKey and initialBalance
  near state <accountId>                           # view account state
  near keys <accountId>                            # view account public keys
  near add-key <accountId> <accessKey>             # Add an access key to given account
  near send <sender> <receiver> <amount>           # send tokens to given receiver
  near stake <accountId> <stakingKey> <amount>     # create staking transaction (stakingKey is base58 encoded)
  near delete <accountId> <beneficiaryId>          # delete an account and transfer funds to beneficiary account
  near delete-key [accessKey]                      # delete access key

For native smart contracts:

  near deploy [accountId] [wasmFile] [initFunction] [initArgs] [initGas] [initDeposit]  # deploy your smart contract
  near dev-deploy [wasmFile]                       # deploy your smart contract using temporary account (TestNet only)
  near call <contractName> <methodName> [args]     # schedule smart contract call which can modify state
  near view <contractName> <methodName> [args]     # make smart contract call which can view state
  near clean                                       # clean the smart contract build locally (remove ./out )

For NEAR EVM smart contracts:

  near evm-view <evmAccount> <contractName> <methodName> [args]     # make an EVM smart contract call which can view state
  near evm-call <evmAccount> <contractName> <methodName> [args]     # schedule an EVM smart contract call which can modify state

For transactions:

  near tx-status <hash>                            # lookup transaction status by hash

For validators:

  near validators <epoch>                          # lookup validating nodes by epoch(or "current", "next")
  near proposals                                   # lookup current proposals

REPL:

near repl

Launch interactive Node.js shell with NEAR connection available to use. The repl's initial context contains nearAPI, nearand account if an accountId cli argument is provided. To load a script into the repl use .load script.js.

Usage example:
near repl --acountId bob
> console.log(account)
> .load script.js

Misc:

  near repl                                        # launch interactive Node.js shell with NEAR connection available to use
  near generate-key <account-id>                   # generate key locally (Note: this does not create another access key automatically)

Options

Option Description Type Default
--help Show help [boolean]
--version Show version number [boolean]
--nodeUrl NEAR node URL [string] "https://rpc.testnet.near.org"
--networkId NEAR network ID for different keys by network [string] "default"
--helperUrl NEAR contract helper URL [string]
--keyPath Path to master account key [string]
--accountId Unique identifier for the account [string] [required]
--masterAccount Account used to create requested account. [string] [required]
--publicKey Public key to initialize the account with [string] [required]
--initialBalance Number of tokens to transfer to newly account [string] [required]

Environments

Use NEAR_ENV to define which network these commands will target. Default is testnet.

export NEAR_ENV=mainnet

License

This repository is distributed under the terms of both the MIT license and the Apache License (Version 2.0). See LICENSE and LICENSE-APACHE for details.

About

General purpose command line tools for interacting with NEAR Protocol

Resources

License

MIT, Apache-2.0 licenses found

Licenses found

MIT
LICENSE
Apache-2.0
LICENSE-APACHE

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 94.3%
  • Shell 5.7%