Launching Your Own Game on Saga
Part 4: Launch your own NFT Exchange in minutes
Introduction
This blog post is the fourth 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. In crypto today, most games choose to launch on monolithic chains that 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, we’ll 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.
- Blog Post #2: 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.
- This Post: Deploy an NFT exchange for NFTs on your chain.
- Blog Post #5: Demonstrate the power of your own dedicated EVM chain, such as streaming data directly to your own chain.
In this post, we’ll discuss how to easily add an NFT exchange that can be used to trade unique digital collectibles on your chain. This can allow your end-users to trade or easily acquire in-game assets without the need for a trusted-third party.
Let’s dive in.
Step 1: Go to thirdweb.com and sign in with your Metamask account
Third Web — a Saga Innovator — provides best-in-class developer tools to build, manage and analyze web3 apps. Their tooling is open-source, decentralized, and permissionless. They have SDKs for both smart contract development and front-end management across a variety of programming languages such as TypeScript, Javascript, Python, React and Go. For the purpose of this tutorial we will be utilizing some of their pre-audited smart contracts to create a marketplace for the NFTs we minted in the previous post.
Go to https://thirdweb.com/explore, and click on ‘Marketplace’ (Buy and sell ERC721/ERC1155 tokens). Make sure to connect your ‘Metamask’ like we did in post #2.
Step 2: Deploy NFT minting contract to your Saga Chainlet
A marketplace is a contract where one can buy and sell NFTs, with some of the more popular ones in the world today being OpenSea, Blur or Rarible. The marketplace contract allows users to list NFTs for direct sale or auction, as well as make offers to buy unlisted NFTs. Other users can place offers/bids or buy NFTs for the specified amount in the listing, or auction. Users can even accept offers for their unlisted NFTs. The specific marketplace contract we’ll be interacting with can allow for the following functionality:
- Sell your NFTs on the marketplace
- Create auctions where the highest bidder, after a certain period, wins the NFT
- Makes offers on unlisted NFTs
- Creates an open marketplace where any user can list NFTs for sale, like OpenSea
On the right side of the page, click ‘Deploy Now’ to start the process of adding these smart-contracts to your chainlet.
Under ‘Advanced Configuration’, I have added in a platform fee of 2%. This will allow the primary issuer of this marketplace (me) to collect a commission on all NFTs trades that this smart contract enables. This can also be useful if one is deploying a contract to a third party and wants to take fees for this service. Fill out the rest of the details to your liking and then click ‘Deploy Now’ on the bottom right.
Once you click ‘Deploy Now’, you will be prompted to sign several transactions on MetaMask. Once this is done, you should be able to see that you have created this from the ThirdWeb website along with the address (0xB85B0A306b38678f11F2FAd8a56697A520403455)for the marketplace. This can also be independently verified from your block explorer.
Step 3: Create a direct listing for an NFT
Now that we have a marketplace to buy and sell NFTs, it’s time to use it to list an NFT for sale. For this author, he minted a few lightsaber NFTs from the last tutorial and will sell one of them on the marketplace now. Scroll down to ‘Direct Listings’ on the left side of the screen and click on ‘Create Direct Listing’ on the right hand side of the page.
After clicking on ‘direct listing’, fill in the rest of the details from the pop-up screen on the right. You can find the contract address for your NFTs from the NFT tab on your Metamask. For ‘listing currency’, we’ll use ‘SHAY’ as that is the gas-token for this chainlet. And for listing price, I will list these for 100 (100 SHAY tokens) as a price that others can buy any of these NFTs for. Alternatively, you can choose an ERC-20 token as the listing currency and utilize the ERC-20 token we created in the second blog post. Click ‘Create Direct Listing’ at the bottom-right of the screen and you will be prompted to sign a few more transactions on Metamask. Make sure to click on the NFTs from the list that you want to add to the marketplace.
And there you go! We have now created an NFT exchange that can be used to buy and sell any NFT created on your chain with a commission structure in place. You can go back to the marketplace dashboard and see your NFT is, in fact, listed. For more details on how to create a front-end for the NFTs on your chain, please click here for more information.
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, created an NFT exchange contract and used that exchange contract to list the NFTs we created in the previous tutorial.
In the next tutorial, we’ll discuss how to use your chain to deploy data. This data can include things like game-state, game events or any kind of information that would benefit from being open and accessible for your application!
To learn more about Saga’s approach to blockchain gaming, click here. Follow us on Twitter or join our Discord.