Skip to content

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

Section titled “Create a basic NFT Smart Contract to integrate into the game”

Follow Hiro NFT example

docs.hiro.so/tutorials/clarity-nft https://docs.hiro.so/tutorials/clarity-nft

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

  1. Go to https://explorer.stacks.co/sandbox/faucet?chain=testnet

  2. Connect wallet

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

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

Section titled “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

Section titled “Wait for the smart contracts to get confirmed on the anchor block”
  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