I’ve been working with blockchain technology for a long time, helping entrepreneurs around the world to launch their crypto exchanges and dApps. But, all these years, I never got a chance to contribute much to the open-source community. And here I go, my first article, here I share my knowledge and experience in reverse engineering the Openseas NFT marketplace platform.
NFTs or Non-fungible Tokens are trending these days. A lot of entrepreneurs want to ride the NFT wave, launch their own products and platforms embracing NFTs. So, I thought to decode the most popular NFT marketplace platform – Openseas, and reverse engineer it so that you’d get a better understanding of how such platforms work from an engineering standpoint.
For those who don’t know what an NFT marketplace is, it’s a digital platform that allows users to buy/sell digital or even physical assets. You can read more on the concept of NFTs in this article: what is an NFT?
Even though I have not directly worked on any NFT marketplace product, I was so much interested in finding out what was happening behind the scenes. So, I started investigating and tried to reverse-engineer the Openseas NFT Marketplace website. I started with testing Openseas APIs using Postman and figured out their XHR request and response structure. They were using GraphQL but for simplicity’s sake, we will be using a back-end with MySQL database in this article.
Thinking about what technology stack to use for developing your NFT marketplace? I’d recommend a tech stack with the following components.
-Ethereum Web3Js library
-ERC 1155 contract
So, let’s get started. An NFT marketplace would have 3 basic components.
1. A user connects their wallet to the NFT marketplace
2. A user creates an NFT marketplace token
3. A user creates a sell order or a buy order
A user needs to connect their wallet to the NFT marketplace to purchase an NFT. The connection is established between the user’s wallet and marketplace platform via web3js and metamask. One the connection is established, an address is returned, and it can be sent to the server and store in the marketplace database via an API. At the same time, an access token can be generated that can be used to authenticate other API calls. A pictorial representation of this process is given below.
Now let’s see how the NFT token creation works. First, you need to create an API for uploading digital files to the server. This can be music, video, images, etc. Once the file is uploaded into the back-end it’s further saved into the IPFS node from where a hash is returned that can be then sent back to the front-end. Then, the URL can be stored into the blockchain using ERC 721/1155 smart contracts which are interfaced into the front-end using ABI and Web3JS. Any functions inside the contracts can be invoked from the front-end.
The logic for creating a sell order is simple. When the user selects an NFT token they created and places a sell order, the NFT will be listed in an order book. The logic for a Buy order is a bit more complex. Here, once a user clicks on an already listed sell order they can send the Ethereum to the contract. The corresponding ID will be reassigned to the sender and finally, the back-end is notified that a buy order has been completed and verification is also done from the back-end on the transaction to prove the validity.
A user creates a sell order or a buy order
So that covers the basic 3 elements needed for the NFT marketplace. In this upcoming article, I’ll dive into different detailed technological and engineering aspects you should consider before launching your NFT marketplace.
This article was originally published by Shehin on his personal blog. View original article