How to Use NEAR CLI: A Comprehensive Guide

Dec 19, 2023 | Blockchain

Welcome to the wonderful world of NEAR CLI! If you’re looking to interact with the NEAR blockchain without getting lost in complex code, you’ve arrived at the right place. This guide will not only help you install and navigate NEAR CLI but will also cover common troubleshooting steps to ensure a smooth experience.

What is NEAR CLI?

NEAR CLI is a command-line interface built using Node.js and the near-api-js library, allowing users to connect to and interact with the NEAR blockchain. With NEAR CLI, you can create accounts, manage access keys, and easily send transactions.

Installation: Getting Started

Before diving into usage, it’s essential to set up NEAR CLI on your machine.

Requirements

  • Node.js version 16 or higher.
  • Current version of npm.

Installing on Mac and Linux

npm install -g near-cli

If you’re using NVM (Node Version Manager), here are the steps to install it:


curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
source ~/.bashrc
nvm install node
npm install -g near-cli

Installing on Windows

For Windows users, it’s recommended to use the Windows Subsystem for Linux (WSL).

  1. Install WSL here.
  2. Follow the instructions to install npm and Node.js.
npm install -g near-cli

Basic Commands: Navigating NEAR CLI

Once installed, you can start utilizing NEAR CLI commands. Let’s delve into some core functionalities.

Creating Accounts

Creating an account in NEAR is as simple as one quick command!

near create-account new-account.testnet --initialBalance 10

Managing Access Keys

Access keys are crucial for account security. Here’s how to manage them:

  • Add Access Key:
    near add-key accountId publicKey
  • Delete Access Key:
    near delete-key accountId publicKey

An Analogy to Understand NEAR CLI Features

Think of creating a NEAR account and managing access keys like opening a bank account:

  • Creating an Account: When you want to open a bank account, you fill out some forms and deposit an initial amount (like creating an account with the initial balance).
  • Access Keys: Access keys act like your ATM cards. You can add multiple cards (keys) to your account for different permissions (transactions, withdrawals, etc.).

Troubleshooting Common Issues

Even the best tools encounter hiccups. Here are some troubleshooting tips:

  • If a command isn’t working, try checking the command help. For example:
  • near create-account --help
  • Ensure your Node.js is updated to the latest version.
  • If you run into issues with Ledger, you may need to specify the –ledgerPath.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Conclusion

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox