Date: 2025-03-25
Network: Polygon Amoy Testnet
Tooling: Foundry, Web3.Storage, OpenSea, IPFS, cast
This devlog documents the full process of deploying a smart contract called TopSecurityNFT to the Polygon Amoy testnet. The NFT images and metadata were hosted on IPFS using Web3.Storage.
TopSecurityNFT smart contract1 to the deployer’s walletcast for
minting.gitignore to keep keys and cache
private{
"name": "Aurora's Echo",
"description": "A feathered traveler bathed in the hues of dawn...",
"image": "ipfs://<imageCID>/painting_01.png"
}bafybeic2f7dtbhcph4q72ja4avhesovmhmbdmpjtc45brtwbqyfroqsr3ytokenURI:ipfs://bafy.../metadata1.jsonTopSecurityNFT.solERC721URIStorage and
OwnableinitialOwnerbaseURI + token ID to generate
tokenURIfunction tokenURI(uint256 tokenId) public view override returns (string memory) {
return string(abi.encodePacked(baseURI, "metadata", Strings.toString(tokenId), ".json"));
}
.envDEPLOYER_ADDRESS=0xYourAddressHere
PRIVATE_KEY=your_private_key_here
script/Deploy.s.solcontract Deploy is Script {
function run() external {
address initialOwner = vm.envAddress("DEPLOYER_ADDRESS");
vm.startBroadcast();
new TopSecurityNFT(initialOwner);
vm.stopBroadcast();
}
}
forge script script/Deploy.s.sol:Deploy \
--rpc-url https://rpc-amoy.polygon.technology \
--broadcast \
--legacy \
--sender $DEPLOYER_ADDRESS \
--private-key $PRIVATE_KEY0xE85f1711AbFb46b43220521a67519ae28c0c56fAcast send \
--rpc-url https://rpc-amoy.polygon.technology \
--private-key $PRIVATE_KEY \
0xE85f1711AbFb46b43220521a67519ae28c0c56fA \
"mintNFT(address)" 0xYourAddressHereTransaction Hash:
https://amoy.polygonscan.com/tx/0x3ada70455ff57e84b762dc4eaf5554fd967e69ccc81d20d9e5d8a81d9f09fb72
Link:
https://testnets.opensea.io/assets/amoy/0xE85f1711AbFb46b43220521a67519ae28c0c56fA/1
Note: IPFS images may take a few minutes to appear while OpenSea indexes metadata.
Created .gitignore in project root
(~/main/blockchain/metaverse-sandbox/blockchain/):
.env
broadcast/
cache/
out/
foundry.toml.lock
Paused development to be MOMMY. The contract is fully deployed, NFT minted, and metadata hosted on IPFS.
End of session.