0

I see some methods how to refresh collection metadata on opensea.
one method was this

https://api.opensea.io/api/v1/asset/[contract-address]/[token-id]/?force_update=true but it doesn't work on polygon networks is there any solution for polygon networks?

1 Answer 1

0

Polygon and many other networks aren't supported in V1 of the API unfortunately. One solution I was able to find is running a script in the developer console which will refresh individual item's metadata via the browser and Opensea's ui. You can find it on Github:

https://gist.github.com/rcaloras/95bcd4e83cb17ff40d28e8d51fc2e0df

Inlining here for convenience:

// Paste this script into the console on a specfic NFT detail page for your collection.
// e.g. https://opensea.io/assets/ethereum/0x1485297e942ce64e0870ece60179dfda34b4c625/3723
// Adjust i on the for loop for the range of nfts you wish to refresh
// Should work for all chains including Polygon and testnets.

// Returns a Promise that resolves after "ms" Milliseconds
const timer = ms => new Promise(res => setTimeout(res, ms))

async function refresh_metadata() { // We need to wrap the loop into an async function for this to work
    for (var i = 1; i <= 1326; i++) {
        await timer(1000); // then the created Promise can be awaited
        var collectionUrl = window.location.href.split('/').slice(0, -1).join('/') + '/'
        var nextUrl = collectionUrl + i
        var nextWindow = window.open(nextUrl)
        nextWindow.addEventListener('load', function () {
            // Interact with the dom on this new page
            kabob = nextWindow.document.getElementsByClassName('sc-a143597d-0 sc-f0199734-0 RovoC gdcSkC material-icons')[2]
            kabob.click()
            refresh = nextWindow.document.getElementsByClassName('sc-29427738-0 sc-bdnxRM sc-a8df1259-2 erpyI iPAlIP')[0]
            refresh.click()
            console.log("Refreshed for " + i)
        }, false);
        nextWindow.blur();
        await timer(3000);
        nextWindow.close();
    }
}

refresh_metadata()

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.