fudgebucket27 / LoopringRedditNFTGiveawayBot

Loopring Reddit NFT Giveaway Bot
4 stars 0 forks source link

Fetch nftData and nftTokenId yourself #5

Open modersohn opened 2 years ago

modersohn commented 2 years ago

Yesterday I was trying to help someone on Discord who wanted to use the bot, but struggled to get nftData and nftTokenId. Neither of those are easily accessible, not even on lexplorer - at least for nftData you have to use the API to retrieve it it seems.

Since the bot already needs to make API calls anyway, wouldn't it be easier to let users specify the normal nftId and then the bot fetches nftData and nftTokenId itself? Just an idea - or if there is a way to show both in lexplorer, we could do that ;-)

fudgebucket27 commented 2 years ago

I'll need to research the API endpoints but that would be much more preferable!

On Wed, 6 July 2022, 7:50 pm modersohn, @.***> wrote:

Yesterday I was trying to help someone on Discord who wanted to use the bot, but struggled to get nftData and nftTokenId. Neither of those are easily accessible, not even on lexplorer - at least for nftData you have to use the API to retrieve it it seems.

Since the bot already needs to make API calls anyway, wouldn't it be easier to let users specify the normal nftId and then the bot fetches nftData and nftTokenId itself? Just an idea - or if there is a way to show both in lexplorer, we could do that ;-)

— Reply to this email directly, view it on GitHub https://github.com/fudgebucket27/LoopringRedditNFTGiveawayBot/issues/5, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABIDWT3VWDJDAB56VSKUY2LVSVJERANCNFSM52ZEFNRA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

modersohn commented 2 years ago

Out of interest I had a look and since I'm not familiar with the API at all, I might be totally wrong.

If you fetch all token balances of a user using /api/v3/user/nft/balances you could then iterate over all nftDatas and query the NFT information with /api/v3/nft/info/nfts - or it might even be able to retrieve them all at once? There you could then find the one for the given nftID and extract tokenID and nftData.

That's the best I could find - and it seems cumbersome and/or requires numerous API calls.

An alternative could be /api/v3/nft/info/nftData which needs minter, tokenAddress and nftID. And tokenAddress could be fetched with /api/v3/nft/info/computeTokenAddress - but that would only work if the account really is the minter and as long as there's no baseAddress used. Personally, I'd just use the graph to get the tokenAddress!

fudgebucket27 commented 2 years ago

Thanks mate I'll do some reading!