How to Deploy NFTs on OpenSea using Remix IDE - Polygon Blockchain - Part V
Tags: nft, blockchain, programming, python
Published: 2022-05-22 23:25:56

We ended the last tutorial by uploading the JSON folder of our NFT collection to Pinata. In this tutorial, we will be deploying our NFTs to OpenSea using Remix.

Go to [Remix - Ethereum IDE](https://remix.ethereum.org/#optimize=false&runs=200&evmVersion=null&version=soljson-v0.8.7+commit.e28d00a7.js)

Remix is an interface which allows us to interact with the blockchain by using smart contracts. This IDE will help us deploy our NFTs on OpenSea.

Make sure you open the link above using Google Chrome or any other browser that supports MetaMask since we will need to connect to it later.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nzo8gmgp0dwbzrhj9lni.png)

Rename the workspace with the name of your project.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2v3t2m6tljjxr07iwt1i.png)
 
Open the contracts folder and delete all the contracts there.

Right-click on the contracts folder and add a new file. Pick a name for the contract and make sure you add the .sol extension at the end of it.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ohbw34o7so8kh1p73ffn.png) 

This is going to be our Solidity contract which will allow us to deploy our NFTs.

Copy the code of the contract in this page: [NFT Contract](https://github.com/HashLips/hashlips_nft_contract/blob/main/contract/SimpleNft_flat.sol)

Open the contract in your workspace and paste the code from the contract on Github. Save the contract.

After you save the file, the folder tree on the left side will start populating with some JSON files. These files come from the contract which we just exported and are needed to deploy our contract on the blockchain.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c13subo09p6yk5rss65j.png)

Go to the end of the contract and delete the lines shown below.

As you can read in the comments, these lines pay Hashlips who is the one who created the contract a percentage of the initial sale, so if you want to support him, leave those lines in, if not, just delete them.

I have deleted the these lines because my NFT collection is just for teaching purposes. I'm not really trying to make money out of it.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7zfadphu66tjnw15geuy.png)

Let's start changing some things in the contract.

Go to **line 1235** and change **NFT** for the name of your contract, in my case the name is **MED**.

In **line 1240**, we will change **0.05** for the price that we want our NFT to cost. In my case, I will be deploying on Polygon, so I have to think in terms of MATIC and not Ethereum.

For example, if I put **10 ether** in the contract that means that minting one of my NFTs will cost 10 MATIC.

Assuming the price of MATIC at the time is $1.50 then the cost of my NFT will be: 

Cost to Mint one NFT = 10 MATIC * $1.50 = $15

Make sure you select the right price depending on which blockchain you plan to deploy. In my case, I will keep the price at **0.05 ether** because I will be deploying on the test network first.

In **line 1241**, we will add the maximum supply of our collection, so change **10000** for the amount of NFTs you have in your collection. 

In my case, I have 13 NFTs in my collection, so I put **13**.

If you have trouble finding out how many you have. You can open the **images** folder generated in the previous tutorials and count how many images you have.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pi8076dlo429bb51pqfs.png)

In **line 1242**, you want to pick how many NFTs a user can mint. Since I have only 13 NFTs, I will make **maxMintAmount = 1**. If you have a collection that has more than 10k NFTs then you can increase the maximum mint amount number to 10 or more.

In **line 1243**, you want to keep **paused = false**. If you change it to **paused = true**, you won't be able to mint until you unpause the contract. 

In **line 1244**, change **revealed = false**, to **revealed = true**, so that the NFTs will be revealed when minted. 

After changing the lines above, save the file. My values are shown below to provide an example, but make sure you change your contract based on what you want for your project.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bo0vi44pams1fgeoraki.png)
 
On the left side of the editor, click on the Solidity logo (the one with the green check mark).

Check off the **Auto compile** and **Enable optimization** boxes.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oiplxeukufx0mrsu8ubf.png)

As mentioned before, you will need MetaMask to deploy your contract.

You need to do the following things before continuing with the tutorial.

- Install [Metamask](https://metamask.io) (Chrome Extension Recommended)

- Add [Rinkeby Test Network](https://gist.github.com/tschubotz/8047d13a2d2ac8b2a9faa3a74970c7ef) to MetaMask and get some Rinkeby Ethereum (This is fake Ethereum used only for testing purposes)

- Add [Polygon Network ](https://docs.polygon.technology/docs/develop/metamask/config-polygon-on-metamask/)to Metamask

We will be deploying on the Rinkeby Test network first and then on the Polygon network, that's why we need to add both networks.

## Deploying on Rinkeby Test Network

The Rinkeby test network will allow us to test the contract first to help us find any errors. It's always recommended to deploy on the test network before doing it on the real network.

Go back to Remix and click on the Ethereum logo on the left side of the editor and change the following.

For **Environment**, select the **Injected Web3** option. Once you click on it, you will be asked to sign in to Metamask.

Make sure you have the **Rinkeby (4) network** shown under environment.

For **Contract**, select the name of your contract. In my case, **MED.sol**.

Finally, click on the arrow next to **Deploy** to open the drop-down menu. 
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b0ldw8bajlokk8s235zq.png)

In the **Deploy** section, fill out the fields as shown below.

**_NAME:** MED (contract name or collection name)
**_SYMBOL:** MED (contract name or collection name)
**_INITBASEURI:** ipfs://"CID FROM JSON FOLDER on PINATA"/
**_INITNOTREVEALEDURI:** ipfs://"CID FROM JSON FOLDER on PINATA"/

For testing purposes, we are going to make **_INITBASEURI** the same as **_INITNOTREVEALEDURI**.

To find the CID of your collection, go to Pinata and copy the CID from the JSON folder.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eehxqvwmvdn9t4cknwm1.png)

Click on the icon next to transact to copy the bytecode of the contract.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hl510qf8z1z33nvc1h5b.png) 

Create a document or text file on your computer to save some important information about the contract. We will need this information later to verify the contract after deployed. 

In my case, I created a new folder in the main project folder of Visual Studio, and inside this folder I created a file to save my contract's information.

Paste your contract's bytecode into your info file.

Copy the code of your contract in Remix and paste it into the info file as well.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kw86tcppafstgogyepik.png) 

Finally, go back to Remix and double check that you are deploying on the Rinkeby test network.

Also, make sure that you have enough fake ethereum to pay for the transactions.

Click on **Transact** to deploy the contract.

Once you do this, MetaMask will ask you to sign on the transaction. 

After you approve the transaction and pay the fee to deploy the contract, you should see a message on the terminal window at the bottom of Remix showing a successful message if the contract was deployed correctly.

Alternatively, you can find the deployed contract on the left side of the editor. 

Copy the contract address and paste it into your info file as well. 

Click on the arrow next to the contract address to open the drop-down menu of the contract.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u89xdequp39rg1qzv1ns.png)
 
This menu works as a control panel and allows us to interact with the contract directly. We can use this panel to mint NFTs, pause the contract, change prices, and more.

Click on the arrow next to the **mint** button to start minting. Enter 1 to mint one NFT. Remember that our contract only allows us to mint one NFT at a time, so if you put any number other than 1, you will get an error.

Click on **transact** to mint.

You will be taken to MetaMask once again to pay for the minting.

After you confirm the transaction, you should see a message at the bottom of Remix indicating if the NFT was minted or not.

You can also check the status of the transactions on Metamask.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cnf65xpsnvzdkbv0lwhm.png)

Since we deployed our contract on the **Rinkeby Test network**, we have to go to [OpenSea Testnets](https://testnets.opensea.io) to see the collection and the NFT that was minted.

Once on OpenSea Testnets, go to **Profile > My collections**. You should see a new collection with only one NFT.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iwrb295rrhhs89dw931n.png)
 
Click on the NFT to see more information about it. In that page, you can see the name, description, properties of the NFT, and more. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vchyonm4t7jhnfbsp76c.png)
 
If you deployed successfully on the Rinkeby test network, you can be confident that you won't have any problems with your contract when deploying on the main networks.

## Deploying on Ethereum Network

If you want to deploy on Ethereum you will follow the same steps, but you have to make sure that you go to MetaMask and select the Ethereum network before deploying the contract.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/13qm1ec7mtcdex9zjdpw.png)

On Remix, you should see under environment, the Ethereum network which is **Main(1) network**.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/utnyv8kywljkf40zngxf.png)

## Deploying on Polygon Network
 
If you want to deploy on Polygon you will follow the same steps, but you have to make sure that you go to MetaMask and select the Polygon network before deploying the contract.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jik4rb9lanoevtr57fca.png)

On Remix, you should see under environment, the Polygon network which is **Custom(137) network**.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rhllp0alx7y6sr5x96m2.png)
 
## Verify and Publish

There is one last thing that we have to take care of after deploying our contract. We need to verify and publish our contract, so that other people can access it and interact with it.

Since I deployed the contract on the Rinkeby Test network, I will go to [Rinkeby Testnet Blockchain Explorer](https://rinkeby.etherscan.io).

If you deployed on the Ethereum network, go to [Ethereum Blockchain Explorer](https://etherscan.io).

If you deployed on the Polygon network, go to [Polygon Blockchain Explorer](https://polygonscan.com).

The steps that follow are the same regardless of the network on which you deployed. 

Go to your info file, and copy the contract address.

Paste the contract address into the bar and search.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jhal7xvu1alnm8ckxu0g.png)
 
The next page shows a summary of the contract you just deployed.

Click on **Contract > Verify and Publish**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zrqi82ewb9iwxsm8eqh5.png)

In this page, the contract field will show your contract address.

For the rest of the fields, select the options below.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6yuze8e31l6hg1ylb1jr.png)
 
For **Compiler Type**, select **Solidity (Single file)**.

We select single file because we used only one solidity file.

For **Compiler version**, you can find the version by going to **Remix > Solidity Compiler**.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fg96rlbozr43l0qh1lwa.png)
 
For **Open Source License Type**, you can find the license in the very first line of the code of your contract.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g6i9gmci47lof2m4btzh.png)

Click on **Continue**

In this page, we will use the information in our info file. 

For **Optimization**, select **Yes**.

Copy the Solidity contract code from the info file and paste it into the contract code section.

Delete the existing bytecode from the **Constructor Arguments ABI-encoded** section.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/psg5xzpqcbjkbebltwrg.png)

Go to the info file, and look for the bytecode of your contract.

Go to the last lines of the bytecode and select everything after the last number that's not zero (copy from where the file starts going all zeroes) until the end.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rhfdvr1sbt1vo0u86zh8.png) 

Copy this part of the bytecode from the info file and paste it into the **Constructor Arguments ABI-encoded** section.

Click on **Verify and Publish**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uykkyhxgqyk3ordw233f.png)
 
After your contract has been verified, it will show a green checkmark next to it. 

Click on **Write Contact** and connect your wallet.

Go to the minting section and complete the fields which include the price and the amount to be minted which has to be 1 since the contract allows us to mint only one NFT at a time. 

Click on **Write** and confirm the transaction on MetaMask to mint the NFT.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hyzd7t24td687yzfjdh5.png)
 
Finally, go to you collection on OpenSea Testnets to see the new NFT. You should have a total of two NFTs now.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wrk25fh7r4tnwp127sjc.png)

There are a lot of steps to mint one NFT, so to make it easier and more intuitive for users, we will create a Minting Dapp, so that users can mint our NFTs easily.

If you believe this tutorial was helpful, please consider [subscribing](https://www.youtube.com/channel/UChZR16e1XwZXy2yrk_8ymFg/?sub_confirmation=1) to my YouTube channel.

The whole series has been already released on Youtube in case you want to check it out.

I'll be releasing the next post once we reach 100 subs on Youtube. Let's get it.

**Youtube:**

{% youtube uPGEoIeqPYs%}

**Twitter:**

[balt1794](https://twitter.com/balt1794)

**OpenSea**

[MEDYC Collection](https://opensea.io/collection/much-exclusive-doge-yacht-club)