Skip to content

near-examples/ft-contract-tools

Repository files navigation

Fungible Token (FT) based on Contract Tools

This repository contains an example implementation of a fungible token contract in Rust which uses near-sdk-contract-tools.


How to Build Locally?

Install cargo-near and run:

cargo near build

How to Test Locally?

cargo test

How to Deploy?

To 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>

Basic methods

# 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

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

About

No description, website, or topics provided.

Resources

License

MIT, Apache-2.0 licenses found

Licenses found

MIT
LICENSE
Apache-2.0
LICENSE-APACHE

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages