Skip to main content

Pack class

Create lootboxes of NFTs with rarity based open mechanics.

Example

import { ThirdwebSDK } from "@thirdweb-dev/sdk";

const sdk = new ThirdwebSDK("{{chainName}}");
const contract = await sdk.getContract("{{contract_address}}", "pack");

Constructors

ConstructorModifiersDescription
(constructor)(network, address, storage, options, abi, chainId, contractWrapper)Constructs a new instance of the Pack class

Properties

PropertyModifiersTypeDescription
abiAbi
contractRolesstaticreadonly ["admin", "minter", "asset", "transfer"]
encoderContractEncoder<PackContract>
erc1155Erc1155<PackContract>
estimatorGasCostEstimator<PackContract>
eventsContractEvents<PackContract>
metadataContractMetadata<PackContract, typeof PackContractSchema>
ownerContractOwner<PackContract>
rolesContractRoles<PackContract, typeof Pack.contractRoles[number]>
royaltiesContractRoyalty<PackContract, typeof PackContractSchema>Configure royalties
vrfreadonlyPackVRFIf enabled in the contract, use the Chainlink VRF functionality to open packs

Methods

MethodModifiersDescription
addPackContents(packId, packContents)Add Pack Contents
create(metadataWithRewards)Create Pack
createTo(to, metadataWithRewards)Create Pack To Wallet
get(tokenId)Get a single Pack
getAddress()
getAll(queryParams)Get All Packs
getOwned(walletAddress)Get Owned Packs
getPackContents(packId)Get Pack Contents
getTotalCount()Get the number of packs created
isTransferRestricted()Get whether users can transfer packs from this contract
open(tokenId, amount)Open Pack

Signature:

export declare class Pack extends StandardErc1155<PackContract>

Extends: StandardErc1155<PackContract>