Fungible Token (FT) Example 👋
This repository contains an example implementation of a fungible token contract in Rust which uses near-contract-standards and workspaces-rs tests.
Install cargo-near
and run:
cargo near build
cargo test
To deploy manually, install cargo-near
and run:
# Create a new account
cargo near create-dev-account
# 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_call
provides 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
- NEAR Rust SDK Documentation
- NEAR Documentation
- NEAR StackOverflow
- NEAR Discord
- NEAR Telegram Developers Community Group
- NEAR DevHub: Telegram, Twitter