An NFT (Non-Fungible Token) is a type of digital asset that represents ownership or proof of authenticity of a unique item or piece of content, such as artwork, music, videos, and even tweets. Unlike fungible tokens, such as cryptocurrencies, which are interchangeable and have the same value, each NFT is unique and can have its own distinct value, based on its rarity, historical significance, or popularity. NFTs are typically stored on a blockchain, which provides a decentralized and tamper-proof record of ownership and transaction history. This makes NFTs an exciting new way for creators and collectors to monetize and trade digital assets, while also providing a new level of transparency and authenticity in the digital world.
In this tutorial, weโll walk through the steps of creating and deploying an NFT on Gnosis chain and storing its metadata and artwork on Swarm.
Before we get started, make sure you have the following prerequisites:
node = 16
- Swarm Desktop running a light node funded with some BZZ and XDAI
The first step to creating an NFT is to deploy an NFT contract on Gnosischain. Here's how to do it:The first step to creating an NFT is to deploy an NFT contract on Gnosischain. Here's how to do it:
Let's clone the NFT Example repository and install the packages
git clone https://github.com/rampall/nft-example.git
cd nft-example
npm install
Steps to deploy the NFT contract:
- Copy the contents of
.env.example
in the project root to a new.env
file :cp .env.example .env
- Create a new account in Metamask and fund it with a small amount of XDAI (XDAI 0.10 is enough) on Gnosischain, this will be your deployment account.
- In Metamask, click the three dots next to your account address, and select "Account Details" then "Export Private Key"
- Enter your password and then copy the private key into your
.env
file afterGNOSIS_PRIVATE_KEY=0x
(it should have a 0x prefix). - Deploy your contract using the following command:
npx hardhat run --network gnosis scripts/deploy.ts
- The NFT contract address should be printed in the output message. Copy and paste it into
.env
afterNFT_TOKEN_ADDRESS=0x
.
- Start up Swarm Desktop.
- Buy a postage stamp batch by following these steps. This should give you a Batch ID.
- Copy the Batch ID value into the
.env
afterPOSTAGE_BATCH_ID=
- Create another new account in Metamask and copy the address into
.env
afterNFT_TO_ADDRESS=0x
, this is the address that will receive your NFT. - Mint your NFT using the following command:
npx hardhat run --network gnosis scripts/mint.ts
- In Metamask, with your
NFT_TO_ADDRESS
account selected, select network 'Gnosis Chain', clickNFT
then scroll down and selectImport NFTs
. - Copy the NFT contract address from step 6 into the
Address
field and input0
as theToken ID
. - You should be able to see your own Beelon Musk NFT in your Metamask wallet, keep it, or send it to a friend!
- Replace
{{0x...}}
in this url with your contract address from step x and open the linkhttps://gnosis.nftscan.com/{{0x...}}/0
, you should bee able to see your Beelon Musk NFT on nftscan!
Congratulations ๐! You've successfully created an NFT and stored its metadata on Swarm. You can use this repo as a starting point to create collections of NFT's that store their data, decentralised, in the Swarm.