What You'll Build

In this tutorial, we will build out a Move smart contract (module) from scratch with key stablecoin features such as Minting, Burning, and Transferring. All of the features will be implemented with key management and control features using the Fungible Asset Standard.


Knowledge Please ensure that you have knowledge of, or have covered the following topics before

this tutorial:

  1. Learn the basics about Move smart contract
  2. Aptos Object Model
  3. Fungible Asset Standard

Set-up - [Set up your

environment](https://learn.aptoslabs.com/example/aptogotchi-beginner/env-setup)


Contract Definition - Create a new folder within your desired directory on your local device.

You can call it something like stablecoin-aptos. - Navigate to the root of your project directory, and run the following command on your terminal: aptos init. Select devnet (default) and enter your private key. A new one will be created for you if you don't enter an existing one (can view it in the config.yaml file that is created for you). - Create a file called Move.toml at the root.


[package]
name = "stablecoin"
version = "0.0.0"
[addresses]
stablecoin = "_"
master_minter = "_"
minter = "_"
denylister = "_"
[dependencies.AptosFramework]
git = "https://github.com/aptos-labs/aptos-core.git"
rev = "mainnet"
subdir = "aptos-move/framework/aptos-framework"

  • Create a folder called sources, and under that folder create a file called usdk.move.
  • In our case, the aptos_framework package is necessary for utilizing fungible assets, while the aptos_token_objects package is required for NFT usage. Since these packages aren't part of the standard library, it's essential to include them as dependencies.

module stablecoin::usdk {
use aptos_framework::account;
use aptos_framework::dispatchable_fungible_asset;
use aptos_framework::event;
use aptos_framework::function_info;
use aptos_framework::fungible_asset::{Self, MintRef, TransferRef, BurnRef, Metadata, FungibleAsset, FungibleStore};
use aptos_framework::object::{Self, Object, ExtendRef};
use aptos_framework::primary_fungible_store;
use aptos_std::smart_table::{Self, SmartTable};
use std::option;
use std::signer;
use std::string::{Self, utf8};
use std::vector;
use aptos_framework::chain_id;