How to publish your NFT on Opensea testnet
Tags: web3, opensource, blockchain, tutorial
Published: 2022-09-26 14:14:35

Index for the post:

- Overview
- Acquire test ETH
- Build and compile smart contracts using Remix
- Deploy to Rinkeby testnet
- Mint NFTs
- Publish on Opensea

This is a quick guide showing you how to publish an NFT you’ve built to a marketplace like Opensea. Opensea will help you auction or transfer the NFTs you own or build.

There are some prerequisites for this tutorial. You must have the Metamask plugin installed on your browser and “Rinkeby testnet” network added to it. 

There are two parts to this exercise. First we’ll acquire some test ETH and then we’ll use that to publish our NFT to Opensea.

Acquire some test ETH:

We can get some test ETH from a faucet like the [Rinkeby faucet](https://rinkebyfaucet.com/). The instructions on how to acquire them are available on the faucet’s website.

> In case the Rinkeby faucet isn't working, try this [link](https://faucet.rinkeby.io/). If that doesn’t work as well, reach out to me, i’ll send you some test ETH.
> 

Publish the contract to Ethreum testnet:

For this exercise I’ll be using [Remix](https://remix.ethereum.org) as our IDE and publishing tool. Remix is a cloud based IDE for solidity smart contracts development. You can use any IDE for web3 development kits for the same. I’ll cover deploying using truffle and hardhat in a future article.

Once you open [Remix](https://remix.ethereum.org) create a new file (revise-nft.sol) in the contracts folder. Paste the following code in the file.

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// Let’s start by importing the Openzeppelin ERC-721 template into our file
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
// Next, let’s add our NFT smart contract and name the NFT token (Dynamic NFT)
contract ReviseNFT is ERC721 {
    string baseuri = "";
    constructor(string memory _baseuri) ERC721("Dynamic NFT", "dNFT") {
        baseuri = _baseuri;
    }
    // Last but not the least, let’s add functions to enable minting and to enable setting the _baseURI().
    function mint(address to, uint256 tokenId) public {
        _safeMint(to, tokenId);
    }
    function _baseURI() internal view override(ERC721) returns (string memory) {
        return baseuri;
    }
}
```

Let’s start by compiling the smart contract. Hit `cmd + s` on the Mac or `ctrl + s` on windows to save the file. You should see a green tick on the compiler.


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

Click on the “Deploy options” tab. It’s the button just below the “compiler button” (shown in the above diagram).

Choose `ReviseNFT` from the “contracts” dropdown (it’s usually the last option). Fill the `_baseuri` property. Paste the baseURI link. The baseURI points to the data within the NFT. This is the data that gets shown in marketplaces like Opensea. You can use [Revise](https://revise.network?utm_source=forums&utm_medium=essay&utm_campaign=ua&utm_id=ap) to generate the baseURI. Refer to [this article](https://dev.to/anil_from_revise/use-javascript-and-openzeppelin-to-build-your-first-nft-43oe) for more details.


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

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

Set the Environment as `Injected Web3` in the “Environment” option (the first option in the page). Make sure  “Rinkeby network” is selected in your Metamask wallet. Now hit the `Deploy` button. This will bring up the Metamask popup. It will ask you confirm the deployment of this smart contract. Once you accept it, the smart contract will be deployed to “Rinkeby testnet”.

Once the NFT smart contract is successfully deployed we can mint an NFT. Click on “REVISENFT…” in the “deployed contracts” section. You’ll see a bunch of smart contract functions you can call.

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

Click on the “mint” function and pass it your wallet address and choose 1 as the tokenID (you can choose any number, make sure you use the same number in [Revise](https://revise.network?utm_source=forums&utm_medium=essay&utm_campaign=ua&utm_id=ap) as the tokenId). This will trigger Metamask and open an popup. Once you hit on “confirm” it will process your transaction and mint the NFT straight to your wallet.

Copy and store the address of the contract you just deployed. You’ll find it under “Deployed contracts”.

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

Now that our NFT smart contract is deployed on-chain and we’ve minted at least one NFT, we’re ready to publish our collection to Opensea.

Visit [https://testnets.opensea.io](https://testnets.opensea.io) and click on the wallet button (it’s the last button in the header, right beside the profile button). Choose Metamask and click confirm on the popup. 

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

Once you’re logged in you can go to your profile and your NFT will be listed under “my collections”! If you’re not able to view it there just visit “https://testnets.opensea.io/assets/<your_contract_address>/<token_id>”, replace the contract address with the address we copied earlier and the token_id with 1 (since that’s what we minted). You’ll be able to see your NFT there.

Congrats on publishing your first NFT collection to Opensea!