Skip to content

Latest commit

 

History

History

contract-rs

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Count on NEAR Contract Example

The smart contract exposes methods to interact with a counter stored in the NEAR network.

How to Build Locally?

Install cargo-near and run:

cargo near build

How to Test Locally?

cargo test

How to Deploy?

Deployment is automated with GitHub Actions CI/CD pipeline. To deploy manually, install cargo-near and run:

cargo near deploy <account-id>

How to Interact?

In this example we will be using NEAR CLI to intract with the NEAR blockchain and the smart contract

If you want full control over of your interactions we recommend using the near-cli-rs.

Get the Counter

get_num is a read-only method (aka view method).

View methods can be called for free by anyone, even people without a NEAR account!

# Use near-cli to get the counter value
near view <contract-account-id> get_num

Modify the Counter

increment, decrement and reset change the contract's state, for which they are call methods.

Call methods can only be invoked using a NEAR account, since the account needs to pay GAS for the transaction.

# Use near-cli to set increment the counter
near call <contract-account-id> increment --accountId --accountId <your-account>

Useful Links