Skip to content

kirill-m21/fungible_token

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Fungible Token

MANAGED: a token managed by a treasurer trusted for minting and burning. This is how (e.g.) a fiat-backed stablecoin or an in-game virtual currency would work.

Install Sui (Linux)

Other OS

Install steps for macOS or WIndows 11 could be found here.

Rust and cargo

Use the following command to install Rust and Cargo on Linux:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Use the following command to update Rust:

rustup update stable

Linux prerequisites

You should make sure that your system has the latest version of apt-get. Use the following command to update apt-get:

sudo apt-get update

Install cURL with the following command:

sudo apt install curl

Run the following command to install Git, including the Git CLI:

sudo apt-get install git-all

Install CMake using the instructions at Installing CMake on the CMake website.

Use the following command to install libssl-dev:

sudo apt-get install libssl-dev

Use the following command to install libclang-dev:

sudo apt-get install libclang-dev

Install Sui binaries

cargo install --locked --git https://github.com/MystenLabs/sui.git --branch devnet sui

Integrated development environment

The recommended IDE for Move development is Visual Studio Code with the move-analyzer extension. Follow the Visual Studio Marketplace instructions to install the move-analyzer extension, passing address20 using the --features flag:

cargo install --git https://github.com/move-language/move move-analyzer --features "address20"

Sui test tokens request

To request SUI test tokens in Discord (once per two hours):

  1. Join the Sui Discord.

  2. Identify your address by running the following command and electing to connect to a Sui RPC server if prompted:

    sui client active-address

  3. Request tokens in the #devnet-faucet channel using the syntax: !faucet <YOUR_ADDRESS>, for example:
    !faucet 0xd72c2c90ed9d923cb0ed2ca91db5be9e1c9b5ccb

Sui Move Explorer

You might search for information through sui move explorer by Addresses / Objects / Transactions.

Building a package

Ensure that directory contains your package, and then use the following command to build it:

sui move build

Testing a package

An individual Move unit test is encapsulated in a public function that has no parameters, no return values, and has the #[test] annotation. Such functions are executed by the testing framework upon executing the following command:

sui move test

Deploy a package

After succesful SUI test tokens request, check the current address:

sui client active-address

Output:

To simplify the next steps – Assign a new address to the var. In this case example: ACCOUNT_ID=0xaa5a31455935d79607dadac2a446b355bcf71ef4

To deploy (you should be in the root folder):

sui client publish --gas-budget 1000

Output:

Current transaction details could be found here.

Interact with a package

Let’s see all the objects on the current account.

sui client objects

Output:

From the output besides airdropped coins we could see deployed package:

Object ID 0xcfd4e997d7e3524f4beb80162b75252c00eb1331
Version 1110
Digest QAdY0mb+Ce4fiwuLFMxUOUwgC6rpM1IHgd/w+EGGno8=
Owner Type AddressOwner
Object Type 0x2::coin::TreasuryCap<0xd163b8ae41129c2ccd3497cf6657b825099ae136::managed::MANAGED>

To simplify the next steps (in the current case):

PACKAGE_ID=0xd163b8ae41129c2ccd3497cf6657b825099ae136

MANAGED_ID=0xcfd4e997d7e3524f4beb80162b75252c00eb1331

to call the method with the entry modifier (in our case, the mint method) requires the following command:

sui client call --function mint --module managed --package $PACKAGE_ID --args \"$MANAGED_ID\" \"42\" \"$ACCOUNT_ID\" --gas-budget 10000

Output:

Let’s see all the objects on the current account.

sui client objects

Output:

From the output besides airdropped coins and deployed package we could see minted managed coins:

Object ID 0xaa049d6b61a5e467375f9e72ae4b60fd356debde
Version 1111
Digest jTG8BQ2CH1liVXla4gjwdlzA6G/ctgwnqH7F6/Bg+7M=
Owner Type AddressOwner
Object Type 0x2::coin::Coin<0xd163b8ae41129c2ccd3497cf6657b825099ae136::managed::MANAGED>

For the next steps (in the current case):

COIN_ID=0xaa049d6b61a5e467375f9e72ae4b60fd356debde

to call the method with the entry modifier (in our case, the burn method) requires the following command:

sui client call --function mint --module managed --package $PACKAGE_ID --args \"$MANAGED_ID\" \"$COIN_ID\" --gas-budget 10000

Output:

Let’s see all the objects on the current account.

sui client objects

Output:

As a result – minted coins were burned.

About

Sui move fungible token example implementation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages