How To Deploy Your Own NFT Collection on Fantom

Strange Brew
6 min readSep 27, 2021

--

Here at StrangeBrew we believe artists should be able to show off their work without the need for third parties or middlemen. This is why we decided to help get the word out about how fast and easy it is to deploy your own NFT contract and mint some NFTs on Fantom. This is what decentralization means; anyone can deploy a contract on the blockchain for a low gas cost, host their images and metadata for free, and distribute or sell as they see fit.

There is also a video you can follow along with here: https://vimeo.com/616333737.

Some things you need to get started:

  • Metamask connected to the Fantom network. https://docs.fantom.foundation/tutorials/set-up-metamask (If you need help)
  • Some Fantom for gas fees (2 should be more than enough)
  • A Pinata account. https://www.pinata.cloud/ (It’s free)
  • A web browser (we use chrome in this example)
  • A text editor (We use sublime text in this example, you can use notepad or textedit which come native with windows or macos. If you’re using linux we’re going to assume you’ve got this covered.)
  • An asset to turn in to an NFT. (My whole life savings is in JPEGs, they work great)

Step 1: Deploying the Smart Contract

First, open up the Remix development environment on your browser by navigating to http://remix.ethereum.org

It is important that you used http, not https. Your browser may warn you the connection is not secure, don’t worry about that. Make a new wallet for contract deployment if it will make you feel better.

Be sure you are on the Fantom network.

Navigate to Contracts and add a new contract.

Then copy and paste the Example contract from here:

https://docs.google.com/document/d/15_JljKnNxvaXcGaAN-D8UVK7gTWjNU80HXYyJ6dNw44/edit?usp=sharing

Here is a second option for a contract if you would like the option to change the token after the fact:

https://docs.google.com/document/d/1wY75m7uci9mhzyJj2EA2_116GUEpOzzMixfqdN8Htb0/edit?usp=sharing

The second contract has an option to edit the token URI after the fact. If you are comfortable with this option it can be very useful. Keep in mind this means the token can be changed after the fact and your holders will need to be comfortable with the fact that you can change it. This can also have benefits. For instance, if you need to change the hosting of the JSON and image to a different service, you have the ability to do that.

Here is another option for contracts, this has the function of changing the URI after the fact, and is also has the enumerable function.

https://docs.google.com/document/d/1Q_7mWa7k_LnmTNGk3uMMiCRamPln6Vr-UaG_hXoJQvo/edit?usp=sharing

This third contract will work with the new marketplace NFTKey allowing them to show rarity based on attributes. See below on adding attributes to the metadata.

In to the development environment. You should see the text of the contract on the right hand side.

The compiler page should look like this:

Now navigate to the Deploy page and select Injected Web3.

It should ask you to log in to Metamask when you make that selection.

Now choose a Name and Symbol for your token:

Push the transact button, the gas should be about 1 FTM. If it works correctly you can confirm the transaction and wait for the contract to deploy.

Once it’s confirmed, you can get to the contract address on ftmscan from your recent transactions in metamask.

Clicking here should take you to the ftmscan page for the contract.

Navigate to the Contracts tab and click Verify and Publish:

Select Solidity Single File as the file type:

Select the latest compiler, which Remix should have defaulted to:

No License, we don’t need anyone’s permission:

Then click Continue.

If it all worked correctly it should tell you the contract has been successfully verified. Now you can interact with the contract using ftmscan to mint your NFTs.

Step 2: Hosting the Asset and Metadata

In this example, we will be using Pinata. Head over to Pinata and upload your image file for the NFT.

Now that the image is being hosted, we can create the metadata for the NFT. Here’s a link to a file containing an example: https://docs.google.com/document/d/1LIdMTQh0uHX-OkWOuo2dgAOQoTB-30y-DwfWfrE2R5Q/edit?usp=sharing

Here it is for easy copy/paste:

{ "name": "Example", "description": "Description of Example", "image": "Link to image" }

NOTE: You must be sure the quotation marks are in plain text as shown above. If they are not, the NFT will not show up in your wallet properly. If you want to be sure that the JSON file is set up correctly you can use a JSON linter. Here is one: https://jsonlint.com/

*If you would like to add attributes for rarity, you can use this standard:

{
"description": "Description",
"image": "link to image",
"name": "name",
"attributes": [
{
"trait_type": "type",
"value": "value"
},
{
"trait_type": "type",
"value": "value"
},
]
},
}

Use as many trait types and value as you like. These can be used to calculate the rarity of a specific NFT.

Drop this in to a text editor (we are using sublime text but you can use wordpad or textedit) and add your own name, description, and the link to the picture you uploaded to pinata:

Save it as a .json file and upload it to pinata. The link to this file will be your token URI when you mint your token. Here is an example of the link for a URI we used for one of our projects along with a link to the image itself:

URI: https://gateway.pinata.cloud/ipfs/QmdSZVuTSrR1hoNSha2bi6CcXMjuFNpxXWVb2tpmhDeJX1

Image:

https://gateway.pinata.cloud/ipfs/QmWP7zVzsZxGfaxk1xv5oPbd3imEESrVaa4a9vGwiEs5BZ

Step 3: Mint the NFT

Now we have the contract deployed and the image and metadata hosted. It’s time to mint your NFT. Head back over to ftmscan and go to the write contract page for your minting contract. Connect your Metamask to ftmscan as follows:

Go to function 2 to mint, and enter your wallet address, a token number (pick one and if you plan on minting more than one you should avoid using the same number again), and the URI. The uri will be the link to the metadata json file you uploaded to pinata earlier.

Click Write and confirm the transaction. When the transaction confirms you should be able to see the minting activity on ftmscan like this:

Congratulations! You’ve minted your NFT. You can double check that the URI is correct in the Read Contract page, and add it to Metamask Mobile and double check that you can see the picture.

Artists should be free to create their content without needing to use a specific platform. We hope this helps to decentralize things and maintain the free flow of creativity we have been seeing on the Fantom network.

Cheers!

--

--

Strange Brew
Strange Brew

Written by Strange Brew

For those who enjoy having a pint.

Responses (7)