<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Seamus Cranley on Medium]]></title>
        <description><![CDATA[Stories by Seamus Cranley on Medium]]></description>
        <link>https://medium.com/@seamus.cranley?source=rss-8d471e688873------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*2e3rwRvvKaZnwxsyw2GQFA.png</url>
            <title>Stories by Seamus Cranley on Medium</title>
            <link>https://medium.com/@seamus.cranley?source=rss-8d471e688873------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 22:18:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@seamus.cranley/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Part 2: Images upload to IPFS with Metadata.]]></title>
            <link>https://medium.com/@seamus.cranley/part-2-images-upload-to-ipfs-with-metadata-61b12524fc1?source=rss-8d471e688873------2</link>
            <guid isPermaLink="false">https://medium.com/p/61b12524fc1</guid>
            <category><![CDATA[ipfs]]></category>
            <category><![CDATA[polygon]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[nft]]></category>
            <dc:creator><![CDATA[Seamus Cranley]]></dc:creator>
            <pubDate>Thu, 09 Sep 2021 12:00:21 GMT</pubDate>
            <atom:updated>2022-09-29T04:01:04.483Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Tk8AQ9qMvxh5-5Hn.png" /></figure><h3>A journey to programmatically create NFTs Part 2</h3><p>In this article I will show you how to programmatically upload an image and it’s metadata to IPFS. This resulting metadata can be used to mint your NFTs. <a href="https://medium.com/@seamus.cranley/how-to-create-the-art-for-an-nft-like-cryptopunks-aa09c94dea9f">Part 1: How To Create art for an NFT like CryptoPunks</a></p><p><em>Basic understanding of javascript is needed in order to properly use the code snippets provided in this article.</em></p><h3>Step 1: Creating the MetaData with your Ruby Script.</h3><ul><li>Here is a link to the repo for this article: <a href="https://github.com/scranley/heroipfsupload">https://github.com/scranley/heroipfsupload</a></li><li>Install Node.js and Ruby</li></ul><p>In the previous article we showed how to create our images which we will now upload to IPFS.</p><p>We will create metadata.json for each hero’s face image. This script also creates the images along with the metadata.json.</p><ul><li>Program our ruby script to create our metadata.json:</li></ul><pre>require &#39;json&#39; //For out metadata we will include json.<br>require &#39;pixelart&#39; //pixelart is needed to create the images.</pre><pre>COMPONENTS = {<br>face: { types: [&#39;&#39;, &#39;myface1&#39;] },<br>mouth: {  types: [&#39;&#39;, &#39;mymouth1&#39;] },<br>eyes: { types: [&#39;&#39;, &#39;myeyes1&#39;] }<br>}</pre><pre>// The heroMetaData hash is where we will construct our json.<br>$heroMetaData = {<br>      &quot;name&quot;=&gt; &quot;&quot;,<br>      &quot;description&quot; =&gt; &quot;&quot;, <br>      &quot;image&quot; =&gt; &quot;&quot;,<br>      &quot;face&quot; =&gt; &quot;&quot;,       ##Face <br>      &quot;mouth&quot; =&gt; &quot;&quot;,      ##Mouth<br>      &quot;eyes&quot; =&gt; &quot;&quot;       ##Eyes<br>      }</pre><pre>def generate_hero( codes )<br>  hero = Pixelart::Image.new( 32, 32 )<br>           <br>  COMPONENTS.each_with_index do |(key,part),i|<br>    code  = codes[i] <br>    if code != 0                  <br>      attribute = part[:types][ code-1 ]<br>      path = &quot;./components/#{key}/#{key}#{code}.png&quot;<br>      part = Pixelart::Image.read( path ) <br>      hero.compose!( part )<br>      $heroMetaData[&quot;#{key}&quot;] = &quot;#{key}#{code}&quot;<br>    end<br>  end                            <br>  hero                 <br>end</pre><ul><li>Program the next ruby script to output a metadata.json per hero.</li></ul><pre>require &#39;./hero_gen.rb&#39;</pre><pre>fileNumber = 0</pre><pre>while fileNumber &lt; 2  do  </pre><pre>codes = [1, 1, 1]<br> myhero = generate_hero( codes )<br> myhero3x = myhero.zoom( 3 )<br> myhero.save( &quot;./HeroImages/hero-#{fileNumber}.png&quot; )<br> myhero3x.save(&quot;./HeroImages/hero-#{fileNumber}.x3.png&quot;)</pre><pre>#The image CID will be added in our IPFS upload script.</pre><pre>$heroMetaData[&quot;name&quot;] = &quot;My Hero Number: #{fileNumber}&quot;<br> $heroMetaData[&quot;description&quot;] = &quot;Description: A super hero&quot;<br> File.open(&quot;metaDataFiles/metadata-#{fileNumber}.json&quot;,&quot;w&quot;) do |f|<br> f.write($heroMetaData.to_json)<br> end<br> fileNumber += 1<br>end</pre><h3>Step 2 : Setup Pinata.</h3><ul><li>Create a Pinata account: <a href="https://app.pinata.cloud/">https://app.pinata.cloud/</a> (you will need it for pinning your files. For more details <a href="https://medium.com/pinata/what-is-an-ipfs-pinning-service-f6ed4cd7e475">see this article</a>)</li><li>Create new Pinata API keys, secure them in your password manager.</li><li>We will test our Node.js setup and authentication with Pinata.</li><li>Let’s initialize your npm package. Run the following from the root directory.</li></ul><pre>npm init</pre><ul><li>Take the defaults for npm init.</li></ul><pre>npm install @pinata/sdk</pre><ul><li>Create the following script in the root of your directory and name it pinataAuthenticationTest.js</li></ul><pre>const pinataSDK = require(&#39;<a href="http://twitter.com/pinata/sdk">@pinata/sdk</a>&#39;);<br>const pinata = pinataSDK(&#39;&lt;YOUR PINATA KEY IDENTIFIER GOES HERE&gt;&#39;, &#39;&lt;YOUR PINATA KEY SECRET GOES HERE&gt;&#39;);</pre><pre>pinata.testAuthentication().then((result) =&gt; {<br>    //handle successful authentication here<br>    console.log(result);<br>}).catch((err) =&gt; {<br>    //handle error here<br>    console.log(err);<br>});</pre><ul><li>Add this line to your package.json under scripts:</li></ul><pre>“scripts”: {</pre><pre>“test”: “echo \”Error: no test specified\” &amp;&amp; exit 1&quot;,</pre><pre>“testPinataAuth”: “node pinataAuthenticationTest.js”</pre><pre>},</pre><ul><li>From the command line type: npm run testPinataAuth</li></ul><p>This will return:</p><p>{ authenticated: true }</p><h3><strong>STEP 3: Program our Pinata upload script.</strong></h3><p>I will explain how to get the image and upload the image to Pinata. This will return the CID of the image in IPFS. Once we have the CID for the image in IPFS, we create the metadata file that we will use for our NFT.</p><ul><li>Create the first part of our IPFS upload file to get our heroes on IPFS. Name this file: heroipfsupload.js</li><li>Add another entry to your package.json:</li></ul><pre>“scripts”: {</pre><pre>“test”: “echo \”Error: no test specified\” &amp;&amp; exit 1&quot;,</pre><pre>“testPinataAuth”: “node pinataAuthenticationTest.js”,</pre><pre>“heroupload”: “node heroipfsupload.js”</pre><pre>},</pre><ul><li>Create the script:</li></ul><pre>const fs = require(&#39;fs&#39;)<br>const path = require(&#39;path&#39;)<br>const cid = require(&#39;cids&#39;)<br>const pinataSDK = require(&#39;<a href="http://twitter.com/pinata/sdk">@pinata/sdk</a>&#39;);<br>const pinata = pinataSDK(&#39;&lt;YOUR PINATA KEY IDENTIFIER GOES HERE&gt;&#39;, &#39;&lt;YOUR PINATA KEY SECRET GOES HERE&gt;&#39;);</pre><pre>async function main() {</pre><pre>for (let count = 0; count &lt; 1; count++) {</pre><pre>let rawdata = fs.readFileSync(&quot;metaDataFiles/hero-metadata-&quot; + count + &quot;.json&quot;); //read in incomplete herometadata<br>  let metaData = JSON.parse(rawdata);<br>  const URI = await CreatePinMeta(metaData, count);<br>  console.log(&quot;NFT minted:&quot;, URI);<br> }<br>}<br>main().then(() =&gt; process.exit(0)).catch(error =&gt; {<br> console.error(error);<br> process.exit(1);<br>});</pre><ul><li>Now we will create our CreatePinMeta function</li></ul><pre>async function CreatePinMeta(metadata, count) {</pre><pre>MyCustomName = &quot;hero&quot; + count</pre><pre>MyFileName = &quot;HeroImages/hero-&quot; + count + &quot;.x3.png&quot;</pre><pre>const readableStreamForFile = fs.createReadStream(MyFileName);<br> const options = {<br>  pinataMetadata: {<br>   name: MyCustomName,<br>   keyvalues: {<br>    customKey: &#39;CryptoHeroPNG&#39;,<br>    customKey2: &#39;FirstEdition&#39;<br>   }<br>  },<br>  pinataOptions: {<br>   cidVersion: 0<br>  }<br> };</pre><pre>return pinata.pinFileToIPFS(readableStreamForFile, options).then((result) =&gt; {<br>  //send result hash CID to create Metadata.<br>  console.log(result);</pre><pre>metadata.image = result.IpfsHash;<br>  //this is the meta data that points to the PNG, pinning JSON to pinata.<br>  const body = metadata;<br>  console.log(metadata);<br>  const options = {<br>   pinataMetadata: {<br>    name: &quot;metadata.json&quot;, //this will always be named metadata.json<br>    keyvalues: {<br>     customKey: &#39;CryptoHeroMetaData&#39;<br>    }<br>   },<br>   pinataOptions: {<br>    cidVersion: 0<br>   }<br>  };</pre><pre>return pinata.pinJSONToIPFS(body, options).then((result) =&gt; {<br>   //handle results here Create NFT here.  <br>   // return IpfsHash for URI to mint NFT.                               <br>   return result.IpfsHash;<br>  }).catch((err) =&gt; {<br>   //handle error here<br>   console.log(err);<br>  });</pre><pre>}).catch((err) =&gt; {<br>  //handle error here<br>  console.log(err);<br> });</pre><pre>}</pre><p>Let’s go over what this function does:</p><p>It has the meta data from the file and the hero count. It reads the first hero PNG and then uploads it to IPFS. Once the hero.png is uploaded a CID is returned from Pinata. This CID is passed to the function that will upload the Metadata. This is the Metadata that you need when you create an NFT of the hero’s image.</p><p>Once this function is done, it will return the CID for the metadata to the first function call in main and then be outputted as URI to console.log.</p><p>Congratulations! You have just uploaded, pinned your image to IPFS, and created the metadata.json needed to create your NFT.</p><p><a href="https://medium.com/@seamus.cranley/how-to-create-the-art-for-an-nft-like-cryptopunks-aa09c94dea9f">Part 1: How To Create art for an NFT like CryptoPunks</a></p><p>Part 2: Images upload to IPFS with MetaData <em>(Current)</em>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=61b12524fc1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Part 1: How To Create art for an NFT like CryptoPunks.]]></title>
            <link>https://medium.com/@seamus.cranley/how-to-create-the-art-for-an-nft-like-cryptopunks-aa09c94dea9f?source=rss-8d471e688873------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa09c94dea9f</guid>
            <category><![CDATA[crypto]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[cryptopunks]]></category>
            <category><![CDATA[nft]]></category>
            <category><![CDATA[lospec]]></category>
            <dc:creator><![CDATA[Seamus Cranley]]></dc:creator>
            <pubDate>Wed, 25 Aug 2021 06:42:41 GMT</pubDate>
            <atom:updated>2022-09-29T04:00:33.849Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rdOSHMvfdfXcEvz1d_Nh3Q.png" /></figure><h3>A journey to programmatically create NFTs.</h3><p>In this article I will show you how to create images similar to cryptopunks from <a href="https://www.larvalabs.com/cryptopunks">https://www.larvalabs.com/cryptopunks</a> and cryptodaemons from <a href="http://www.ethertale.com/">www.ethertale.com</a>. These images are made of different layers: empty outlines of faces<strong>,</strong> hair, eyes, mouth, nose, etc.., that are randomly generated by a script to compose complete faces.</p><p>Example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/168/1*V8EwcMCCFxacSNTtiGzxjQ.png" /><figcaption>CryptoDaemon from Ethertale.</figcaption></figure><h3>Step 1: Create the images.</h3><p>Each layer will be a separate image, think of Mr. PotatoHead™. I will demonstrate how to create and export layers using “lospec’s free pixel editor” but you can use any other image editor program that suits your needs. Here’s a link to the repository: <a href="https://github.com/scranley/cryptoheroes">https://github.com/scranley/cryptoheroes</a> .</p><ul><li>Open <a href="https://lospec.com/">https://lospec.com/</a> and open their free pixel editor from the hamburger.. upper right. Enter the app, and create a 32x32 canvas<strong>.</strong></li><li>Start working with layers: Select editor in the top and choose “ Advanced” to get your panel for adding layers.</li><li>Let’s make a blank face on layer 1. This simple rectangle in the center of the canvas will be our face.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/416/1*Vm__QltQ98NXUEngt3aZsg.png" /><figcaption>Make a rectangle in the center of the canvas.</figcaption></figure><ul><li>Then draw the mouth on layer 2.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/330/1*HQ_BrnwDZi9yqFFfhKSlAQ.png" /><figcaption>mouth1 on Layer 2</figcaption></figure><ul><li>And eyes1 on layer 3.</li></ul><p>Now you should have a smiley face.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/306/1*c6CbWO7mbsGiv1FMlBrdxA.png" /><figcaption>eyes1 on Layer 3</figcaption></figure><p>Export each layer as a separate PNG image: face1.png, mouth1.png and eyes1.png. This is how I did it in “lospec’s pixel editor”. The reason you have to put a number after your images is because of the way the script references them. You could have any number of faces, mouths etc.</p><p>To export “face1.png” I hid layers “mouth1” and “eyes1” and exported the layer with face1.</p><ul><li>I did same for “eyes1.png” and “mouth1.png”</li></ul><p>Now you should have three files, face1.png, mouth1.png and eyes1.png.</p><ul><li>Create a directory called components in your script folder.</li><li>In the components directory create 3 more directories called “face”, “mouth” and “eyes”.</li><li>Copy your PNG images<strong> </strong>to the “face” directory, “mouth” directory and your “eye” directory respectively. <strong>Pay close attention to the names, they have to match for your script to find the files.</strong></li></ul><p>Directory Structure:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*oHz2W9V_lgd1Bg2wCiwAjQ.png" /></figure><h3>Step 2: Combine the images with our script.</h3><p>Now we will use the ruby programming language to combine the separate images into complete faces.</p><ul><li>Install Ruby:</li></ul><p><a href="https://www.ruby-lang.org/en/documentation/installation/">Installing Ruby</a></p><ul><li>and then install the picture library we will use:</li></ul><pre>gem install pixelart</pre><ul><li>Now create a file in your text-editor or ide: let’s name it hero_gen.rb</li><li>Paste the following code in the file:</li></ul><pre>require ‘pixelart’</pre><pre>COMPONENTS = {<br>face: { types: [‘’, ‘myface1’] },<br>mouth: { types: [‘’, ‘mymouth1’] },<br>eyes: { types: [‘’, ‘myeyes1’] }<br>}</pre><p>The first line requiring pixel-art loads the pixel-art gem so we can use it’s functions later in our program.</p><p>COMPONENTS is a hash in ruby. Our program will grab our component and type of component depending on what codes we give it.</p><pre>def generate_hero( codes )<br>    hero = Pixelart::Image.new( 32, 32)<br>    COMPONENTS.each_with_index do |(key,part),i|<br>        code = codes[i] <br>        if code != 0 <br>        attribute = part[:types][ code-1 ]<br>        path = “./components/#{key}/#{key}#{code}.png”<br>        part = Pixelart::Image.read( path ) <br>        hero.compose!( part )<br>        end<br>     end <br>  hero <br>end</pre><p>And here we call our function: “hero_gen.rb”</p><p>The function will assemble our hero with our components and it will save the resulting image in regular size and 3 times that size.</p><p>Put this below our generate_hero function in the same file hero_gen.rb</p><pre>codes = [1, 1, 1]<br>myhero = generate_hero( codes )<br>myhero3x = myhero.zoom( 3 )<br>myhero.save( ‘./hero-0000.png’ )<br>myhero3x.save(‘./hero-0000x3.png’)<br></pre><p>If you see the new PNG images in the “myheroes” directory, it’s success!</p><p>Congratulations! You have just created your first layered sprite with code.</p><p>Part 2: Images upload to IPFS with Metadata. Coming soon.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa09c94dea9f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>