usePack
Deprecated
This hook is deprecated and will be removed in a future major version. You should use useContract 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.
function usePack(
contractAddress: RequiredParam<string>,
): undefined | Pack;
Parameters
Returns
type ReturnType = undefined | Pack;
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
}
...
}