• Homepage •
Supported protocols •
Chainstack blog •
Chainstack docs •
Blockchain API reference •
• Start for free •
This project contains all tutorial files from the How to mint a generative music NFT with Chainstack IPFS Storage and Soundraw tutorial, originally published on the Chainstack Developer Portal: Web3 [De]Coded.
This repository contains scripts and contracts needed to create a new wallet, check its balance, compile an NFT contract, and mint music NFTs using generated metadata on the Ethereum network with Chainstack IPFS Storage, Soundraw, Hardhat and Web3js.
- Chainstack endpoint
- Soundraw API token
- Dotenv
- Hardhat with Web3js
- OpenZeppelin contracts
- Axios
- Form data
- Canvas
- Image data URI
- Jdenticon
- Merge images
- Random words
- Text-to-image
- Clone or fork this repo to a preferred location by running in CLI:
git clone https://github.com/chainstacklabs/generative-ai-music-nft-javascript.git
- Install dependencies by running in CLI:
npm ci
- Rename
.env.sample
to.env
and fill in your endpoint URLs for each network, then your Chainstack and Etherscan API keys:
GOERLI="https://your-goerli-endpoint-here"
SEPOLIA="https://your-sepolia-endpoint-here"
MAINNET="https://your-mainnet-endpoint-here"
CHAINSTACK="Bearer y0urChainstackAPIkeyHer3"
ETHERSCAN="Y0URETHERSCANAPIKEYHER3"
SOUNDRAW="Bearer Y0urSoundrawAPIt0k3nHere=="
- Generate a new wallet address key pair and fund it from the Chainstack $NETWORK faucet by running in CLI:
npx hardhat run scripts/wallet.js --network $NETWORK
- Check wallet balance by running in CLI:
npx hardhat run scripts/balance.js --network $NETWORK
- Deploy the NFT minter smart contract from the ABI & BIN files by running in CLI:
npx hardhat run scripts/deploy.js --network $NETWORK
- Generate all media files and JSON metadata with Soundraw and other libraries by running in CLI:
npx hardhat run scripts/generate.js
- Pin all media files and JSON metadata with Chainstack IPFS Storage by running in CLI:
npx hardhat run scripts/pin.js
- Mint an NFT with the metadata from the pinned JSON file by running in CLI:
npx hardhat run scripts/mint.js --network $NETWORK
- .env.sample - Sample Dotenv file containing pre-formatted slots needed for key script variables
- contracts/MyFirstMusicNFT.sol - Smart contract supporting functions to mint NFTs with custom tokenURI
- src/ - Sample media files and metadata JSON you can use to test minting
- scripts/wallet.js - Script to generate a wallet address and key pair
- scripts/balance.js - Script to check the balance of a wallet address
- scripts/deploy.js - Script to deploy the NFT minter smart contract from the ABI & BIN files
- scripts/generate.js - Script to generate media files and metadata for the NFTs
- scripts/pin.js - Script to pin relevant media files and JSON metadata with Chainstack IPFS Storage
- scripts/mint.js - Script to mint an NFT with the metadata from pinned JSON metadata file