<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Solidity on Coderrob</title><link>https://coderrob.com/tags/solidity/</link><description>Recent content in Solidity on Coderrob</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Wed, 03 Nov 2021 16:46:16 -0500</lastBuildDate><atom:link href="https://coderrob.com/tags/solidity/index.xml" rel="self" type="application/rss+xml"/><item><title>Building a Revealable PFP NFT Contract with ERC-721 and IPFS</title><link>https://coderrob.com/posts/creating-pfp-nft-smart-contracts/</link><pubDate>Wed, 03 Nov 2021 16:46:16 -0500</pubDate><guid>https://coderrob.com/posts/creating-pfp-nft-smart-contracts/</guid><description>&lt;p&gt;A profile-picture NFT contract has one deceptively simple job: connect each token ID to the correct metadata.&lt;/p&gt;
&lt;p&gt;The contract in this post does that with a reveal workflow. Before reveal, every minted token returns the same placeholder metadata. After reveal, token &lt;code&gt;42&lt;/code&gt; returns the metadata assigned to token &lt;code&gt;42&lt;/code&gt;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#000;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;before reveal
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;token 42 -&amp;gt; ipfs://&amp;lt;placeholder-cid&amp;gt;/placeholder.json
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;after reveal
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;token 42 -&amp;gt; ipfs://&amp;lt;metadata-cid&amp;gt;/42.json
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The useful part is not merely concatenating a number onto a string. We also need to enforce the supply cap, reject nonexistent token IDs, stop minting before disclosure, prove that the final metadata was chosen before deployment, and freeze that metadata after reveal.&lt;/p&gt;</description></item></channel></rss>