Project 2 - NFT minter

I would like to share my second project with this lovely community and hear your feedback!

From the suggested options, I chose the topic of collectibles. As I saw it, just making a collectible itself would rather mean doing market research and artwork, and not much actual programming. While that sure develops valuable skills, I thought it was not really the purpose at the moment.

Hence, I decided to create an application which would allow for anyone to take a file or string of data, and mint it as an NFT token.
Taking a look at how Opensea makes the NFTs appear on screen, I figured that usually the image (or whatever file the token will contain) is hosted somewhere, and the token is basically a link to this file.
As the blockchain is transparent anyway, the file will be accessible for everyone. The token only represents the ownership.

So, in my case, the user uploads the file on some hosting service (I have chosen Infura’s IPFS), gets the link to their file, and then mints this link as an ERC721 token. Then, by entering the token ID, the link can be retrieved. As the file would usually be an image, the webpage also makes this image appear.

To interact with the webpage, simply navigate to
and follow the instructions on screen. When you first load it, give it a moment as it will be quite slow. I guess it is just how IPFS is.
Make sure you use a full link, including https://, like this:

To see the token ID, open console, copy Your transaction hash, paste it in Etherscan and see line 7, Tokens transfered. Yes, that is not pretty and should be improved.
For example, here I have minted a Big Strong goldfish that now lives in my MetaMask and attracts abundance.

The code with a more detailed description can be found here:

The contract itself is quite simple - it just has mint() and view() functions, and inherits the rest from OpenZeppelin ERC721 contract.
What I struggled quite a lot, was that during the course we were using pragma 0.5.12, but the ERC721.sol uses 0.6.0 and up. That meant updating Truffle and Ganache, after which Truffle didn’t work, then Ganache didn’t work, and then they didn’t communicate. Finally, I managed to deploy the contract on Ropsten. But now it is accessible for everyone!

Regarding the frontend, the mint() function was also supposed to bring the token ID on screen, but I didn’t get it to work.
Another option would be to bring up all tokens that the user’s address owns when MetaMask is connected, but at the moment I have no idea how to do that.


Now this looks good @MarcisB, great job by using openzepellin! :nerd_face:


Carlos Z.


Now I’ve been working on a personal erc721 project, learning also a lot about OpenZepellin contracts, I think using the counter utility from openzepellin could help you return the TokenID.

Dont do this exactly, this is just an example, to give you some kind of guide line or another point of view to try to help you solve this :nerd_face:

So in my NFT contract i have imported the counters library:

import "./@openzeppelin/contracts/utils/Counters.sol";

Then i have a variable that i will use to securely count my tokenId

    using Counters for Counters.Counter;
    Counters.Counter private _tokenIds;

Then i use that variable to count my IDs, this is my mint function.

    function mint(address to) private onlyOwner returns(uint256){
        uint256 newTokenId = _tokenIds.current();
        _mint(to, newTokenId);
        return newTokenId;

Now I’m still working on it, I have not coded a function to return me all the tokens owned by 1 account, but I think it must be do it by web3 and iterating through tokenOfOwnerByIndex function from the ERC721.sol of openzepellin.(I might be wrong at these, but if I found something useful ill let you know)

I will be researching this in the next days, if I made progress I can share my solution with you :nerd_face:
Carlos Z.

1 Like

It just has to copy and paste so source metamask reader (code platform presenter) insert any info to be broken in to symbolism aka images as a file storage…