This repository contains an example implementation of a non-fungible token contract in Rust which uses near-sdk-contract-tools.
non-fungible token: https://nomicon.io/Standards/NonFungibleToken/README.htmlnear-sdk-contract-tools: https://github.com/near/near-sdk-contract-toolsnear-contract-standards: https://github.com/near/near-sdk-rs/tree/master/near-contract-standardsnear-workspaces-rs: https://github.com/near/near-workspaces-rs
Note: If you'd like to learn how to create an NFT contract from scratch that explores every aspect of the NEP-171 standard including an NFT marketplace, check out the NFT Zero to Hero Tutorial.
Install cargo-near and run:
cargo near buildNote: to avoid issues, be sure to update your Rust compiler with
rustup update stable
cargo testTo deploy manually, install cargo-near and run:
# Deploy the contract and initialize it
cargo near deploy build-non-reproducible-wasm <account-id> with-init-call new json-args '{"owner_id":"<account-id>", "metadata": {"name": "GO TEAM", "symbol": "GOAT", "icon": "https://bafybeidl4hjbpdr6u6xvlrizwxbrfcyqurzvcnn5xoilmcqbxfbdwrmp5m.ipfs.dweb.link/", "spec": "nft-1.0.0"}}' prepaid-gas '100.0 Tgas' attached-deposit '0 NEAR' network-config testnet sign-with-keychain send# View metadata
near view <account-id> nft_metadata
# Mint a NFT
near call <account-id> nft_mint '{"token_id": "0", "owner_id": "<account-id>", "metadata": {"title": "Olympus Mons", "description": "Tallest mountain in charted solar system", "media": "https://upload.wikimedia.org/wikipedia/commons/thumb/0/00/Olympus_Mons_alt.jpg/1024px-Olympus_Mons_alt.jpg", "copies": "1"}}' --accountId <account-id> --deposit 0.1
# View tokens for owner
near view <account-id> nft_tokens_for_owner '{"account_id": "<owner_id>"}'
# Transfer a NFT
near call <account-id> nft_transfer '{"token_id": "0", "receiver_id": "<receiver-id>", "memo": "transfer ownership"}' --accountId <account-id> --depositYocto 1- cargo-near - NEAR smart contract development toolkit for Rust
- near CLI - Iteract with NEAR blockchain from command line
- NEAR Rust SDK Documentation
- NEAR Documentation
- NFT Zero to Hero Tutorial
- NEAR StackOverflow
- NEAR Discord
- NEAR Telegram Developers Community Group
- NEAR DevHub: Telegram, Twitter