Create your own token with Typescript
One of the amazing things that you can do with our SDK, is create your own ERC20 token, or Coin! How amazing is that?
In this guide, we will explore how to create our own "SaturnCoin", deploy contract for it, mint and share tokens with everyone else. Let's go! 🚀
Setup your project quickly if you haven't yet with the instructions here.
Deploy your ERC20 token contract
To make your own coin, You need to deploy the contract with the name, and symbol of your coin. For us, it would
be SaturnCoin and SATC. Feel free to change the value as you want!
const tokenAddress = await client.deployTokenModule({
name: 'SaturnCoin',
symbol: 'SATC'
});
console.log(`Token contract deployed at ${address}`);Run this file. Once the transaction is processed, it should give you the contract address. Keep a note of it.
Mint and transfer coins
Now, here's the fun part, where you mint your own token, transfer and even burn (destroy) it.
First, instantiate the token module with the address from earlier.
const tokenModule = client.getTokenModule(tokenAddress);Let's get started by minting a supply of 5000 tokens.
const { transactionHash } = await tokenModule.mint(5000);
console.log(`Minted tokens. Transaction hash: ${transactionHash}`);We can also transfer to a specific address, a supply of 500.
const { transactionHash } = await tokenModule.transfer(
'<RECIPIENT_ADDRESS>',
500
);
console.log(`Transferred tokens. Transaction hash: ${transactionHash}`);As well as, destroying the supply is possible too! Here's how.
const { transactionHash } = await tokenModule.burn(500);
console.log(`Destroyed tokens. Transaction hash: ${transactionHash}`);And, there we go! 🚀
It's this easy to make your own currency, make a supply for it, transfer it, destroy it and lots more things.