Create our own Beelon Musk NFT!
This is an extremely simple NFT example project. It deploys an NFT contract and mints one NFT where the data is stored on Swarm.
It is intended as an easy example for you to enjoy that can then be built upon to create collections of NFT's that store their data, decentralised, in the Swarm.
Use node > 16.
npm i
First try it out locally. Spend some time examining the scripts to understand what's going on.
- Start up a local hardhat development blockchain
npx hardhat node
- Deploy your contract
npx hardhat run --network localhost scripts/deploy.ts
- The NFT contract address should be output, copy and paste it into
mint.ts
asTOKEN_ADDRESS
. - Run a local bee development environment
bee dev
- Buy a stamp
swarm-cli stamp buy --depth 20 --amount 10000000000
- Copy the Stamp ID into
mint.ts
asPOSTAGE_BATCH_ID
- Create a new account in Metamask and copy the address into
mint.ts
asTO_ADDRESS
, this is the address that will receive your NFT. - Mint your NFT
npx hardhat run --network localhost scripts/mint.ts
- In Metamask, with your
TO_ADDRESS
account selected, select network 'Gnosis Chain', clickNFT
then scroll down and selectImport NFTs
. - Copy the NFT contract address from step x into the
Address
field and input0
as theToken ID
. - You should be able to see your Test NFT in your Metamask wallet!
Now, let's deploy your NFT on a real blockchain!
First, remember to turn off bee dev
and your local hardhat development blockchain!
- Comment out the 'dev constants' and uncomment the 'prod constants'.
- 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"
- Create a new file in the root directory of this project called
.env
and copy the contents from the.env.example
file. - Enter your password and then copy the private key into your
.env
file afterGNOSIS_PRIVATE_KEY=
(it should have a 0x prefix). - Deploy your contract
npx hardhat run --network gnosis scripts/deploy.ts
- Start up Swarm Desktop.
- Buy a stamp
swarm-cli stamp buy --depth 20 --amount 10000000000
- Copy the Stamp ID into
mint.ts
asPOSTAGE_BATCH_ID
- The NFT contract address should be output, copy and paste it into
mint.ts
asTOKEN_ADDRESS
. - Create another new account in Metamask and copy the address into
mint.ts
asTO_ADDRESS
, this is the address that will receive your NFT. - Mint your NFT
npx hardhat run --network gnosis scripts/mint.ts
. - In Metamask, with your
TO_ADDRESS
account selected, select network 'Gnosis Chain', clickNFT
then scroll down and selectImport NFTs
. - Copy the NFT contract address from step x into the
Address
field and input0
as theToken ID
. - You should be able to see your Test 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 NFT on nftscan!