< Back to Blog

How In Writing Built a Decentralized Marketplace

Decentralization is what the blockchain and Web3 are all about, so why do people sell digital assets on centralized websites like OpenSea? NFT project In Writing has implemented its own decentralized marketplace specifically so users can buy and sell In Writing NFTs as long as the blockchain exists.

Some background on In Writing

In Writing is a text based NFT project, which features on chain storage of strings (text), including unicode characters, as NFTs. With all of its data stored on-chain, In Writing aims to be fully autonomous with no reliance on off-chain websites or servers. Having a decentralized marketplace coded into the In Writing smart contract aligns with their vision, as it provides users a means of buying and selling NFTs without relying on external services.

Article graphic for how in writing built a decentralized marketplace

In Writing's home page, where you can mint your own text-based NFT!

How can you sell an NFT on In Writing?

There are two ways to sell an NFT on In Writing: list_for_sale and mint_and_list_NFT. These are the two functions that can list an NFT for sale.

To use the mint_and_list_NFT function can be used by navigating to the “write” tab on In Writing’s website, typing in the text of the NFT you’d like to sell, checking the box that says “List for sale,” filling in the price you’d like to sell it for, and completing the transaction. By doing this you have first minted the text, and immediately listed it for sale on the decentralized marketplace!

The list_for_sale function can only be used for NFTs that you already own. You can use this function by navigating to the NFT you want to sell, clicking “List for sale,” entering the price you’d like to sell it for, and confirm the transaction. Now your NFT is up for sale on the decentralized marketplace!

When your NFT is bought it will automatically be transferred out of your wallet, and your earnings will be deposited into your wallet! Here is a transaction on Polygonscan showing the process.

How does the decentralized marketplace work in the code?

The In Writing NFT smart contract implements a modified version of the ERC721 token standard. This modified token standard has functions for buying and selling NFT tokens, which are kept track of in mappings (these are like python dictionaries). When a token is listed for sale, it is added to the mapping. When a token is bought or removed from the marketplace, it is removed from the mapping. These additions to the ERC721 token standard make In Writing’s decentralized marketplace work from a code standpoint.

Why is a decentralized marketplace better?

Decentralized market places are better than centralized marketplaces because there is no 3rd party needed for a transaction to take place. Most NFT sales happen needing OpenSea or some other third party to help moderate the transaction, and make sure both parties get what was agreed upon in the transaction. This comes at the cost of a commission fee, where both parties lose money on the transaction. At the time of writing, OpenSea charges a commission fee of 2.5%, which can be costly on big transactions, while In Writing has no commission fees (besides gas) at the time of writing for buying and selling on their decentralized marketplace.

Are there any cons to a decentralized marketplace?

Well… yes. A decentralized marketplace relies on computation rather than a third party to moderate transactions, and this costs gas on the Polygon blockchain. Gas prices are on the decline, but it’s unknown how low they will go. Listing on In Writing costs about 53,000 gas, while buying costs about 76,000 gas. For reference, transferring ether or MATIC costs 21,000 gas.


Decentralized marketplaces emphasize longevity, and In Writing is doing exactly that with the creation of their on-chain NFT and implementation of their own decentralized marketplace. Although it might be more expensive than a transaction on OpenSea with current gas prices, that may not always be the case. In the absence of OpenSea sometime in the future, In Writing provides a marketplace that will last as long as the Polygon blockchain itself.

< Back to Blog