Launching Your Own Game on Saga
Part 2: Launch your own token in minutes
This blog post is the second of a series designed to walk you through the steps of launching your own chain that can host its own game, whether the game is fully on-chain, meant to store gamestate in real time or only has in-game assets on chain. In crypto today, most games choose to launch on monolithic chains they do not control, where developers are limited by the design choices that are specific to that chain. But on Saga, where developers can launch their own chain, there is a far greater degree of flexibility, customizability and throughput that a developer can have access to. In this series, we’ll show you some of the basics of deploying your own chain on Saga while also demonstrating the unique things that one can do with Saga that isn’t possible in other ecosystems. Specifically, over the course of these blog posts, we will show you how you can:
- Blog Post #1: Launch your own EVM chain in minutes and connect it to its own block explorer, web-sockets and RPC endpoints.
- This Post: Connect and deploy pre-audited smart contracts directly onto your own chain such as an ERC-20 token contract.
- Blog Post #3: Deploy pre-compiled NFT minting contracts onto your own chain.
- Blog Post #4: Deploy an NFT exchange and build a tokenized in-game economy.
- Blog Post #5: Demonstrate the power of your own dedicated EVM chain, such as streaming live game events directly to your own chain.
In the first blog post, we discussed how to launch your own EVM-compatible chain on Saga in less than 10 minutes using the Saga CLI. In that tutorial, we also created a gas token specifically for our chain. While gas tokens can be abstracted away in future versions of our tech stack, they are required for usability today.
In this second post, we’ll discuss how to easily add an ERC-20 token to your chain that is customized to your preferences without touching a single line of Solidity code! ERC-20 tokens are useful as they can represent different aspects of an in-game economy, and have completely customizable value accrual mechanisms. ERC-20 tokens are separate from gas tokens as the former cannot typically be utilized for paying transactions fees. This tutorial coincides with the second half of the video that was referred to in the first blog post. For reference, we’ll be following along at this time-stamp.
Let’s dive in.
Step 1: Go to thirdweb.com and sign in with your Metamask account
Go to thirdweb.com/explore and click ‘Connect Wallet’ at the top right and choose ‘MetaMask’.
You may be asked to sign with your Metamask account in order to ‘log-in’ to their website. Once that is done, click on your Metamask and in the drop-down menu at the top left, you’ll see a list of chains to choose from. Make sure to choose your Saga Chainlet. For reference from the previous article, the name of my chain is ‘npcchain’ which is the one that I’ll be connecting from. Please refer to the previous blog for how to connect your Saga chain to your Metamask account.
Step 2: Prepare smart contract for deployment on Saga Chainlet
In this tutorial we will be creating and deploying a new token onto our Saga Chainlet. The token contract is suited for creating a digital currency and is compliant with the ERC20 standard. It can be purchased and traded between users on an exchange, utilized to buy and sell NFTs in a marketplace, etc. Let’s navigate over to https://thirdweb.com/thirdweb.eth/TokenERC20 and click ‘deploy’ at the top right. In the drop-down menu fill in the name of your coin, symbol and token image as you see fit. It can look something like this.
At the bottom of the menu, we have the option to select a network. Here we will not see your Saga chain as a test deployment, so we must click on ‘Add Custom Network’ to the bottom. Fill in the info for Network ID and Network name as you like and for Chain ID, be sure to put in the number that corresponds to the Chain ID for your Saga Chainlet and Currency symbol. You will also need to plug in your RPC end-point which you can find from running the following command in your cli:
command: sagacli Chainlet apis <chainId>
For this author’s chain, it will look something like this:
We now have a potential contract from Third Web that is ready to deploy onto our Saga chainlet.
Step 3: Deploy Contracts from Metamask
From here, we are now ready and should be able to now click ‘Deploy Now’ at the bottom left of the screen to deploy the contract.
It may take a few minutes or a few attempts at clicking ‘Deploy Now’ in order for the command to go through. Once it does, you will be asked to sign a series of Metamask transactions in order to deploy. The Metamask signings will look something like this:
As we can see from this tutorial, a ‘gas token’, i.e. the token created in part 1 of this series is required to pay for transactions on your Saga Chainlet. As we go through more of this tutorial, we’ll see that the gas required is variable according to the type of transactions. In future versions of our testnet and mainnet, there will be options to have a fixed transaction fee for all types of transactions and even a ‘zero-transaction fees’ for all transactions. The latter can help to greatly improve the UX of whatever kind of application is being built.
Step 4: Mint tokens via thirdweb to the token we just deployed
Now that we have created a new ERC-20 token contract and deployed it to our Saga Chainlet, it is time to mint new tokens from the contract! Click on ‘token tab’ and then click ‘+ mint’ to start the process.
From there, fill in the number of tokens you’d like to mint and then click on ‘Deploy Now’ in order to deploy the tokens to your chain. You will likely have to sign a few more transactions in Metamask.
Step 5: Confirm tokens that are in the wallet from Metamask and Block Explorer
Once you deploy the tokens, you should be able to find the ‘token address’ on the ThirdWeb website. Copy that token address and go to your Metamask account. Click on ‘Import Tokens’ as seen below. From there, paste the address in ‘Token contract address’ below and click ‘Add custom token’.
Once you do that, you should be able to see the tokens in your Metamask wallet. Feel free to also confirm the set of transactions from your block explorer as well!
Conclusion and Next Steps
So let’s summarize what we’ve done over the course of the tutorial. We have connected our Saga Chainlet to ThirdWeb’s infrastructure and then created a custom ERC-20 token. From there, we have deployed the token to our very own Chainlet by signing via Metamask and confirmed the existence of the token from our Metamask account!
In the next blog post, we will learn how to deploy more robust smart contracts onto our Chainlet and get started with building on-chain elements of a game.