Comments (6)
I set totalNum to calculate rarity scores. Cursor usage is giving us the full metadata of any collection. I thing setting the variable like this after loop is completed may be way better than my codes. let totalNum = allNFTs.length;
And like that you don't have to know how many NFT's are available in collection.
from rarity-ranking-nft.
Same issue for me, is there a fix for this?
from rarity-ranking-nft.
Same issue for me, is there a fix for this?
I used cursor instead of offset.
async function generateRarity() {
const totalNum = 10000;
let allNFTs = [];
const timer = (ms) => new Promise((res) => setTimeout(res, ms));
let cursor = null;
do {
const response = await Moralis.Web3API.token.getAllTokenIds({
address,
chain: "eth",
limit: 500,
cursor: cursor,
});
console.log(
`Got page ${response.page} of ${Math.ceil(
response.total / response.page_size
)}, ${response.total} total`
);
allNFTs = allNFTs.concat(response.result);
cursor = response.cursor;
// await timer(1000);
cursor = null; // disable the timer above and enable this line of code to get only 500 tokenIds;
} while (cursor != "" && cursor != null);
let metadata = allNFTs.map((e) => JSON.parse(e.metadata).attributes);
console.log(metadata);
from rarity-ranking-nft.
Same issue for me, is there a fix for this?
I used cursor instead of offset.
async function generateRarity() { const totalNum = 10000; let allNFTs = []; const timer = (ms) => new Promise((res) => setTimeout(res, ms)); let cursor = null; do { const response = await Moralis.Web3API.token.getAllTokenIds({ address, chain: "eth", limit: 500, cursor: cursor, }); console.log( `Got page ${response.page} of ${Math.ceil( response.total / response.page_size )}, ${response.total} total` ); allNFTs = allNFTs.concat(response.result); cursor = response.cursor; // await timer(1000); cursor = null; // disable the timer above and enable this line of code to get only 500 tokenIds; } while (cursor != "" && cursor != null); let metadata = allNFTs.map((e) => JSON.parse(e.metadata).attributes); console.log(metadata);
Even I tried this but what if the collection has more than 10000 nfts?
from rarity-ranking-nft.
#16 Created a pull request regarding the updated cursor of Moralis.
from rarity-ranking-nft.
This works as a fix for cursor
` let allNFTs = [];
const timer = (ms) => new Promise((res) => setTimeout(res, ms));
let cursor = null;
do {
const NFTs = await Moralis.Web3API.token.getAllTokenIds({
address: collectionAddress,
chain: "eth",
limit: 100,
cursor: cursor,
});
let counter = 0;
for (const nft of NFTs.result) {
let metaData = JSON.parse(nft.metadata);
if(metaData != null) {
allNFTs.push(nft);
console.log(metaData);
}
counter+=100;
}
if(counter % 200 == 0) {
await timer(2000);
}
cursor = NFTs.cursor;
} while (cursor != "" && cursor != null);
let metadata = allNFTs.map((e) => {
if(JSON.parse(e.metadata)) {
return JSON.parse(e.metadata).attributes
}
});`
from rarity-ranking-nft.
Related Issues (13)
- Avalanche Ranker HOT 14
- Cannot read properties of null (reading 'attributes') HOT 9
- Define a default collection shown when opening the page
- cannot read properties of undefined reading map:
- Load collection when page loads
- can we open this back up
- Rarity Generator issues HOT 5
- Getting TypeError: Cannot read property 'attributes' of null error HOT 1
- Null metadata
- Solana Integration
- Error: Cannot find module 'rxjs' HOT 1
- Polygon Issue
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rarity-ranking-nft.