<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sem Moolenschot</title>
    <description>The latest articles on DEV Community by Sem Moolenschot (@sem).</description>
    <link>https://dev.to/sem</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F780482%2F14e28085-0e46-4647-8f99-885e744c9477.png</url>
      <title>DEV Community: Sem Moolenschot</title>
      <link>https://dev.to/sem</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sem"/>
    <language>en</language>
    <item>
      <title>Create a NFT collection using Python</title>
      <dc:creator>Sem Moolenschot</dc:creator>
      <pubDate>Mon, 10 Jan 2022 20:24:07 +0000</pubDate>
      <link>https://dev.to/sem/create-a-nft-collection-using-python-467i</link>
      <guid>https://dev.to/sem/create-a-nft-collection-using-python-467i</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In this tutorial I will show you guys how to create your very own NFT collection in Python. &lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Download &lt;a href="//www.python.org"&gt;Python&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Open any IDE like &lt;a href="https://code.visualstudio.com"&gt;VS Code&lt;/a&gt;, and then open ur terminal. Once you have your terminal opened you can clone the repository by typing &lt;code&gt;git clone https://github.com/sem/NFT-Image-Generator&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Now you have the repository cloned, you will need to install the requirements by typing the following in your terminal:&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;Mac/Linux&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip3 install -r requirements.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Windows&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install -r requirements.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What is Pinata?
&lt;/h2&gt;

&lt;p&gt;Pinata cloud is a pinning service that allows users to host files on the IPFS network. We will have to use this so that we can have a path to our images to put it in the corresponding  metadata.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is metadata?
&lt;/h2&gt;

&lt;p&gt;NFT metadata is the core of an NFT. It is a JSON document that often contains a path to the image along with a description and the name of the NFT etc.&lt;/p&gt;

&lt;h2&gt;
  
  
  Get an API key from Pinata
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Go to &lt;a href="//pinata.cloud"&gt;pinata.cloud&lt;/a&gt; and make an account.&lt;/li&gt;
&lt;li&gt;Click on your icon in the top right corner and navigate to &lt;a href="https://app.pinata.cloud/keys"&gt;API Keys&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Click on the 'New Key' button, enable 'Admin' and give the key a name.&lt;/li&gt;
&lt;li&gt;Once you've made the key, copy the JWT (Secret access token).&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Set up the config
&lt;/h2&gt;

&lt;p&gt;Now comes the most important part, setting up the config. It will make sure that the images can be uploaded to the right Pinata account and that all names and descriptions will be set correctly for each individual NFT in your collection.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Name of your collection&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;project_name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name of your project&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;

    &lt;span class="c1"&gt;// Amount of images you want to create&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;amount&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;

    &lt;span class="c1"&gt;// Description of the collection&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;description&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;description of your collection&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;

    &lt;span class="c1"&gt;// JWT (Secret access token) from Pinata that you had copied&lt;/span&gt;
    &lt;span class="c1"&gt;// earlier.&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;api_key&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;your secret access token&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;

    &lt;span class="c1"&gt;// All folders containing seperate layers that will be used&lt;/span&gt;
    &lt;span class="c1"&gt;// to make your final images. You can add as many folders as&lt;/span&gt;
    &lt;span class="c1"&gt;// you want as long as they start with a sequential number&lt;/span&gt;
    &lt;span class="c1"&gt;// that represents the order of the layers. &lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;folders&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;1 background&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;2 body&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;3 eyes&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;],&lt;/span&gt;

    &lt;span class="c1"&gt;// Files to be ignored in the corresponding folders while&lt;/span&gt;
    &lt;span class="c1"&gt;// making the NFT images.&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ignore&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;.DS_Store&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should have a file structure that looks something like the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;NFT-Image-Generator/
├─ main.py
├─ config.json
├─ requirements.txt
├─ 1 background/
│  ├─ red.png
│  ├─ green.png
│  ├─ blue.png
├─ 2 body/
│  ├─ female.png
│  ├─ male.png
│  ├─ zombie.png
├─ 3 eyes/
│  ├─ sun_glasses.png
│  ├─ normal_eyes.png
│  ├─ vr_glasses.png
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure each folder contains at least one image.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating the images
&lt;/h2&gt;

&lt;p&gt;Now the config and folders are set up, we're finally able to create the images. Good job 👏. All you have to do now is open up your terminal and run the Python file.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Mac/Linux&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python3 main.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Windows&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python main.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you have followed along step by step, then your images and the metadata should appear in a folder called 'output'. You can also log in to &lt;a href="//www.pinata.cloud"&gt;Pinata&lt;/a&gt; and your output should be right there at the &lt;a href="https://app.pinata.cloud/pinmanager"&gt;files&lt;/a&gt; tab.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;We have now created our own collection of unique images along with the metadata that's needed to deploy them as NFT's! &lt;/p&gt;

&lt;p&gt;If you’ve reached this far, congratulations! There will be another tutorial soon to actually deploy your images and start earning money.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/sem/NFT-Image-Generator"&gt;Final code repository&lt;/a&gt;&lt;/p&gt;

</description>
      <category>nft</category>
      <category>python</category>
      <category>tutorial</category>
      <category>blockhain</category>
    </item>
  </channel>
</rss>
