Smart Contract NFTs

In order to integrate NFTs into a game, we need a smart contract for the NFTs. We'll create an NFT project locally, edit the NFT smart contract, fund the testnet account with STX and upload it there. The clarinet project should be created in the root folder of the cloned repository.

Create a basic NFT Smart Contract to integrate into the game

Follow Hiro NFT example

Edit smart contract

Rename MY-OWN-NFT to character

Change token-URI

from https://token.stacks.co/{id}.json to ipfs://QmNLo4oeN741Ai5PEafBnDtpXh2XMea8wBUGicTeErCtEB/{id}.json

Stacks Explorer

Faucet - request STX for the address

  1. Connect wallet

  2. Select last option from the right list and press Request STX

Deploy .nft-trait and .my-nft smart contracts on testnet

  1. Select first option from the right list, paste the nft-trait contract from the local project, rename contract name to nft-trait, press Deploy and confirm the transaction

  2. Paste the my-nft contract from the local project, rename contract name to my-nft press Deploy and confirm the transaction

Wait for the smart contracts to get confirmed on the anchor block

Mint NFTs using the sandbox

  1. Copy my-nft contract address

  2. Go back to sandbox, pick the second option from the right list and paste the contract name there

  3. Select claim and call the function

Last updated