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.
const itemAddresses = await lb.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.
3. owner​
Returns the owner of the lootbox.
const owner = await lb.owner();
console.log(owner); // Owner address
4. active​
Returns the status of the lootbox.
const isActive = await lb.active();
console.log(isActive); // true or false
5. permanentlyStopped​
Returns whether the lootbox is permanently stopped or not.
const killed = await lb.permanentlyStopped();
console.log(killed); // true or false
6. chainId​
Returns the chainId.
const chainId = await lb.chainId();
console.log(chainId); // chain id
7. creator​
Returns the address of the lootbox creator.
const creator = await lb.creator();
console.log(creator); // Address of lootbox creator
8. merkleRoot​
Returns the merkle root since we use the merkle tree method of whitelisting large number addresses.
const merkleRoot = await lb.merkleRoot();
console.log(merkleRoot); // merkleRoot Hex