Useful information functions from LyncLootBox class
NOTE -
These are information functions and do not require a signer. Just the provider will work!
Initialize the class before calling any of these functions.
import { LyncLootBox, LootBoxError } from"@lyncworld/lootbox-evm-sdk";import { ethers } from"ethers";constlb=newLyncLootBox();awaitlb.initialize(ChainIdentifier.BASE_SEPOLIA,// your chain provider,// provider lootboxId // your lootbox id / address);
1. isEmpty
Checks if the lootbox is empty or not.
constempty=awaitlb.isEmpty();console.log(empty); // true or false
2. itemAddresses
Lists the item addresses that are present in the lootbox.
constitemAddresses=awaitlb.itemAddresses();console.log(itemAddresses); // Array of addresses
NOTE -
It has an optional parameter useSubgraph which takes a boolean. If set to true, it will utilize the subgraph instead of directly querying the blockchain.
{ erc20Items: [ { itemAddress:'0x...',// addres of the erc20 token tokenAmount:'85517387241022654383'// total token amount for this wallet },... more items ], erc721Items: [ { itemAddress:'0x...',// addres of the erc721 token tokenIds: ['2','3',...] // all the token ids for this wallet },... more items ], erc1155Items: [ { itemAddress:'0x...',// addres of the erc1155 token tokenIds: ['1','2','3',...],// all the token ids for this wallet tokenAmounts: ['5','8','1',...] // respective token amounts },... more items ]}