You'll probably need node version 16 or higher installed on your machine.
- After cloning the repo
yarn install
- CD into
client
and create a.env
(or.env.local
) file from.env.example
filling all required information. You can use the defaults when runnning locally. - From the root, build contracts:
yarn run build:server
. - Run locally both server and client by running
yarn run dev
from the root directory. - Import one of the 20 test account generated by Hardhat into your Metamask.
- https://ethereum.org/en/developers/tutorials/how-to-write-and-deploy-an-nft/
- https://docs.ipfs.io/how-to/mint-nfts-with-ipfs/#a-short-introduction-to-nfts
- https://docs.openzeppelin.com/contracts/4.x/erc721
- https://nft.storage/docs
- https://eips.ethereum.org/EIPS/eip-721
- https://eips.ethereum.org/EIPS/eip-1155
- https://blog.starton.io/deploy-your-nfts-on-blockchain-with-starton-ad7d4b2f9ea3
There exist several standards of smart contracts that have been developed for NFTs. The most famous ones are the ERC721 and the ERC1155.
The main big difference between the two is that in an ERC721, every NFT is unique which means you will have to reference the content for each of them.
Meanwhile the ERC1155 enables you to create “collections” which are several copies of the same NFT.
The ERC721, which is easier to use, still can be used to upload several copies of the same content, but is less optimised for this use case than the ERC1155.
For our use case, we will choose to use the ERC721. Starton proposes two templates for the ERC721 : the Auto-increment and the Custom Uri.
The Auto-Increment is preferable if the content of NFTs is stored on a centralised server.
It will use a static url like “https://test.com/“ and append the NFT id at the end to reference the content. For exemple “https://test.com/123“ will reference the 123th NFT that has been minted.
Of course, this is not very much in line with the decentralised philosophy as we could potentially change — or delete — the content associated to this id on our centralised server.
This is why we will upload the content on a decentralised file storage system like IPFS instead.
The process of minting a new NFT and sending it to an address goes in three steps:
With this method, we will need to specify a URI for each NFT we will mint, and thus we will need to use the ERC721 Custom Uri template.
We upload the content on IPFS (as it is too heavy to be stored on-chain) and get the CID of the content.
We upload a metadata object as a JSON file on IPFS as we do not reference the content directly in the contract. Instead, we put the CID of the content in a metadata object that we upload on IPFS.
We call the function “safeMint” of our smart contract, giving the CID of our metadata object and the address that will receive the NFT.