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:
TestNet - Used to test the functionality and business logic of smart contracts projects.
MainNet - The official mainnet, where contracts can be deployed after thorough testing.
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:
Install npm
Execute the installation command:
sudo npm install -g near-cli
Verify Installation:
near --version
Deploying Contracts on TestNet
Register TestNet account
Visit the NEAR wallet website to register a new account
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
Compile the contract to generate a WASM file
Create a sub-account for deployment
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.
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.
12 Likes
Reward
12
6
Repost
Share
Comment
0/400
MissedAirdropAgain
· 07-14 15:21
When will these updates issue coin?
View OriginalReply0
ApeDegen
· 07-14 14:15
Is it a network deployment? What's the picture for?
View OriginalReply0
DeFiChef
· 07-12 16:32
Let's give it a try~
View OriginalReply0
Ramen_Until_Rich
· 07-11 16:16
Pro, please distribute the salary.
View OriginalReply0
LuckyHashValue
· 07-11 16:15
As expected, there's no need to elaborate too much.
NEAR Testnet Deployment Rust smart contracts Practical Guide
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:
NEAR CLI Installation
NEAR CLI is a NodeJS command line interface for interacting with the NEAR network. Installation steps:
sudo npm install -g near-cli
near --version
Deploying Contracts on TestNet
Register TestNet account
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
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.