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

Checks if the lootbox is empty or not.

const empty = await lb.isEmpty();
console.log(empty); // true or false

2. itemAddresses

Lists the item addresses that are present in the lootbox.

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.

3. owner

Returns the owner of the lootbox.

4. active

Returns the status of the lootbox.

5. permanentlyStopped

Returns whether the lootbox is permanently stopped or not.

6. chainId

Returns the chainId.

7. creator

Returns the address of the lootbox creator.

8. merkleRoot

Returns the merkle root since we use the merkle tree method of whitelisting large number addresses.

9. remainingOpens

Returns the number of time a wallet can still open the lootbox.

10. hasPendingClaims

Returns whether a wallet has some pending claims or not.

11. lootboxContents

Returns 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

Get the current trusted forwarder address.

13. getRewardsForAddress

Get the rewards for the address which has opened the lootbox. It returns all the accumulated rewards.

Example output:

14. getAllRewardsForAddress

Returns all the rewards a wallet has gotten till now. Uses subgraph

Example output:

Last updated