Fungible Token (FT) Example 👋 [![](https://img.shields.io/badge/⋈%20Examples-Basics-green)](https://docs.near.org/tutorials/welcome) [![](https://img.shields.io/badge/Contract-Rust-red)](contract-rs) This repository contains an example implementation of a [fungible token] contract in Rust which uses [near-contract-standards] and workspaces-rs tests. [fungible token]: https://nomicon.io/Standards/FungibleToken/Core [near-contract-standards]: https://github.com/near/near-sdk-rs/tree/master/near-contract-standards [near-workspaces-rs]: https://github.com/near/near-workspaces-rs
## How to Build Locally? Install [`cargo-near`](https://github.com/near/cargo-near) and run: ```bash cargo near build ``` ## How to Test Locally? ```bash cargo test ``` ## How to Deploy? To deploy manually, install [`cargo-near`](https://github.com/near/cargo-near) and run: ```bash # Create a new account cargo near create-dev-account # Deploy the contract on it cargo near deploy # Initialize the contract near call new '{"owner_id": "", "total_supply": "1000000000000000", "metadata": { "spec": "ft-1.0.0", "name": "Example Token Name", "symbol": "EXLT", "decimals": 8 }}' --accountId ``` ## Basic methods ```bash # View metadata near view ft_metadata # Make a storage deposit near call storage_deposit '' --accountId --amount 0.00125 # View balance near view ft_balance_of '{"account_id": ""}' # Transfer tokens near call ft_transfer '{"receiver_id": "", "amount": "19"}' --accountId --amount 0.000000000000000000000001 ``` ## Notes - 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. ## Useful Links - [cargo-near](https://github.com/near/cargo-near) - NEAR smart contract development toolkit for Rust - [near CLI](https://near.cli.rs) - Iteract with NEAR blockchain from command line - [NEAR Rust SDK Documentation](https://docs.near.org/sdk/rust/introduction) - [NEAR Documentation](https://docs.near.org) - [NEAR StackOverflow](https://stackoverflow.com/questions/tagged/nearprotocol) - [NEAR Discord](https://near.chat) - [NEAR Telegram Developers Community Group](https://t.me/neardev) - NEAR DevHub: [Telegram](https://t.me/neardevhub), [Twitter](https://twitter.com/neardevhub)