this is forked from Counter example in Rust (https://github.com/near-examples/rust-counter). Modified to do hello world.
lib.rs
- add get_helloworld(), add corresponding unit test
- remove other methods, remove corresponding unit test
remove src/tests/sim/test.rs
main.js, index.html
- add call to get_helloworld(), remove call to increment, decrement, get_num().
This contract implements bare minimum hello world
Contract in contract/src/lib.rs
provides methods to get a hello world string.
Open in the Gitpod link above or clone the repository. (not tested. I only tested the regular version)
git clone https://github.com/hackathonprojs/near-rust-helloworld
Install dependencies:
yarn
If you don't have Rust
installed, complete the following 3 steps:
- Install Rustup by running:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
(Taken from official installation guide)
- Configure your current shell by running:
source $HOME/.cargo/env
- Add wasm target to your toolchain by running:
rustup target add wasm32-unknown-unknown
Next, make sure you have near-cli
by running:
near --version
If you need to install near-cli
:
npm install near-cli -g
If you do not have a NEAR account, please create one with NEAR Wallet.
In the project root, login with near-cli
by following the instructions after this command:
near login
Modify the top of src/config.js
, changing the CONTRACT_NAME
to be the NEAR account that was just used to log in. currently set to helloworld.gameofstake.testnet
…
const CONTRACT_NAME = 'YOUR_ACCOUNT_NAME_HERE'; /* TODO: fill this in! */
…
Start the example!
yarn start
cd contract
cargo test -- --nocapture
contract/src/lib.rs
for the contract codesrc/index.html
for the front-end HTMLsrc/main.js
for the JavaScript front-end code and how to integrate contractssrc/test.js
for the JS tests for the contract
cd contract
cargo doc --no-deps --open