This is a good project to use as a starting point for your AssemblyScript project.
This repository includes a complete project structure for AssemblyScript contracts targeting the NEAR platform.
The example here is very basic. It's a simple contract demonstrating the following concepts:
- a single contract
- the difference between
view
vs.change
methods
There are 1 Rust contracts in this project, each in their own folder:
- status message in the
src
folder
We say that an rust contract is written in the "simple style" when the lib.rs
file (the contract entry point) includes a series of exported functions.
In this case, all exported functions become public contract methods.
(see below for video recordings of each of the following steps)
INSTALL NEAR CLI
first like this: npm i -g near-cli
INSTALL RUST toolchain
Add the wasm target using rustup target add wasm32-unknown-unknown
- clone this repo to a local folder
- run
./scripts/1.dev-deploy.sh
- run
./scripts/2.use-contract.sh
- run
./scripts/3.cleanup.sh
1.dev-deploy.sh
This video shows the build and deployment of the contract.
2.use-contract.sh
This video shows contract methods being called. You should run the script twice to see the effect it has on contract state.
3.cleanup.sh
This video shows the cleanup script running. Make sure you add the BENEFICIARY
environment variable. The script will remind you if you forget.
export BENEFICIARY=<your-account-here> # this account receives contract account balance
-
See
./scripts/README.md
for documentation about the scripts -
Watch this video where Willem Wyndham walks us through refactoring a simple example of a NEAR smart contract written in AssemblyScript