Tutorials

How to Create an NFT and store metadata on Swarm

This article provides a comprehensive guide on deploying, minting, and importing NFTs on the Swarm Network.

TL;DR: This article provides step-by-step instructions on how to deploy, mint and import an NFT using Hardhat, Swarm Desktop App and Metamask. You will learn how to deploy an NFT contract on Gnosis, mint an NFT to your wallet address, store the NFT image and metadata on Swarm, and import your NFT in Metamask. The NFT example repo used in this article is intended to serve as an easy reference that can then be built upon to create collections of NFTs that store their data, decentralised, in the Swarm.

On NFTs

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 decentralised and tamper-proof record of ownership and transaction history. This makes NFTs an exciting new way for creators and collectors to monetise and trade digital assets, while also providing a new level of transparency and authenticity in the digital world.

image

Prerequisites

Before we get started, make sure you have the following prerequisites:

Deploying an NFT Contract on Gnosis

The first step to creating an NFT is to deploy an NFT contract on Gnosischain. Here's how to do it:

Clone repository and install packages

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

Deploy NFT contract

Steps to deploy the NFT contract:

  1. Copy the contents of .env.example in the project root to a new .env file : cp .env.example .env
  2. 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.
  3. In Metamask, click the three dots next to your account address and select "Account Details", then "Export Private Key".
  4. Enter your password and then copy the private key into your .env file after GNOSIS_PRIVATE_KEY=0x (it should have an 0x prefix).
  5. Deploy your contract using the following command: npx hardhat run --network gnosis scripts/deploy.ts
  6. The NFT contract address should be printed in the output message. Copy and paste it into .env after NFT_TOKEN_ADDRESS=0x.

Mint NFT

  1. Start up Swarm Desktop.
  2. Buy a postage stamp batch by following these steps. This should give you a Batch ID.
  3. Copy the Batch ID value into the .env after POSTAGE_BATCH_ID=
  4. Create another new account in Metamask and copy the address into .env after NFT_TO_ADDRESS=0x; this is the address that will receive your NFT.
  5. Mint your NFT using the following command: npx hardhat run --network gnosis scripts/mint.ts

Import NFT

  1. In Metamask, with your NFT_TO_ADDRESS account selected, select network 'Gnosis Chain', click NFT then scroll down and select Import NFTs.
  2. Copy the NFT contract address from step 6 into the Address field and input 0 as the Token ID.
  3. You should be able to see your own Beelon Musk NFT in your Metamask wallet; keep it or send it to a friend!
  4. Replace {{0x...}} in this url with your contract address from step x and open the link https://gnosis.nftscan.com/{{0x...}}/0. You should be able to see your Beelon Musk NFT on nftscan!

Metamask with NFT Metadata on Swarm

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 NFTs that store their data, decentralised, in the Swarm.

References

Read more

TutorialsBee Node Hardware Requirements and Performance Benchmarking GuideOver the last several months the Bee dev team has been hard at work with the rollout of the storage incentives system which will ensure that node operators who share their disk space with the network will get rewarded. Along the way the dev team has been continually testing various aspects of the health of the network and monitoring community feedback in order to diagnose any issues. One issue which has come up is that of node performance. Some node operators may be missing out on earning storage incentives due to insufficient hardware performance. To address this issue, we’ve put together this guide for benchmarking node performance so node operators can make sure that their nodes are running optimally.TutorialsBuild on Swarm: How to Run a Bee Node for Testing and DevelopmentRunning a Bee node is essential for building decentralised applications on the Swarm network. However, as a developer, it is often convenient to work in an environment where interactions with the node/network can be tested rapidly and without putting the node’s storage data or the user’s tokens at risk.TutorialsHow to Publish a Website on Swarm Using the Swarm Desktop App: A Step-by-Step GuideTL;DR: This guide will walk you through the process of publishing a website on Swarm using the Swarm Desktop App. You’ll learn how to install the app, fund your account, upload your website, and connect an ENS domain for a user-friendly experience. By following these steps, you’ll be able to host a censorship-resistant website on decentralised storage and make it easily accessible for users.Tutorials — IndexAll tutorials