Skip to content
by Unity Nodes
NEAR Protocol

Rust: NEAR collections, U128, build, deploy, call/view with NEAR CLI

Nothing is loaded from YouTube until you press play, and then without tracking cookies.

About this video

We take a tour starting from a StackOverflow question and delve into a few topics. Like why we shouldn't use Rust's HashMap data structure, what NEAR Collections are available, and how to use them. We'll also cover not-great behavior that can occur when sending large numbers as parameters, and the need to use U64 or U128, which are different than u64 and u128.

StackOverflow question: https://stackoverflow.com/questions/6...

Examples: near.dev

Rust contract demonstrating U128 issues: https://github.com/mikedotexe/near-de...

The project shown in this video: https://github.com/mikedotexe/near-st...

Install NEAR CLI: https://docs.near.org/docs/developmen...

All the NEAR Collections for Rust: https://docs.rs/near-sdk/2.0.0/near_s...

If you don't have an account, go to wallet.testnet.near.org

CLI Commands: near create-account 64378144.stackoverflow.testnet --masterAccount stackoverflow.testnet near deploy --accountId 64378144.stackoverflow.testnet --wasmFile res/veggie_example.wasm --initFunction 'new' --initArgs '{}' near call 64378144.stackoverflow.testnet add_veggie_taste '{"upc": "679508051007679508", "taste": "just alright"}' --accountId 64378144.stackoverflow.testnet near view 64378144.stackoverflow.testnet get_taste '{"upc": "679508051007679508"}'

Then: (will fail) near call 64378144.stackoverflow.testnet perish_all '{}' --accountId mike.testnet

(would succeed if you had the keys) near call 64378144.stackoverflow.testnet perish_all '{}' --accountId 64378144.stackoverflow.testnet

Make minor change not affecting state, then deploy with: near deploy --accountId 64378144.stackoverflow.testnet --wasmFile res/veggie_example.wasm

Add a veggie from another account:

near call 64378144.stackoverflow.testnet add_veggie_taste '{"upc": "199508051007679508", "taste": "ono"}' --accountId mike.testnet near view 64378144.stackoverflow.testnet get_taste '{"upc": "199508051007679508"}'

I'm on Twitter at @mikedotexe

Follow the latest from NEAR Protocol on,

Website: near.org Discord: near.ai/discord Medium: near.ai/medium Twitter: near.ai/twitter GitHub: near.ai/github

Transcript

YouTube has no captions for this video, so there is no text to read. We look again once a day.