1

I am learning how to make NFTs in Solidity. I have two questions:

1.) what is token URI? What does it mean?

2.) I am following a ERC-721 guide, but I think the _setTokenURI function has been removed from the OpenZeppelin ERC-721 standard because this code will not compile, so how do I set the new URI?

pragma solidity ^ 0.8.10;

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/utils/Counters.sol";

contract EGM_NFT is ERC721 {
    using Counters for Counters.Counter;
    Counters.Counter private _tokenIDs;
    constructor() ERC721("Gato NFT", "GFT") {}

    function createGatoNFT (string memory tokenURI) public returns (uint256) {
        _tokenIDs.increment();
        uint256 newTokenID = _tokenIDs.current();
        _safeMint(msg.sender, newTokenID);
        _setTokenURI(newTokenID, tokenURI);
        return newTokenID;
        
    }

}
3

2 Answers 2

1

I think is because you must install the dependency first and then import like you are doing with Counter.sol.

import "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol";

Be sure that you run yarn add @openzeppelin/contracts or npm install @openzeppelin/contracts

1

To answer your URI question - if you want to use IPFS then you should install IPFS CLI to create a local node and upload your file to get a hash generated which you can use to create your URI. https://docs.ipfs.io/install/command-line/

If you want an example on how to mint an NFT using ERC721, IPFS and some basic toolchain try out this example from Patrick Collins bootcamp course free on youtube (https://www.youtube.com/watch?v=M576WGiDBdQ&t). the NFT project timestamp is 09:50.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.