The contracts use NEAR SDK 5.29.1 and the pinned Rust 1.97.1 toolchain. Install rustup and cargo-near before building or running the local sandbox integration tests:
cargo install cargo-near --version 0.21.1 --locked --no-default-featuresIntegration tests use near-sandbox to run local nodes and near-api to sign transactions. Contract builds and integration-test fixtures compile from source; no live network account is required for tests.
This repository contains an example implementation of a fungible token contract in Rust which uses near-contract-standards and sandobox testing.
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 '{"owner_id": "<contract-account-id>", "total_supply": "1000000000000000", "metadata": { "spec": "ft-1.0.0", "name": "Example Token Name", "symbol": "EXLT", "decimals": 8 }}' --accountId <contract-account-id># 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.00125
# 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 - Iteract with NEAR blockchain from command line