usePack() function
Warning: This API is now obsolete.
This hook is deprecated and will be removed in a future major version. You should use instead.
- const pack = usePack("0x1234...");
+ const pack = useContract("0x1234...", "pack").contract;
Hook for getting an instance of a Pack
contract. This contract supports the creation of on-chain luck-based lootboxes.
Example
import { useContract } from '@thirdweb-dev/react'
export default function Component() {
const { contract } = usePack("<YOUR-CONTRACT-ADDRESS>", "pack")
// 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 contract.getAll()
return packs
}
...
}
Signature:
export declare function usePack(
contractAddress: RequiredParam<string>,
): import("@thirdweb-dev/sdk").Pack | undefined;
Parameters
Parameter | Type | Description |
---|---|---|
contractAddress | RequiredParam<string> | the address of the Pack contract, found in your thirdweb dashboard |
Returns:
import("@thirdweb-dev/sdk").Pack | undefined