Fungible Tokens

A guide to help you create your own fungible tokens

source: Hiro blog

Creating a fungible token on Stacks can happen a few different ways — using no-code launchpads or writing your own Clarity smart contract. This guide helps you pick the best path for your goals and gives you the implementation details to ship confidently, whether you’re deploying with clicks or code.

Custom Development

For developers who want full control over their token implementation, here’s how to create a custom SIP-010 token on Stacks using Clarity. But before you deploy the token contract, you must have your token contract conform to the SIP-010 trait standard.

1

Define SIP-010 fungible token trait

What is SIP-010?

SIP-010 is the standard for defining fungible tokens on Stacks. Defining a common interface (known in Clarity as a "trait") allows different smart contracts, apps, and wallets to interoperate with fungible token contracts in a reusable way.

Below is an implementation of the SIP-010 trait standard for fungible tokens. You can use the existing minimal standard SIP-010 trait or extend it by adding in your own custom traits. But the requirements of the SIP-010 traits are necessary to have at the minimum.

All we are doing here is defining the function signatures for functions we'll need to implement in our token contract, which we can see a simple version of below.

2

Implement SIP-010 trait in token contract

Any token contract that wants to conform to the SIP-010 fungible token standard for Stacks needs to have this trait "implemented" in their token contract. See the below minimal token contract example of how this is done.

This is the Clarity code we need in order to create an fungible token, with one additional function, mint that allows us to actually create a new fungible tokens. This mint function is not needed to adhere to the trait.

The token contract example above is passing in an already deployed trait on mainnet into the impl-trait function. You can use this same deployed trait for your own token contract as well.

No-code Platforms

Use community built no-code platforms that can quickly help you deploy tokens.

STX.City

STX.CITY is a one-click platform for launching tokens on Stacks. The platform is a comprehensive toolkit for memecoin creators, enabling them to grow their communities through features like AMM listing support (such as on Alex, Velar, and Stackswap), airdrops, token donations, and burn mechanisms.

Check out this blog post by the founder of STX.City for more information.

Best Practices

Here are some things to consider when creating your token and after your token is launched.

How to format the token metadata?

Example token metadata taken from the sBTC token:

Check out the SIP-016 standard for how you should define the schema of your metadata.

How would I properly update my token metadata?

If you plan on updating your token's metadata in the future, you should definitely implement a SIP-019 compliant token metadata update notification. Take a look at the example token contract above and you'll notice the set-token-uri function emits a SIP-019 compliant print event.

Hiro’s Token Metadata API watches for that specific print event (specifically the notification of "token-metadata-update") on the network and auto-updates the API’s database to reflect a change in the existing token’s metadata.

If your token contract did not implement this print event, you could use the helper contract below to invoke a function that'll emit the same print event notification. Just invoke the ft-metadata-update-notify function of this contract below:

SP1H6HY2ZPSFPZF6HBNADAYKQ2FJN75GHVV95YZQ.token-metadata-update-notify

Additional Resources

  • [dev.to] A Deep Dive into Token Standards: ERC-20 vs. SIP-10 vs. BRC20 vs. STX20

  • [StacksGov] SIP-010 Standard Trait Definition for Fungible Tokens

  • [StacksGov] SIP-016 Schema Definition for Metadata for Digital Assets

  • [StacksGov] SIP-019 Notifications for Token Metadata Updates

  • [contract] SP1H6HY2ZPSFPZF6HBNADAYKQ2FJN75GHVV95YZQ.token-metadata-update-notify

  • [StacksDevs YT] Fungible Token Standard (SIP-10) Tutorial For Bitcoin L2 Stacks

  • [LearnWeb3] SIP-010 Fungible Tokens & Traits

  • [Medium @n.campos.rojas] Learn how to create fungible tokens on Stacks (versus on Ethereum)

Last updated

Was this helpful?