Add Energi Testnet Network to MetaMask by going to https://chainlist.org.
Create an account on https://replit.com.
Fork the following Replit
https://replit.com/@smartNFTs/ai-generated-nftCreate an account on Hugging Face. Visit your profile settings, and create a read access token.
Create an account on NFT.Storage, and then create a new API key.
On your Replit, go to "Shell and run the following command:
cp .env.example .env
Open Secrets from "Tools". Update the following variables with your information. This will stay secure and cannot be copied when your Replit is forked by someone.
- ACCOUNT_PRIVATE_KEY"" - Get the private key for your owner account from MetaMask
- REACT_APP_HUGGING_FACE_API_KEY"" - Populate the API from step 3 above
- REACT_APP_NFT_STORAGE_API_KEY - Populate the API from step 3 above. Do not put any quotes around the API
Edit lines 4, 5 and 6 of scripts/deploy.js:
const NAME = "AI Generated NFT"
const SYMBOL = "AINFT"
const COST = ethers.utils.parseUnits("1", "ether") // 1 NRG
- NAME - Name of collection as you want it to appear on the Marketplace
- SYMBOL - Token Symbol of your collection
- COST - Minting cost
Edit scripts/constructor-arg.js.
module.exports = [
"AI Generated NFT",
"AINFT",
"1"
];
The entires should match the information set in scripts/deploy.js in step 5.1 above.
To add some test NRG (tNRG) to your wallet, go to the Energi Testnet Faucet and request some tNRG be added to your account. Use the same account you generated the private key for on MetaMask.
Close your "Shell" windows. From "Tools" on the left navigation pane, select "Shell". Run the following command to deploy a smart contract on Energi Testnet.
npx hardhat run ./scripts/deploy.js --network energiTestnet
Output:
Downloading compiler 0.8.17
Compiled 13 Solidity files successfully
Deployed NFT Contract at: 0x09f0eB0b32367821d06D53644081bbbdbB16e68a
SKIP FOR NOW - NEED TO RESOLVE ISSUE ON VERIFICATION.
Open Block Explorer - Testnet. Check if the smart contract has been created on the Energi Testnet.
Run the following command to verify the smart contract (replace <contract_address> with your smart contract.)
npx hardhat verify <contract_address> --constructor-args ./scripts/constructor-arg.js
npx hardhat verify 0x09f0eB0b32367821d06D53644081bbbdbB16e68a --constructor-args ./scripts/constructor-arg.jsNothing to compile
Compiling 1 file with 0.8.17
Successfully submitted source code for contract
contracts/NFT.sol:NFT at 0x09f0eB0b32367821d06D53644081bbbdbB16e68a
for verification on the block explorer. Waiting for verification result...
Successfully verified contract Foo on Etherscan.
https://explorer.test.energi.network/address/0x5A106e0E52B0F60101BAeBC255c1E5d5D9fA0ABd/contracts
Put the contract address on line 4 of src/config.json
{
"49797": {
"nft": {
"address": "0x09f0eB0b32367821d06D53644081bbbdbB16e68a"
}
}
}
On the "Shell" window, run the following to start the web application:
npm run start
A "Webview" window will pop up. Click on the right icon which will say "Open in a new tab" when you hover over it.
- 9.1. Connect your Owner Wallet
- 9.2. Give a
namefor the image - 9.3. Add a
descriptionto your NFT. The AI NFT Generator will take the description and create an NFT. - 9.4. Click "Create & Mint" to generate an NFT using the AI, post the NFT to IPFS and mint it on the Energi Blockchain. You will have to pay the minting cost.
Once minted the image of the NFT will appear on the box to the right. Go to GMI Testnet Marketplace to view your collection.
Have fun with your NFTs!
Any contribution is appreciated. Please send ETH (on the Ethereum chain) or NRG (on the Energi chain) to the following account:
0x3E9764ee008697849292511d278E8a05e1Fbba27
For details on how the code works, view the following YouTube video:


