First Token on Move
Learning Move’s Asset Model through Token Creation
💡 Goals of This Chapter
- Understand Move’s asset model (
resource
,object
) through hands‑on practice. - Learn the token issuance flow using
Coin
,TreasuryCap
, andmint
/burn
logic. - Use the Sui Extension template to create and manage your own token.
1. Overview — What Is an Asset in Move?
In Move, all assets—coins, NFTs, and permissions—are represented as resources. A resource cannot be copied or deleted; it can only be moved.
Concept | Description |
---|---|
resource | A value that cannot be copied or deleted—only moved. |
object | A managed instance of a resource in Sui. |
Coin<T> | Represents a token object. |
TreasuryCap<T> | Object holding capability to mint or burn. |
2. Preparing the Template — Managed Token
The Sui Extension includes a ready‑to‑use token template. Choose “Sui Move Intro Course: Fungible Token (Managed)” to begin.
📌 Steps to Load the Template
- In VS Code → Explorer, right‑click a folder → New Move Project
- Select Fungible Token (Managed) from the list
- Run Build / Test / Deploy to complete deployment
After deployment, a
TreasuryCap<...::MANAGED>
object is created. It represents your token’s mint and burn authority.
3. Code Walkthrough — Minting and Capability Structure
Token Type Definition
public struct MANAGED has drop {}
MANAGED
defines the token’s type. It’s an empty struct with the drop
ability and serves as the token’s unique type identifier.
Initialization Logic
fun init(witness: MANAGED, ctx: &mut TxContext) {
let (treasury_cap, metadata) = sui::coin::create_currency<MANAGED>(
witness, 2, b"MANAGED", b"MNG", b"", std::option::none(), ctx
);
sui::transfer::public_freeze_object(metadata);
sui::transfer::public_transfer(treasury_cap, sui::tx_context::sender(ctx));
}
create_currency
creates the token and its metadata.metadata
stores the token name, symbol, and description.treasury_cap
grants mint/burn authority.
4. Practice — Minting and Burning
Mint Function
public fun mint(
treasury_cap: &mut TreasuryCap<MANAGED>,
amount: u64,
recipient: address,
ctx: &mut TxContext,
) {
treasury_cap.mint_and_transfer(amount, recipient, ctx)
}
- Only accounts holding
TreasuryCap
can call this function. - Mints tokens and transfers them to
recipient
.
Burn Function
public fun burn(treasury_cap: &mut TreasuryCap<MANAGED>, coin: Coin<MANAGED>) {
treasury_cap.burn(coin);
}
- Burns (destroys) existing tokens.
5. Running in PTB Builder 🌟
Open PTB Builder
Add a
moveCall
nodeLoad the package
Select the function:
0x<package_address>::managed::mint
Set arguments:
object(treasuryCapId)
pure.u64(amount)
pure.address(recipient)
Click Run and check the Transaction Digest
- View it in the Sui Blockchain Explorer, or at ptb.wal.app/viewer by appending your digest:
https://ptb.wal.app/viewer?tx=<DIGEST>
- View it in the Sui Blockchain Explorer, or at ptb.wal.app/viewer by appending your digest:
💡 PTB Builder can convert the executed PTB to TypeScript code. Use Export to paste it directly into your project.
6. Results and Applications
- The minted
Coin<MANAGED>
appears in the Owner Objects Explorer. - You can call
burn
to destroy tokens in the same way. - Both PTB Builder and CLI produce the same transaction block.