Deploy TT20
Deploy Your Own TT20
ERC20 tokens are one of the most popular DApps in the blockchain community. This tutorial will guide you through deploying an TT20 smart contract on ThunderCore in 5 simple steps. It's super easy and fast!
Requirements
This tutorial expects you to have some basic knowledge of Truffle, Ethereum, Metamask and Solidity.
Install development tools
Please install the following:
Once we have those installed, we only need one command to install Truffle:
To verify that Truffle is installed properly, type truffle version on a terminal.
Install MetaMask
MetaMask is a browser extension that serves as a “wallet” that safely stores your cryptocurrencies such as Ether (ETH) and ThunderCore (TT). It also serves as a “bridge” that connects the web application with the blockchain. You can download and learn more about Metamask.
Get ThunderCore (TT) or ThunderCore Testnet Tokens to get started, you will need to get Thunder Token (Mainnet) or Thunder Testnet Token (Testnet) to deploy your smart contracts on ThunderCore. Please follow this instruction to get your tokens.
Steps in this tutorial we will be covering:
Cloning tt20 repository and installing dependencies
Updating config file of TT20 Token
Compiling and deploying the smart contract on ThunderCore
Transfering your TT20 to others
1. Cloning TT20 repository and installing dependencies
To make it easier to get started with ThunderCore, we've created a ERC20 contract, TT20. You can download the contract with git command. On a terminal, input the following command to download the repository
git clone https://github.com/thundercore/tt20
Next, we'll update the required dependencies for deploying the contract.
2. Updating config file of ERC20 Token
Since we've finished the contract already, the only thing we need to do is to update the config file config.json in tt20 folder. The config.json should look like the following:
Change these fields to whatever you want, for example:
Things to note:
The name and symbol fields give our token a unique identity.
The decimals field determines the degree to which this token can be subdivided.
The initialSupply field determines the number of tokens created when this contract is deployed. In this case, the number is arbitrary. Now, we have our own tokens!
3. Compiling and deploying the smart contract
In the migrations/2_deploy_contracts.js, we load the configuration from config.js of ERC20 and deploy the contract. Before we compile and deploy our own ERC20, we can setup a local chain. By using a local blockchain, we can test our contract without consuming real tokens. We recommend using Ganache. Refer to thundercore/ganache and build the Ganache GUI or using the CLI tool thundercore/ganache-cli with the following command.
After install the dependencies of ganache-cli, we can launch a local blockchain with the following command.
With our blockchain launched, run the following command to compile and deploy the contract
You will see output that looks similar to this:
Now, your MyToken
is deployed and mint to your first address in ganache.
With our blockchain launched, run the following command to compile and deploy the contract.
You will see output that looks similar to this:
Now, your MyToken is deployed and mint to your first address in ganache.
4. Deploy to the ThunderCore Testnet and Mainnet
Now, you can prepare to deploy your token to ThunderCore Testnet or Mainnet. Please make sure you have Thunder Testnet Token (TST) or Thunder Token (TT). First you set up the control of your account to truffle. You can set either by:
Write your 12-word mnemonic (seed phrase) to a file named .mnemonic
Export your account private keys, one per line, to a file named .private-keys
If you use metamask to control your address, you can check how to export the private key here. The address you used will be filled your
MyToken
.Compile and migrate your contract for Thunder Testnet and Thunder Mainnet
After deploying your own token,
totalSupply
will be added to your accounts. Check out MetaMask to see how to add custom token on MetaMask. The token contract address should be in the stdout after you executed the deployment command.
5. Transferring your ERC20 token to others
If you have already added MyToken to your MetaMask, try to send your tokens to other accounts. See more detail on MetaMask doc Note If you try on your local ganache, make sure to set the custom network to your localchain. For exmaple, set rpc url to http://localhost:9545 and chain id 5777. Then you can import private key from ganache to metamask or open a browser without MetaMask (such as incognito window) to see your tokens. Learning more about DApps It’s beyond the scope of this tutorial to go over the code, but if you’d like to learn more about smart contract programming and building DApps in general, we recommend the official Solidity documentation and truffle tutorial. For questions, please join to our Discord channel.
Happy Coding! 😆
Bridging your ERC20 Token to ThunderCore
For devs and projects with tokens deployed one or more chains, you may bridge your tokens over to ThunderCore via Multichain. Learn more by checking out their guide on bridging your ERC20 tokens!
Last updated