As per the title. I want to be able to have a placeholder image for my NFTs, something like this:


Then subsequently, after launch, I then update the metadata.

How do I do this using Pinata / IPFS ? Do I need to write a specific function in my smart contract to allow this?

  • hey what did you end up doing ?
    – ihor.eth
    Nov 3, 2021 at 19:37

2 Answers 2


You need to declare an empty variable at the beginning of your smart contract:

string newURI

Then you need to create a function to control the URI, this function takes a variable called _newURI as a parameter, this is the CID of pinata.

//  Modify URI with this function
function setURI(string calldata _newURI) public onlyOwner{
    newURI = _newURI;

//  Base URI function, this won't be callable, you will use the above 
//  function instead to invoke this one
function _baseURI() internal view override returns (string memory) {
    return newURI;

As you can see the _baseURI( ) function returns the URI of the files, and the setURI( ) function is the one that will override the newURI variable (which is the one that _baseURI returns)

When you deploy your smart contract you will need to set the CID of pinata with the placeholder images, and whenever you want to reveal them you just need to call setURI( ) with the updated CID.


An alternate to @alex's answer (not adviced, but for the sake of completion) would be to create an IPNS listing. IPFS uses content addressing, so when the content changes, the address also changes. For places where you might need a contract address with updatable content, IPNS acts as a naming scheme, where you can update the IPFS content it points to. The content can be accessed via /ipns/<ipns_hash>. However, I'm not sure what NFT marketplaces support it. You can read more about IPNS here.

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.