Walt.id: Mint an NFT with Walt.id and Filebase
This guide was originally published on https://docs.filebase.com. Check out the Filebase documentation site for the latest Web3 tutorials using IPFS through Filebase.
Learn how to mint an NFT with Walt.id and Filebase.
What is Walt.id?
Walt.id is an open-source NFT infrastructure and digital identity product that provides pre-built ‘kits’ that can be used as a springboard for Web3 development. Kits offered by Walt.id include an SSI kit, a crypto wallet kit, and an NFT kit. This tutorial will showcase the NFT kit.
Read below to learn how to mint an NFT with Walt.id and Filebase.
Prerequisites:
- Sign up for a free Filebase account.
- Download and Install Docker and Docker-Compose.
- A cryptowallet, such as MetaMask.
- Have some Mumbai Testnet Currency.
- Have your Filebase Access and Secret Keys. Learn how to view your access keys here.
1. Start by cloning the Walt.id NFT Kit GitHub repository:
git clone https://github.com/walt-id/waltid-nftkit.git
2. Then, navigate into the project’s folder.
cd waltid-nftkit
3. Open the following file in a text editor:
./src/main/resources/walt-default.yaml
4. Replace the PRIVATE_KEY value with your crypto wallet’s private key, then save the file:
hikariDataSource:
jdbcUrl: jdbc:sqlite:data/walt.db
maximumPoolSize: 5
autoCommit: false
dataSource:
journalMode: WAL
fullColumnNames: false
azureKeyVaultConfig:
baseURL:
id:
secret:
providers:
ethereum: "ethereum"
goerli: "https://eth-goerli.g.alchemy.com/v2/e8No6Y2awTnVnf2tAgj-h-sImyCxzXpg"
polygon: "https://polygon-mainnet.g.alchemy.com/v2/yjbYhlaH3U_vfnTiRQ3miGQS0cKwQMkB"
mumbai: "https://polygon-mumbai.g.alchemy.com/v2/yjbYhlaH3U_vfnTiRQ3miGQS0cKwQMkB"
privateKey: "PRIVATE_KEY"
5. Next, build the docker container with the following command:
docker build -t nftkit .
6. Then, run the container:
docker run -p 7000:7000 -it nftkit
7. To mint NFTs, we need some images stored on IPFS.
To do this, navigate to console.filebase.com. If you don’t have an account already, sign up, then log in.
8. Select ‘Buckets’ from the left sidebar menu, or navigate to console.filebase.com/buckets.
Select ‘Create Bucket’ in the top right corner to create a new bucket for your NFTs.
9. Enter a bucket name and choose the IPFS storage network to create the bucket.
Bucket names must be unique across all Filebase users, be between 3 and 63 characters long, and can contain only lowercase characters, numbers, and dashes.
10. Now, upload your NFTs to Filebase using the web console and select ‘Folder’, then select the folder that contains your NFT files.
These files need to be named in sequential order, such as 0.png, 1.png, 2.png, etc.
11. You will see your folder uploaded as a single object:
12. Copy the CID of your folder:
13. Navigate to your IPFS Folder using the Filebase IPFS gateway to see your folder’s files:
https://ipfs.filebase.io/ipfs/IPFS_CID
14. Now it’s time to create the smart contract for our NFTs.
Use the following CURL command to deploy a smart contract on the Polygon Mumbai network:
curl -X POST http://0.0.0.0:7000/nftkit/nft/chain/MUMBAI/contract/deploy \\
-H "Content-Type: application/json" \\
-d '{"name":"Ticket","symbol":"TK","tokenStandard":"ERC721","accessControl":"OWNABLE","options":{"transferable":true,"burnable":true}}'
15. Copy the contract address that is returned from this CURL command.
16. To mint your NFT, use the following CURL command:
curl -X POST "http://0.0.0.0:7000/nftkit/nft/chain/MUMBAI/contract/CONTRACT_ADDRESS/token/mint" \\
-H "Content-Type: application/json" \\
-d '{"metadataUri":"","metadata":{"description":"NFT #1 Description","name":"NFT #1","image":"ipfs://CID/0.png","attributes":[{"trait_type":"Trait 1","value":"Value 1"}]},"recipientAddress":"WALLET_ADDRESS","metadataStorageType":"ON_CHAIN"}'
Replace the following values:
- CONTRACT_ADDRESS: The smart contract address you took note of in the previous step.
- CID: The IPFS folder CID you copied earlier.
- WALLET_ADDRESS: Your crypto wallet address.
17. Repeat the previous CURL command for each NFT you’d like to mint, changing the 0.png portion of the command to reflect 1.png, 2.png, etc.
18. To get information about your NFTs, you can use the following CURL command:
curl -X GET "http://0.0.0.0:7000/nftkit/nft/chain/MUMBAI/contract/CONTRACT_ADDRESS/token/1/metadata"
Replace the following value:
- CONTRACT_ADDRESS: The smart contract address used to mint your NFTs.
Want to learn more about Filebase? You can sign up for a free account today to get started with IPFS.