This repository contains an example implementation of a fungible token contract in Rust which uses near-sdk-contract-tools.
Install cargo-near and run:
cargo near buildcargo testTo deploy manually, install cargo-near and run:
# Create a new account
cargo near create-account <contract-account-id> --useFaucet
# Deploy the contract on it
cargo near deploy <contract-account-id>
# Initialize the contract
near call <contract-account-id> new '{}' --accountId <contract-account-id># Mint to owner
near contract call-function as-transaction <contract-account-id> mint json-args '{"amount": "100000"}' prepaid-gas '100.0 Tgas' attached-deposit '0.0025 NEAR' sign-as <contract-account-id> network-config testnet sign-with-keychain send
# Burn owner's tokens
near contract call-function as-transaction <contract-account-id> burn json-args '{"amount": "1"}' prepaid-gas '100.0 Tgas' attached-deposit '0 NEAR' sign-as <contract-account-id> network-config testnet sign-with-keychain send
# View metadata
near view <contract-account-id> ft_metadata
# Make a storage deposit
near call <contract-account-id> storage_deposit '' --accountId <account-id> --amount 0.0025
# View balance
near view <contract-account-id> ft_balance_of '{"account_id": "<account-id>"}'
# Transfer tokens
near call <contract-account-id> ft_transfer '{"receiver_id": "<account-id>", "amount": "19"}' --accountId <contract-account-id> --amount 0.000000000000000000000001- The maximum balance value is limited by U128 (
2**128 - 1). - JSON calls should pass U128 as a base-10 string. E.g. "100".
- This does not include escrow functionality, as
ft_transfer_callprovides a superior approach. An escrow system can, of course, be added as a separate contract or additional functionality within this contract.
-
cargo-near - NEAR smart contract development toolkit for Rust
-
near CLI - Interact with NEAR blockchain from the command line