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";
const lb = new LyncLootBox();
await lb.initialize(
ChainIdentifier.BASE_SEPOLIA, // your chain
provider, // provider
lootboxId // your lootbox id / address
);1. isEmpty
isEmptyChecks if the lootbox is empty or not.
const empty = await lb.isEmpty();
console.log(empty); // true or false2. itemAddresses
itemAddressesLists the item addresses that are present in the lootbox.
NOTE -
It has an optional parameter
useSubgraphwhich takes a boolean. If set to true, it will utilize the subgraph instead of directly querying the blockchain.
3. owner
ownerReturns the owner of the lootbox.
4. active
activeReturns the status of the lootbox.
5. permanentlyStopped
permanentlyStoppedReturns whether the lootbox is permanently stopped or not.
6. chainId
chainIdReturns the chainId.
7. creator
creatorReturns the address of the lootbox creator.
8. merkleRoot
merkleRootReturns the merkle root since we use the merkle tree method of whitelisting large number addresses.
9. remainingOpens
remainingOpensReturns the number of time a wallet can still open the lootbox.
10. hasPendingClaims
hasPendingClaimsReturns whether a wallet has some pending claims or not.
11. lootboxContents
lootboxContentsReturns the current state of the lootbox. Details like which item is present in the lootbox, quantity and tokenIds.
NOTE -
This function utilizes the subgraph, which may result in a slight delay in retrieving the data.
Example output:
12. trustedForwarder
trustedForwarderGet the current trusted forwarder address.
13. getRewardsForAddress
getRewardsForAddressGet the rewards for the address which has opened the lootbox. It returns all the accumulated rewards.
Example output:
14. getAllRewardsForAddress
getAllRewardsForAddressReturns all the rewards a wallet has gotten till now. Uses subgraph
Example output:
Last updated