Token
How to create a token on Chopin Framework.
Before starting this tutorial, be sure to have a Chopin Framework project set up. If you don't have one, follow the Quickstart guide to get started.
Overview
In Chopin Framework, tokens are simply defined by your database and backend. There is no need to define a token contract. In this guide, we will present an idea for how you could create a token using Next.js and a PostgreSQL database.
You could use this method to add Points to your app—or to use Chopin Framework for traditional crypto usecases. However, keep in mind this is an technical guide and not legal advice.
Tokens and Balances
You can simply store a token's balance in a table.
Or you can extend the user table to include a balance column if there is only one type of token.
Now the logic for how we can create, mint, and transfer tokens can be easily implemented in your backend.
Token Creation
We can then create helper functions to get the max supply and total circulating supply.
Token Operations
Checking Balances
Minting
Burning
Transferring
Usage
Now you can control when this is invoked on the frontend by calling these functions in API routes. For example, here is a Next.js route that would allow a user transfer a token.
Bridging
Bridging is a work in progress. More information will come soon. It will eventually be possible to transfer tokens from your database to a third-party blockchain—and vice versa.
