var img = document.createElement('img'); img.src = "https://terradocs.matomo.cloud//piwik.php?idsite=1&rec=1&url=https://docs.terra.money" + location.pathname; img.style = "border:0"; img.alt = "tracker"; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(img,s);
Skip to main content

Mint an NFT using Terrain

NFTs, or non-fungible tokens, are unique digital assets that can be showcased, bought, and sold on the blockchain. Purchasing an NFT gives you ownership over the unique digital creation, similar to buying a distinct painting or art piece.

In this tutorial, you will learn how to mint your own NFT using the NFT minting application and LocalTerra.

Prerequisites

📝LocalTerra requirements

This tutorial uses LocalTerra, which requires at least 16GB of RAM to run optimally.

1. Create your project

After installing all of the prerequisites listed above, use the following steps to set up your environment and clone the NFT minting repository, which contains the NFT minting smart contract and corresponding front end.

  1. Create and enter a new directory for your project.
terminal
Copy

_9
mkdir my-nft-project
_9
cd my-nft-project
_9
_9
_9
git clone --depth 1 https://github.com/terran6/nft-on-terra.git
_9
_9
_9
cd nft-on-terra
_9
npm install

  1. Clone the NFT on Terra repository to your project directory.
terminal
Copy

_9
mkdir my-nft-project
_9
cd my-nft-project
_9
_9
_9
git clone --depth 1 https://github.com/terran6/nft-on-terra.git
_9
_9
_9
cd nft-on-terra
_9
npm install

  1. Enter the cloned repository and run npm install to install all relevant Node dependencies.
terminal
Copy

_9
mkdir my-nft-project
_9
cd my-nft-project
_9
_9
_9
git clone --depth 1 https://github.com/terran6/nft-on-terra.git
_9
_9
_9
cd nft-on-terra
_9
npm install

  1. Create and enter a new directory for your project.
  1. Clone the NFT on Terra repository to your project directory.
  1. Enter the cloned repository and run npm install to install all relevant Node dependencies.
terminal
CopyExpandClose

_9
mkdir my-nft-project
_9
cd my-nft-project
_9
_9
_9
git clone --depth 1 https://github.com/terran6/nft-on-terra.git
_9
_9
_9
cd nft-on-terra
_9
npm install

After all the dependencies have been installed, you can close the terminal window.

2. Start LocalTerra

LocalTerra is a complete Terra testnet and ecosystem containerized with Docker. In this tutorial, you will use LocalTerra to simulate transactions in a local testing environment.

After installing LocalTerra and all of its dependencies, open a new terminal window and run the following commands.


_2
cd localterra
_2
docker-compose up

After starting LocalTerra successfully, you should start seeing simulated blockchain transactions.

3. Set up your wallet

In order to use your Station wallet with LocalTerra, you will need to configure your wallet to run on your LocalTerra network. The following steps walk you through importing one of LocalTerra's preconfigured wallets.

  1. Open the Station extension in your Google Chrome web browser. Click the gear icon in the upper right-hand corner and change the network from mainnet to localterra.

    Switch to LocalTerra
  2. Click on your wallet name in the upper left corner of the extension to enter the wallet manager.

    Manage wallets
  3. Click Add a wallet.

  4. Click Recover wallet.

    Recover Wallet
  5. Input the following LocalTerra seed phrase and wallet information into the form and click Submit.

Test-wallet-info
Copy

_2
Name: test1
_2
Password: testwallet

Mnemonic
Copy

_1
notice oak worry limit wrap speak medal online prefer cluster roof addict wrist behave treat actual wasp year salad speed social layer crew genius

Input Wallet

Now that you have successfully switched to the testing wallet on LocalTerra, you will be able to deploy your smart contract.

4. Update the instantiate message

Before you can deploy your contract and begin minting your NFT, you will need to change the config.terrain.json file in your cloned repository.

  1. In your Station extension, click on your test1 in the upper left corner. Click the copy symbol to copy the address.

    Switch Wallet
  1. Open the config.terrain.json file in a code editor and locate the instantiate message section.
config.terrain.json
Copy

_28
"instantiation": {
_28
"fee": {
_28
"gasLimit": 2000000,
_28
"amount": {
_28
"uluna": 1000000
_28
}
_28
},
_28
_28
"instantiateMsg": {
_28
"name":"NFT Collection Name",
_28
"symbol":"NFTSYMBOL",
_28
"minter":"terraxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
_28
}
_28
_28
}
_28
}
_28
},
_28
"mainnet": {
_28
"_connection": {
_28
"chainID": "phoenix-1",
_28
"URL": "https://lcd.terra.dev"
_28
}
_28
},
_28
"testnet": {
_28
"_connection": {
_28
"chainID": "pisco-1",
_28
"URL": "https://pisco-lcd.terra.dev"
_28
}

  1. Update the "name" and "symbol" fields with the desired name and symbol which will correspond to your NFT collection. The "minter" field should be updated with the wallet address of the collection owner, in this case it will be your test1 wallet address.
config.terrain.json
Copy

_28
"instantiation": {
_28
"fee": {
_28
"gasLimit": 2000000,
_28
"amount": {
_28
"uluna": 1000000
_28
}
_28
},
_28
_28
"instantiateMsg": {
_28
"name":"Cryptocurrency Token NFTs",
_28
"symbol":"TOKENS",
_28
"minter":"Paste your test1 wallet address here"
_28
}
_28
_28
}
_28
}
_28
},
_28
"mainnet": {
_28
"_connection": {
_28
"chainID": "phoenix-1",
_28
"URL": "https://lcd.terra.dev"
_28
}
_28
},
_28
"testnet": {
_28
"_connection": {
_28
"chainID": "pisco-1",
_28
"URL": "https://pisco-lcd.terra.dev"
_28
}

  1. Open the config.terrain.json file in a code editor and locate the instantiate message section.
  1. Update the "name" and "symbol" fields with the desired name and symbol which will correspond to your NFT collection. The "minter" field should be updated with the wallet address of the collection owner, in this case it will be your test1 wallet address.
config.terrain.json
CopyExpandClose

_28
"instantiation": {
_28
"fee": {
_28
"gasLimit": 2000000,
_28
"amount": {
_28
"uluna": 1000000
_28
}
_28
},
_28
_28
"instantiateMsg": {
_28
"name":"NFT Collection Name",
_28
"symbol":"NFTSYMBOL",
_28
"minter":"terraxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
_28
}
_28
_28
}
_28
}
_28
},
_28
"mainnet": {
_28
"_connection": {
_28
"chainID": "phoenix-1",
_28
"URL": "https://lcd.terra.dev"
_28
}
_28
},
_28
"testnet": {
_28
"_connection": {
_28
"chainID": "pisco-1",
_28
"URL": "https://pisco-lcd.terra.dev"
_28
}

💡tip

Be sure to double-check the parameter values in your instantiate message and save the changes to your config.terrain.json file before exiting.

5. Deploy your contract to LocalTerra

You are finally ready to deploy your contract and run the NFT minting application. Make sure you have installed Terrain before proceeding.

  1. Ensure you are still running LocalTerra in a separate terminal window.

  2. Open a new terminal window and run the following commands to navigate to your cloned repo and deploy your contract using Terrain.


    _2
    cd my-nft-project/nft-on-terra
    _2
    terrain deploy cw721-metadata-onchain --signer test1

6. Launch the app front end

Once the contract deployment has successfully completed, you can run the front end application to start minting your NFT.

  1. Change into the frontend directory and install the node dependencies.


    _2
    cd frontend
    _2
    npm install

  2. Start the front-end application:


    _1
    npm start

Your Chrome browser should open a new window and you should be viewing the front-end application at http://localhost:3000/.

  1. Station will ask you to Connect to the application. Click Connect.

    Connect to the NFT Minting Application
  2. Fill out all of the information on the form to mint your first NFT.

  • ID may be any value that you would like to correspond to the ID of the new NFT.

  • Enter the Name for your NFT.

  • The Owner Address is the wallet address which will be the owner of the newly minted NFT. In this tutorial, this will be your test1 wallet address.

  • Use the following URL for the NFT image of Luna used in this tutorial.


    _1
    https://assets.terra.money/icon/svg/LUNA.png

    NFT Minting Application
📝NFT hosting

Most NFT creators host their NFTs using IPFS (Interplanetary File System). There are a variety of resources available to post an NFT on IPFS, such as Pinata. In this example, the image used is available at https://assets.terra.money/icon/svg/LUNA.png.

7. Mint your NFT

Your NFT is ready to mint!

  1. Click Mint NFT. Your Station extension will pop up to request confirmation of the transaction.

  2. Click the Post Button.

After a few seconds, the front-end webpage will display your NFT.

Minted NFT

Congratulations!

You've just minted your first NFT on the Terra blockchain! If you have your own unique digital creation that you would like to share with the world, you can follow these instructions using the mainnet network and your personal Station wallet.

💡Mint NFTs on the mainnet

LocalTerra is not needed for deployments on the mainnet and is primarily used for local testing and development purposes.