NEAR Testnet Deployment Rust smart contracts Practical Guide

robot
Abstract generation in progress

Rust smart contracts development practice: deployment and invocation

This article will introduce how to deploy a simple example smart contract to the NEAR test network, execute the contract, and query the execution results.

Introduction to the NEAR Network

NEAR Protocol, as a protocol, can support multiple independent networks based on it. The three main networks commonly used are as follows:

  1. TestNet - Used to test the functionality and business logic of smart contracts projects.
  2. MainNet - The official mainnet, where contracts can be deployed after thorough testing.
  3. LocalNet - A locally running network, suitable for private development

NEAR CLI Installation

NEAR CLI is a NodeJS command line interface for interacting with the NEAR network. Installation steps:

  1. Install npm
  2. Execute the installation command:

sudo npm install -g near-cli

  1. Verify Installation:

near --version

Deploying Contracts on TestNet

Register TestNet account

  1. Visit the NEAR wallet website to register a new account
  2. View account information in the browser

Log in to NEAR CLI

Execute the following command to log in to your account:

near login

View account information

near state <账户名>

Contract Compilation and Deployment

  1. Compile the contract to generate a WASM file
  2. Create a sub-account for deployment
  3. Use the near deploy command to deploy the smart contracts.

call contract function

Use the near call command to invoke functions in the smart contracts, for example:

near call '{"parameter":"value"}' --accountId

transaction query

You can query specific transaction details in NEAR Explorer using the transaction ID.

By following the above steps, we have completed the entire process of smart contracts from compilation to deployment and then to invocation. The next step can be to discuss how to write safer smart contracts from a security perspective.

NEAR-2.89%
View Original
This page may contain third-party content, which is provided for information purposes only (not representations/warranties) and should not be considered as an endorsement of its views by Gate, nor as financial or professional advice. See Disclaimer for details.
  • Reward
  • 6
  • Share
Comment
0/400
MissedAirdropAgainvip
· 07-14 15:21
When will these updates issue coin?
View OriginalReply0
ApeDegenvip
· 07-14 14:15
Is it a network deployment? What's the picture for?
View OriginalReply0
DeFiChefvip
· 07-12 16:32
Let's give it a try~
View OriginalReply0
Ramen_Until_Richvip
· 07-11 16:16
Pro, please distribute the salary.
View OriginalReply0
LuckyHashValuevip
· 07-11 16:15
As expected, there's no need to elaborate too much.
View OriginalReply0
RetiredMinervip
· 07-11 16:15
Can you provide a simplified tutorial?
View OriginalReply0
Trade Crypto Anywhere Anytime
qrCode
Scan to download Gate app
Community
English
  • 简体中文
  • English
  • Tiếng Việt
  • 繁體中文
  • Español
  • Русский
  • Français (Afrique)
  • Português (Portugal)
  • Bahasa Indonesia
  • 日本語
  • بالعربية
  • Українська
  • Português (Brasil)