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
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.
Rename the workspace with the name of your project.
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.
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
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.
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.
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.
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.
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.
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 (Chrome Extension Recommended)
Add Rinkeby Test Network to MetaMask and get some Rinkeby Ethereum (This is fake Ethereum used only for testing purposes)
Add Polygon Network 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.
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.
Click on the icon next to transact to copy the bytecode of the contract.
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.
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.
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.
Since we deployed our contract on the Rinkeby Test network, we have to go to OpenSea Testnets 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.
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.
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.
On Remix, you should see under environment, the Ethereum network which is Main(1) network.
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.
On Remix, you should see under environment, the Polygon network which is Custom(137) network.
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.
If you deployed on the Ethereum network, go to Ethereum Blockchain Explorer.
If you deployed on the Polygon network, go to Polygon Blockchain Explorer.
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.
The next page shows a summary of the contract you just deployed.
Click on Contract > Verify and Publish
In this page, the contract field will show your contract address.
For the rest of the fields, select the options below.
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.
For Open Source License Type, you can find the license in the very first line of the code of your contract.
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.
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.
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
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.
Finally, go to you collection on OpenSea Testnets to see the new NFT. You should have a total of two NFTs now.
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 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:
Twitter:
OpenSea
Top comments (4)
What if it's not a pixel art I want to create more of 3d midjourney type of art?
Same process but make sure the dimensions are correct and follow same process
Your tutorial was so easy to follow! Glad I found it. This is probably a noob question…but…
Created my original pixel art at 100x100, then rescaled to 600x600. Then I generated 30 variations.
I want to rescale to a final size of 3000x3000 for better minting. Should I rescale, then generate with python, or do manually after.
Thanks Vicki Ross
I'm glad I could help. Either way works. Just make sure that the quality doesn't get messed up when you resize. If you do it before or after your still need to prepare a lot of layers for the NFTs, so you have to do the work either way. The only concern as I said is the quality when changing sizes, so watch out for that.