Skip to main content

usePack() function

Hook for getting an instance of a Pack contract. This contract supports the creation of on-chain luck-based lootboxes.

Example

import { usePack } from '@thirdweb-dev/react'

export default function Component() {
const pack = usePack("<YOUR-CONTRACT-ADDRESS>")

// Now you can use the pack contract in the rest of the component

// For example, this function will get all the packs on this contract
async function getPacks() {
const packs = await pack.getAll()
return packs
}

...
}

Signature:

export declare function usePack(contractAddress?: string): Pack | undefined;

Parameters

ParameterTypeDescription
contractAddressstring(Optional) the address of the Pack contract, found in your thirdweb dashboard

Returns:

Pack | undefined