# 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&#x20;

{% embed url="<https://docs.hiro.so/tutorials/clarity-nft>" %}

## 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. Go to <https://explorer.stacks.co/sandbox/faucet?chain=testnet>​
2. Connect wallet

   <figure><img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F80OG0wKOPO2edA9QxQty%2Fuploads%2Fy1BDhinaQsqBpd3n0rs5%2Fimage.png?alt=media&#x26;token=80dea4df-4eb3-4cbe-bf37-e2e2ef2a25a2" alt=""><figcaption></figcaption></figure>
3. Select last option from the right list and press `Request STX`

   <figure><img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F80OG0wKOPO2edA9QxQty%2Fuploads%2FiQ8UCSdMW132n0Sdxk9P%2Fimage.png?alt=media&#x26;token=153d4b6d-d299-4928-b2bf-c1272440aa99" alt=""><figcaption></figcaption></figure>

#### **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

   <figure><img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F80OG0wKOPO2edA9QxQty%2Fuploads%2F0t8rnuLkWKD2BDkn9DLo%2Fimage.png?alt=media&#x26;token=9f29b95c-43e8-4e6b-8bdf-8023dd328410" alt=""><figcaption></figcaption></figure>
2. Paste the my-nft contract from the local project, rename contract name to `my-nft` press `Deploy` and confirm the transaction

   <figure><img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F80OG0wKOPO2edA9QxQty%2Fuploads%2FCRxfGaqLPDGXgKmcO3Hd%2Fimage.png?alt=media&#x26;token=05666bdd-f0fd-4f58-8dd0-4886b711684b" alt=""><figcaption></figcaption></figure>

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

#### **Mint NFTs using the sandbox**

1. Copy `my-nft` contract address

   <figure><img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F80OG0wKOPO2edA9QxQty%2Fuploads%2FMeO2zMyZxkNHswwe7Dno%2Fimage.png?alt=media&#x26;token=1f58066b-2320-4eee-9ce8-2bba582269ab" alt=""><figcaption></figcaption></figure>
2. Go back to sandbox, pick the second option from the right list and paste the contract name there

   <figure><img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F80OG0wKOPO2edA9QxQty%2Fuploads%2FpX8KK7L4qBbtXzUD6OQ7%2Fimage.png?alt=media&#x26;token=b53dfba0-ac60-454f-80e9-b1268b971f83" alt=""><figcaption></figcaption></figure>
3. Select `claim` and call the function

<figure><img src="https://1978961505-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9fITv8CMOKjvuITjMN1u%2Fuploads%2FmPxFLDJJT5PNJmh4Sw3c%2Fimage.png?alt=media&#x26;token=03cef06b-6ab2-404c-a7e0-0458669ab982" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1978961505-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9fITv8CMOKjvuITjMN1u%2Fuploads%2FQUOUdAFkJMt264JkOuMD%2Fimage.png?alt=media&#x26;token=524587bf-438b-474b-9842-3008c1369b83" alt=""><figcaption></figcaption></figure>
