DEV Community

Discussion on: NFT images generator using Python Jupyter Notebook

Collapse
 
chris_t_3ecc33da3626748cd profile image
Chris T • Edited

Thanks for your quick reply! :)

In response to my 2nd question, the Metadata will already be already included within the PNG files from that line of code you show? So I could just upload the image created onto Opensea and the metadata will also be uploaded too?

Ah okay! Still trying to wrap my head around the smart contracts, a lot more complicated than uploading each file one by one on Opensea :S

Thread Thread
 
victorquanlam profile image
Victor Quan Lam • Edited

image here

As you can see the metadata files will be generated under the metadata folder.
image here

You can run this little javascript to update the meta data

const fetch = require('node-fetch');

// Update [ADD_CONTRACT_ADDRESS] to your Contract Address
const OPENSEA_URI = 'https://api.opensea.io/asset/ADD_CONTRACT_ADDRESS'; 

// Maximum Tokens Belonging to Contract
const MAX_TOKENS = 3349;


// update OPENSEA_URI
function refreshData(tokenId) {
    const URI = `${OPENSEA_URI}/${tokenId}/?force_update=true`;
    const OPTIONS = {method: 'GET'};

    fetch(URI, OPTIONS)
    .then(res => res.json())
    .then(json =>  {
        if(json.detail) {
            console.log(`failed: ${tokenId}`);
        } else if(json.token_id) {
            console.log(`success: ${tokenId}`);
        }
    })
    .catch(err => console.error(`failed: ${tokenId}`));
};


const refreshTokens = (start, end) => {
    Array.from({length: end - start + 1}, (x, i) => start + i).forEach((tokenId) => {    
        refreshData(tokenId);
    });   
}

let start = 0;
let end = 1;

const id = setInterval(() => { 
    refreshTokens(start, end);
    if(end > MAX_TOKENS) clearInterval(id);
    start = end + 1;
    end = start + 1;
},2000);

Enter fullscreen mode Exit fullscreen mode


`
Check this article out for more details about metadata
docs.opensea.io/docs/2-adding-meta...

Hope it helps.

Thread Thread
 
chris_t_3ecc33da3626748cd profile image
Chris T

Great thanks!

Sorry to keep asking questions! There is a lot to learn.

What do I put in here:

IMAGES_BASE_URI = "ADD_IMAGES_BASE_URI_HERE"

I'm still a little confused as to what to do after creating the PNG and Metadata files. Do I need to upload these onto IPFS and then upload that to Opensea? Or if I upload the PNG files directly to Opensea it would automatically do it for me?

Thread Thread
 
victorquanlam profile image
Victor Quan Lam • Edited

This is where you store your images for public views. It can be used when creating your smart contract.

Hope this gives you enough hint. I'm working on a web app to generate pixelated nft arts at the moment so I don't have much time to explain things in much details. I would create a new blog post for creating ERC721 Token and nft in the near future.