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");

Hierarchy

Constructors

  • Parameters

    • network: NetworkInput
    • address: string
    • storage: ThirdwebStorage<IpfsUploadBatchOptions>
    • options: undefined | {
          clientId?: string;
          gasSettings?: { maxPriceInGwei?: number | undefined; speed?: "standard" | "fast" | "fastest" | undefined; };
          gasless?: ({ openzeppelin: { relayerUrl: string; relayerForwarderAddress?: string | undefined; useEOAForwarder?: boolean | undefined; domainName?: string | undefined; domainVersion?: string | undefined; }; experimentalChainlessSupport?: boolean | undefined; }) | ({ biconomy: { apiId: string; apiKey: string; deadlineSeconds?: number | undefined; }; });
          gatewayUrls?: string[];
          readonlySettings?: { rpcUrl: string; chainId?: number | undefined; };
          secretKey?: string;
          supportedChains?: ({ rpc: string[]; chainId: number; nativeCurrency: { symbol: string; name: string; decimals: number; }; slug: string; })[];
      } = {}
    • abi: objectInputType<{
          inputs: ZodDefault<ZodArray<ZodObject<{
              components: ZodOptional<ZodArray<ZodObject<{
                  name: ZodDefault<ZodString>;
                  type: ZodString;
              }, "strip", ZodAny, objectOutputType<{
                  name: ZodDefault<ZodString>;
                  type: ZodString;
              }, ZodAny, "strip">, objectInputType<{
                  name: ZodDefault<ZodString>;
                  type: ZodString;
              }, ZodAny, "strip">>, "many">>;
              name: ZodDefault<ZodString>;
              stateMutability: ZodOptional<ZodString>;
              type: ZodString;
          }, "strip", ZodAny, objectOutputType<{
              components: ZodOptional<ZodArray<ZodObject<{
                  name: ZodDefault<ZodString>;
                  type: ZodString;
              }, "strip", ZodAny, objectOutputType<{
                  name: ZodDefault<ZodString>;
                  type: ZodString;
              }, ZodAny, "strip">, objectInputType<{
                  name: ZodDefault<ZodString>;
                  type: ZodString;
              }, ZodAny, "strip">>, "many">>;
              name: ZodDefault<ZodString>;
              stateMutability: ZodOptional<ZodString>;
              type: ZodString;
          }, ZodAny, "strip">, objectInputType<{
              components: ZodOptional<ZodArray<ZodObject<{
                  name: ZodDefault<ZodString>;
                  type: ZodString;
              }, "strip", ZodAny, objectOutputType<{
                  name: ZodDefault<ZodString>;
                  type: ZodString;
              }, ZodAny, "strip">, objectInputType<{
                  name: ZodDefault<ZodString>;
                  type: ZodString;
              }, ZodAny, "strip">>, "many">>;
              name: ZodDefault<ZodString>;
              stateMutability: ZodOptional<ZodString>;
              type: ZodString;
          }, ZodAny, "strip">>, "many">>;
          name: ZodDefault<ZodString>;
          outputs: ZodDefault<ZodArray<ZodObject<{
              components: ZodOptional<ZodArray<ZodObject<{
                  name: ZodDefault<ZodString>;
                  type: ZodString;
              }, "strip", ZodAny, objectOutputType<{
                  name: ZodDefault<ZodString>;
                  type: ZodString;
              }, ZodAny, "strip">, objectInputType<{
                  name: ZodDefault<ZodString>;
                  type: ZodString;
              }, ZodAny, "strip">>, "many">>;
              name: ZodDefault<ZodString>;
              stateMutability: ZodOptional<ZodString>;
              type: ZodString;
          }, "strip", ZodAny, objectOutputType<{
              components: ZodOptional<ZodArray<ZodObject<{
                  name: ZodDefault<ZodString>;
                  type: ZodString;
              }, "strip", ZodAny, objectOutputType<{
                  name: ZodDefault<ZodString>;
                  type: ZodString;
              }, ZodAny, "strip">, objectInputType<{
                  name: ZodDefault<ZodString>;
                  type: ZodString;
              }, ZodAny, "strip">>, "many">>;
              name: ZodDefault<ZodString>;
              stateMutability: ZodOptional<ZodString>;
              type: ZodString;
          }, ZodAny, "strip">, objectInputType<{
              components: ZodOptional<ZodArray<ZodObject<{
                  name: ZodDefault<ZodString>;
                  type: ZodString;
              }, "strip", ZodAny, objectOutputType<{
                  name: ZodDefault<ZodString>;
                  type: ZodString;
              }, ZodAny, "strip">, objectInputType<{
                  name: ZodDefault<ZodString>;
                  type: ZodString;
              }, ZodAny, "strip">>, "many">>;
              name: ZodDefault<ZodString>;
              stateMutability: ZodOptional<ZodString>;
              type: ZodString;
          }, ZodAny, "strip">>, "many">>;
          type: ZodString;
      }, ZodAny, "strip">[]
    • chainId: number
    • contractWrapper: ContractWrapper<Pack> = ...

    Returns Pack

Properties

_vrf?: PackVRF
abi: objectOutputType<{
    inputs: ZodDefault<ZodArray<ZodObject<{
        components: ZodOptional<ZodArray<ZodObject<{
            name: ZodDefault<ZodString>;
            type: ZodString;
        }, "strip", ZodAny, objectOutputType<{
            name: ZodDefault<ZodString>;
            type: ZodString;
        }, ZodAny, "strip">, objectInputType<{
            name: ZodDefault<ZodString>;
            type: ZodString;
        }, ZodAny, "strip">>, "many">>;
        name: ZodDefault<ZodString>;
        stateMutability: ZodOptional<ZodString>;
        type: ZodString;
    }, "strip", ZodAny, objectOutputType<{
        components: ZodOptional<ZodArray<ZodObject<{
            name: ZodDefault<ZodString>;
            type: ZodString;
        }, "strip", ZodAny, objectOutputType<{
            name: ZodDefault<ZodString>;
            type: ZodString;
        }, ZodAny, "strip">, objectInputType<{
            name: ZodDefault<ZodString>;
            type: ZodString;
        }, ZodAny, "strip">>, "many">>;
        name: ZodDefault<ZodString>;
        stateMutability: ZodOptional<ZodString>;
        type: ZodString;
    }, ZodAny, "strip">, objectInputType<{
        components: ZodOptional<ZodArray<ZodObject<{
            name: ZodDefault<ZodString>;
            type: ZodString;
        }, "strip", ZodAny, objectOutputType<{
            name: ZodDefault<ZodString>;
            type: ZodString;
        }, ZodAny, "strip">, objectInputType<{
            name: ZodDefault<ZodString>;
            type: ZodString;
        }, ZodAny, "strip">>, "many">>;
        name: ZodDefault<ZodString>;
        stateMutability: ZodOptional<ZodString>;
        type: ZodString;
    }, ZodAny, "strip">>, "many">>;
    name: ZodDefault<ZodString>;
    outputs: ZodDefault<ZodArray<ZodObject<{
        components: ZodOptional<ZodArray<ZodObject<{
            name: ZodDefault<ZodString>;
            type: ZodString;
        }, "strip", ZodAny, objectOutputType<{
            name: ZodDefault<ZodString>;
            type: ZodString;
        }, ZodAny, "strip">, objectInputType<{
            name: ZodDefault<ZodString>;
            type: ZodString;
        }, ZodAny, "strip">>, "many">>;
        name: ZodDefault<ZodString>;
        stateMutability: ZodOptional<ZodString>;
        type: ZodString;
    }, "strip", ZodAny, objectOutputType<{
        components: ZodOptional<ZodArray<ZodObject<{
            name: ZodDefault<ZodString>;
            type: ZodString;
        }, "strip", ZodAny, objectOutputType<{
            name: ZodDefault<ZodString>;
            type: ZodString;
        }, ZodAny, "strip">, objectInputType<{
            name: ZodDefault<ZodString>;
            type: ZodString;
        }, ZodAny, "strip">>, "many">>;
        name: ZodDefault<ZodString>;
        stateMutability: ZodOptional<ZodString>;
        type: ZodString;
    }, ZodAny, "strip">, objectInputType<{
        components: ZodOptional<ZodArray<ZodObject<{
            name: ZodDefault<ZodString>;
            type: ZodString;
        }, "strip", ZodAny, objectOutputType<{
            name: ZodDefault<ZodString>;
            type: ZodString;
        }, ZodAny, "strip">, objectInputType<{
            name: ZodDefault<ZodString>;
            type: ZodString;
        }, ZodAny, "strip">>, "many">>;
        name: ZodDefault<ZodString>;
        stateMutability: ZodOptional<ZodString>;
        type: ZodString;
    }, ZodAny, "strip">>, "many">>;
    type: ZodString;
}, ZodAny, "strip">[]
addPackContents: {
    prepare: ((...args) => Promise<Transaction<{
        data: (() => Promise<NFT>);
        id: BigNumber;
        receipt: TransactionReceipt;
    }>>);
    (...args): Promise<TResult>;
} = ...

Type declaration

    • (...args): Promise<TResult>
    • Add Pack Contents

      Parameters

      • Rest ...args: [packId: BigNumberish, packContents: {
            erc1155Rewards?: {
                contractAddress: string;
                quantityPerReward: Object;
                tokenId: Object;
            }[];
            erc20Rewards?: {
                contractAddress: string;
                quantityPerReward: string | number;
            }[];
            erc721Rewards?: {
                contractAddress: string;
                tokenId: Object;
            }[];
        }]

      Returns Promise<TResult>

      Remarks

      Add contents to an existing pack. See Pack.addPackContents

      Example

      const packContents = {
      // ERC20 rewards to be included in the pack
      erc20Rewards: [
      {
      contractAddress: "0x...",
      quantityPerReward: 5,
      quantity: 100,
      totalRewards: 20,
      }
      ],
      // ERC721 rewards to be included in the pack
      erc721Rewards: [
      {
      contractAddress: "0x...",
      tokenId: 0,
      }
      ],
      // ERC1155 rewards to be included in the pack
      erc1155Rewards: [
      {
      contractAddress: "0x...",
      tokenId: 0,
      quantityPerReward: 1,
      totalRewards: 100,
      }
      ],
      }

      const tx = await contract.addPackContents(packId, packContents);
  • prepare: ((...args) => Promise<Transaction<{
        data: (() => Promise<NFT>);
        id: BigNumber;
        receipt: TransactionReceipt;
    }>>)
      • (...args): Promise<Transaction<{
            data: (() => Promise<NFT>);
            id: BigNumber;
            receipt: TransactionReceipt;
        }>>
      • Parameters

        • Rest ...args: [packId: BigNumberish, packContents: {
              erc1155Rewards?: {
                  contractAddress: string;
                  quantityPerReward: Object;
                  tokenId: Object;
              }[];
              erc20Rewards?: {
                  contractAddress: string;
                  quantityPerReward: string | number;
              }[];
              erc721Rewards?: {
                  contractAddress: string;
                  tokenId: Object;
              }[];
          }]

        Returns Promise<Transaction<{
            data: (() => Promise<NFT>);
            id: BigNumber;
            receipt: TransactionReceipt;
        }>>

airdrop: {
    prepare: ((...args) => Promise<Transaction<Omit<TransactionResultWithMetadata<unknown>, "data">>>);
    (...args): Promise<TResult>;
} = ...

Type declaration

    • (...args): Promise<TResult>
    • Airdrop multiple NFTs

      Parameters

      • Rest ...args: [tokenId: BigNumberish, addresses: string[] | {
            address: string;
            quantity?: string | number;
        }[], fromAddress?: string, data: BytesLike]

      Returns Promise<TResult>

      Remarks

      Airdrop one or multiple NFTs to the provided wallet addresses.

      Twfeature

      ERC1155

      Example

      // The token ID of the NFT you want to airdrop
      const tokenId = "0";
      // Array of objects of addresses and quantities to airdrop NFTs to
      const addresses = [
      {
      address: "0x...",
      quantity: 2,
      },
      {
      address: "0x...",
      quantity: 3,
      },
      ];
      await contract.airdrop(tokenId, addresses);

      // You can also pass an array of addresses, it will airdrop 1 NFT per address
      const tokenId = "0";
      const addresses = [
      "0x...", "0x...", "0x...",
      ]
      await contract.airdrop(tokenId, addresses);
  • prepare: ((...args) => Promise<Transaction<Omit<TransactionResultWithMetadata<unknown>, "data">>>)
      • (...args): Promise<Transaction<Omit<TransactionResultWithMetadata<unknown>, "data">>>
      • Parameters

        • Rest ...args: [tokenId: BigNumberish, addresses: string[] | {
              address: string;
              quantity?: string | number;
          }[], fromAddress?: string, data: BytesLike]

        Returns Promise<Transaction<Omit<TransactionResultWithMetadata<unknown>, "data">>>

app: ContractAppURI<Pack>
contractWrapper: ContractWrapper<Pack>
create: {
    prepare: ((...args) => Promise<Transaction<TransactionResultWithId<NFT>>>);
    (...args): Promise<TResult>;
} = ...

Type declaration

    • (...args): Promise<TResult>
    • Create Pack

      Parameters

      • Rest ...args: [metadataWithRewards: {
            erc1155Rewards?: ({ tokenId: (string | number | bigint | BigNumber) & (string | number | bigint | BigNumber | undefined); contractAddress: string; quantityPerReward: (string | number | bigint | BigNumber) & (string | ... 3 more ... | undefined); totalRewards?: string | ... 3 more ... | undefined; })[];
            erc20Rewards?: ({ contractAddress: string; quantityPerReward: string | number; totalRewards?: string | number | bigint | BigNumber | undefined; })[];
            erc721Rewards?: ({ tokenId: (string | number | bigint | BigNumber) & (string | number | bigint | BigNumber | undefined); contractAddress: string; })[];
            openStartTime?: number | Date;
            packMetadata: Object;
            rewardsPerPack?: string | number | bigint | BigNumber;
        }]

      Returns Promise<TResult>

      Remarks

      Create a new pack with the given metadata and rewards and mint it to the connected wallet. See Pack.createTo

      Example

      const pack = {
      // The metadata for the pack NFT itself
      packMetadata: {
      name: "My Pack",
      description: "This is a new pack",
      image: "ipfs://...",
      },
      // ERC20 rewards to be included in the pack
      erc20Rewards: [
      {
      contractAddress: "0x...",
      quantityPerReward: 5,
      quantity: 100,
      totalRewards: 20,
      }
      ],
      // ERC721 rewards to be included in the pack
      erc721Rewards: [
      {
      contractAddress: "0x...",
      tokenId: 0,
      }
      ],
      // ERC1155 rewards to be included in the pack
      erc1155Rewards: [
      {
      contractAddress: "0x...",
      tokenId: 0,
      quantityPerReward: 1,
      totalRewards: 100,
      }
      ],
      openStartTime: new Date(), // the date that packs can start to be opened, defaults to now
      rewardsPerPack: 1, // the number of rewards in each pack, defaults to 1
      }

      const tx = await contract.create(pack);
  • prepare: ((...args) => Promise<Transaction<TransactionResultWithId<NFT>>>)
      • (...args): Promise<Transaction<TransactionResultWithId<NFT>>>
      • Parameters

        • Rest ...args: [metadataWithRewards: {
              erc1155Rewards?: ({ tokenId: (string | number | bigint | BigNumber) & (string | number | bigint | BigNumber | undefined); contractAddress: string; quantityPerReward: (string | number | bigint | BigNumber) & (string | ... 3 more ... | undefined); totalRewards?: string | ... 3 more ... | undefined; })[];
              erc20Rewards?: ({ contractAddress: string; quantityPerReward: string | number; totalRewards?: string | number | bigint | BigNumber | undefined; })[];
              erc721Rewards?: ({ tokenId: (string | number | bigint | BigNumber) & (string | number | bigint | BigNumber | undefined); contractAddress: string; })[];
              openStartTime?: number | Date;
              packMetadata: Object;
              rewardsPerPack?: string | number | bigint | BigNumber;
          }]

        Returns Promise<Transaction<TransactionResultWithId<NFT>>>

createTo: {
    prepare: ((...args) => Promise<Transaction<TransactionResultWithId<NFT>>>);
    (...args): Promise<TResult>;
} = ...

Type declaration

    • (...args): Promise<TResult>
    • Create Pack To Wallet

      Parameters

      • Rest ...args: [to: string, metadataWithRewards: {
            erc1155Rewards?: ({ tokenId: (string | number | bigint | BigNumber) & (string | number | bigint | BigNumber | undefined); contractAddress: string; quantityPerReward: (string | number | bigint | BigNumber) & (string | ... 3 more ... | undefined); totalRewards?: string | ... 3 more ... | undefined; })[];
            erc20Rewards?: ({ contractAddress: string; quantityPerReward: string | number; totalRewards?: string | number | bigint | BigNumber | undefined; })[];
            erc721Rewards?: ({ tokenId: (string | number | bigint | BigNumber) & (string | number | bigint | BigNumber | undefined); contractAddress: string; })[];
            openStartTime?: number | Date;
            packMetadata: Object;
            rewardsPerPack?: string | number | bigint | BigNumber;
        }]

      Returns Promise<TResult>

      Remarks

      Create a new pack with the given metadata and rewards and mint it to the specified address.

      Example

      const pack = {
      // The metadata for the pack NFT itself
      packMetadata: {
      name: "My Pack",
      description: "This is a new pack",
      image: "ipfs://...",
      },
      // ERC20 rewards to be included in the pack
      erc20Rewards: [
      {
      contractAddress: "0x...",
      quantityPerReward: 5,
      quantity: 100,
      totalRewards: 20,
      }
      ],
      // ERC721 rewards to be included in the pack
      erc721Rewards: [
      {
      contractAddress: "0x...",
      tokenId: 0,
      }
      ],
      // ERC1155 rewards to be included in the pack
      erc1155Rewards: [
      {
      contractAddress: "0x...",
      tokenId: 0,
      quantityPerReward: 1,
      totalRewards: 100,
      }
      ],
      openStartTime: new Date(), // the date that packs can start to be opened, defaults to now
      rewardsPerPack: 1, // the number of rewards in each pack, defaults to 1
      }

      const tx = await contract.createTo("0x...", pack);
  • prepare: ((...args) => Promise<Transaction<TransactionResultWithId<NFT>>>)
      • (...args): Promise<Transaction<TransactionResultWithId<NFT>>>
      • Parameters

        • Rest ...args: [to: string, metadataWithRewards: {
              erc1155Rewards?: ({ tokenId: (string | number | bigint | BigNumber) & (string | number | bigint | BigNumber | undefined); contractAddress: string; quantityPerReward: (string | number | bigint | BigNumber) & (string | ... 3 more ... | undefined); totalRewards?: string | ... 3 more ... | undefined; })[];
              erc20Rewards?: ({ contractAddress: string; quantityPerReward: string | number; totalRewards?: string | number | bigint | BigNumber | undefined; })[];
              erc721Rewards?: ({ tokenId: (string | number | bigint | BigNumber) & (string | number | bigint | BigNumber | undefined); contractAddress: string; })[];
              openStartTime?: number | Date;
              packMetadata: Object;
              rewardsPerPack?: string | number | bigint | BigNumber;
          }]

        Returns Promise<Transaction<TransactionResultWithId<NFT>>>

encoder: ContractEncoder<Pack>
erc1155: Erc1155<BaseERC1155 | BaseSignatureMintERC1155>
estimator: GasCostEstimator<Pack>
events: ContractEvents<Pack>
metadata: ContractMetadata<Pack, {
    deploy: ZodObject<{
        app_uri: ZodOptional<ZodString>;
        description: ZodOptional<ZodString>;
        external_link: ZodOptional<ZodString>;
        fee_recipient: ZodDefault<ZodUnion<[ZodType<string, ZodTypeDef, string>, ZodType<`0x${string}`, ZodTypeDef, `${string}.eth` | `${string}.cb.id`>]>>;
        image: ZodOptional<ZodUnion<[ZodUnion<[ZodTypeAny, ZodObject<{
            data: ZodUnion<[ZodTypeAny, ZodString]>;
            name: ZodString;
        }, "strip", ZodTypeAny, {
            data?: any;
            name: string;
        }, {
            data?: any;
            name: string;
        }>]>, ZodString]>>;
        name: ZodString;
        platform_fee_basis_points: ZodDefault<ZodNumber>;
        platform_fee_recipient: ZodDefault<ZodUnion<[ZodType<string, ZodTypeDef, string>, ZodType<`0x${string}`, ZodTypeDef, `${string}.eth` | `${string}.cb.id`>]>>;
        seller_fee_basis_points: ZodDefault<ZodNumber>;
        social_urls: ZodOptional<ZodRecord<ZodString, ZodString>>;
        symbol: ZodDefault<ZodString>;
        trusted_forwarders: ZodDefault<ZodArray<ZodUnion<[ZodType<string, ZodTypeDef, string>, ZodType<`0x${string}`, ZodTypeDef, `${string}.eth` | `${string}.cb.id`>]>, "many">>;
    }, "strip", ZodTypeAny, {
        app_uri?: string;
        description?: string;
        external_link?: string;
        fee_recipient: string;
        image?: any;
        name: string;
        platform_fee_basis_points: number;
        platform_fee_recipient: string;
        seller_fee_basis_points: number;
        social_urls?: Record<string, string>;
        symbol: string;
        trusted_forwarders: string[];
    }, {
        app_uri?: string;
        description?: string;
        external_link?: string;
        fee_recipient?: string;
        image?: any;
        name: string;
        platform_fee_basis_points?: number;
        platform_fee_recipient?: string;
        seller_fee_basis_points?: number;
        social_urls?: Record<string, string>;
        symbol?: string;
        trusted_forwarders?: string[];
    }>;
    input: ZodObject<{
        app_uri: ZodOptional<ZodString>;
        description: ZodOptional<ZodString>;
        external_link: ZodOptional<ZodString>;
        fee_recipient: ZodDefault<ZodUnion<[ZodType<string, ZodTypeDef, string>, ZodType<`0x${string}`, ZodTypeDef, `${string}.eth` | `${string}.cb.id`>]>>;
        image: ZodOptional<ZodUnion<[ZodUnion<[ZodTypeAny, ZodObject<{
            data: ZodUnion<[ZodTypeAny, ZodString]>;
            name: ZodString;
        }, "strip", ZodTypeAny, {
            data?: any;
            name: string;
        }, {
            data?: any;
            name: string;
        }>]>, ZodString]>>;
        name: ZodString;
        seller_fee_basis_points: ZodDefault<ZodNumber>;
        social_urls: ZodOptional<ZodRecord<ZodString, ZodString>>;
        symbol: ZodDefault<ZodString>;
    }, "strip", ZodTypeAny, {
        app_uri?: string;
        description?: string;
        external_link?: string;
        fee_recipient: string;
        image?: any;
        name: string;
        seller_fee_basis_points: number;
        social_urls?: Record<string, string>;
        symbol: string;
    }, {
        app_uri?: string;
        description?: string;
        external_link?: string;
        fee_recipient?: string;
        image?: any;
        name: string;
        seller_fee_basis_points?: number;
        social_urls?: Record<string, string>;
        symbol?: string;
    }>;
    output: ZodObject<{
        app_uri: ZodOptional<ZodString>;
        description: ZodOptional<ZodString>;
        external_link: ZodOptional<ZodString>;
        fee_recipient: ZodDefault<ZodUnion<[ZodType<string, ZodTypeDef, string>, ZodType<`0x${string}`, ZodTypeDef, `${string}.eth` | `${string}.cb.id`>]>>;
        image: ZodOptional<ZodString>;
        name: ZodString;
        seller_fee_basis_points: ZodDefault<ZodNumber>;
        social_urls: ZodOptional<ZodRecord<ZodString, ZodString>>;
        symbol: ZodDefault<ZodString>;
    }, "strip", ZodTypeAny, {
        app_uri?: string;
        description?: string;
        external_link?: string;
        fee_recipient: string;
        image?: string;
        name: string;
        seller_fee_basis_points: number;
        social_urls?: Record<string, string>;
        symbol: string;
    }, {
        app_uri?: string;
        description?: string;
        external_link?: string;
        fee_recipient?: string;
        image?: string;
        name: string;
        seller_fee_basis_points?: number;
        social_urls?: Record<string, string>;
        symbol?: string;
    }>;
}>

Type declaration

  • deploy: ZodObject<{
        app_uri: ZodOptional<ZodString>;
        description: ZodOptional<ZodString>;
        external_link: ZodOptional<ZodString>;
        fee_recipient: ZodDefault<ZodUnion<[ZodType<string, ZodTypeDef, string>, ZodType<`0x${string}`, ZodTypeDef, `${string}.eth` | `${string}.cb.id`>]>>;
        image: ZodOptional<ZodUnion<[ZodUnion<[ZodTypeAny, ZodObject<{
            data: ZodUnion<[ZodTypeAny, ZodString]>;
            name: ZodString;
        }, "strip", ZodTypeAny, {
            data?: any;
            name: string;
        }, {
            data?: any;
            name: string;
        }>]>, ZodString]>>;
        name: ZodString;
        platform_fee_basis_points: ZodDefault<ZodNumber>;
        platform_fee_recipient: ZodDefault<ZodUnion<[ZodType<string, ZodTypeDef, string>, ZodType<`0x${string}`, ZodTypeDef, `${string}.eth` | `${string}.cb.id`>]>>;
        seller_fee_basis_points: ZodDefault<ZodNumber>;
        social_urls: ZodOptional<ZodRecord<ZodString, ZodString>>;
        symbol: ZodDefault<ZodString>;
        trusted_forwarders: ZodDefault<ZodArray<ZodUnion<[ZodType<string, ZodTypeDef, string>, ZodType<`0x${string}`, ZodTypeDef, `${string}.eth` | `${string}.cb.id`>]>, "many">>;
    }, "strip", ZodTypeAny, {
        app_uri?: string;
        description?: string;
        external_link?: string;
        fee_recipient: string;
        image?: any;
        name: string;
        platform_fee_basis_points: number;
        platform_fee_recipient: string;
        seller_fee_basis_points: number;
        social_urls?: Record<string, string>;
        symbol: string;
        trusted_forwarders: string[];
    }, {
        app_uri?: string;
        description?: string;
        external_link?: string;
        fee_recipient?: string;
        image?: any;
        name: string;
        platform_fee_basis_points?: number;
        platform_fee_recipient?: string;
        seller_fee_basis_points?: number;
        social_urls?: Record<string, string>;
        symbol?: string;
        trusted_forwarders?: string[];
    }>
  • input: ZodObject<{
        app_uri: ZodOptional<ZodString>;
        description: ZodOptional<ZodString>;
        external_link: ZodOptional<ZodString>;
        fee_recipient: ZodDefault<ZodUnion<[ZodType<string, ZodTypeDef, string>, ZodType<`0x${string}`, ZodTypeDef, `${string}.eth` | `${string}.cb.id`>]>>;
        image: ZodOptional<ZodUnion<[ZodUnion<[ZodTypeAny, ZodObject<{
            data: ZodUnion<[ZodTypeAny, ZodString]>;
            name: ZodString;
        }, "strip", ZodTypeAny, {
            data?: any;
            name: string;
        }, {
            data?: any;
            name: string;
        }>]>, ZodString]>>;
        name: ZodString;
        seller_fee_basis_points: ZodDefault<ZodNumber>;
        social_urls: ZodOptional<ZodRecord<ZodString, ZodString>>;
        symbol: ZodDefault<ZodString>;
    }, "strip", ZodTypeAny, {
        app_uri?: string;
        description?: string;
        external_link?: string;
        fee_recipient: string;
        image?: any;
        name: string;
        seller_fee_basis_points: number;
        social_urls?: Record<string, string>;
        symbol: string;
    }, {
        app_uri?: string;
        description?: string;
        external_link?: string;
        fee_recipient?: string;
        image?: any;
        name: string;
        seller_fee_basis_points?: number;
        social_urls?: Record<string, string>;
        symbol?: string;
    }>
  • output: ZodObject<{
        app_uri: ZodOptional<ZodString>;
        description: ZodOptional<ZodString>;
        external_link: ZodOptional<ZodString>;
        fee_recipient: ZodDefault<ZodUnion<[ZodType<string, ZodTypeDef, string>, ZodType<`0x${string}`, ZodTypeDef, `${string}.eth` | `${string}.cb.id`>]>>;
        image: ZodOptional<ZodString>;
        name: ZodString;
        seller_fee_basis_points: ZodDefault<ZodNumber>;
        social_urls: ZodOptional<ZodRecord<ZodString, ZodString>>;
        symbol: ZodDefault<ZodString>;
    }, "strip", ZodTypeAny, {
        app_uri?: string;
        description?: string;
        external_link?: string;
        fee_recipient: string;
        image?: string;
        name: string;
        seller_fee_basis_points: number;
        social_urls?: Record<string, string>;
        symbol: string;
    }, {
        app_uri?: string;
        description?: string;
        external_link?: string;
        fee_recipient?: string;
        image?: string;
        name: string;
        seller_fee_basis_points?: number;
        social_urls?: Record<string, string>;
        symbol?: string;
    }>
open: {
    prepare: ((...args) => Promise<Transaction<Promise<{
        erc1155Rewards?: {
            contractAddress: string;
            quantityPerReward: Object;
            tokenId: Object;
        }[];
        erc20Rewards?: {
            contractAddress: string;
            quantityPerReward: string | number;
        }[];
        erc721Rewards?: {
            contractAddress: string;
            tokenId: Object;
        }[];
    }>>>);
    (...args): Promise<TResult>;
} = ...

Type declaration

    • (...args): Promise<TResult>
    • Open Pack

      Parameters

      • Rest ...args: [tokenId: BigNumberish, amount: BigNumberish, gasLimit: any]

      Returns Promise<TResult>

      Remarks

      • Open a pack to reveal the contained rewards. This will burn the specified pack and the contained assets will be transferred to the opening users wallet.

      Example

      const tokenId = 0
      const amount = 1
      const tx = await contract.open(tokenId, amount);
  • prepare: ((...args) => Promise<Transaction<Promise<{
        erc1155Rewards?: {
            contractAddress: string;
            quantityPerReward: Object;
            tokenId: Object;
        }[];
        erc20Rewards?: {
            contractAddress: string;
            quantityPerReward: string | number;
        }[];
        erc721Rewards?: {
            contractAddress: string;
            tokenId: Object;
        }[];
    }>>>)
      • (...args): Promise<Transaction<Promise<{
            erc1155Rewards?: {
                contractAddress: string;
                quantityPerReward: Object;
                tokenId: Object;
            }[];
            erc20Rewards?: {
                contractAddress: string;
                quantityPerReward: string | number;
            }[];
            erc721Rewards?: {
                contractAddress: string;
                tokenId: Object;
            }[];
        }>>>
      • Parameters

        • Rest ...args: [tokenId: BigNumberish, amount: BigNumberish, gasLimit: any]

        Returns Promise<Transaction<Promise<{
            erc1155Rewards?: {
                contractAddress: string;
                quantityPerReward: Object;
                tokenId: Object;
            }[];
            erc20Rewards?: {
                contractAddress: string;
                quantityPerReward: string | number;
            }[];
            erc721Rewards?: {
                contractAddress: string;
                tokenId: Object;
            }[];
        }>>>

owner: ContractOwner<Pack>
roles: ContractRoles<Pack, "transfer" | "minter" | "admin" | "asset">
royalties: ContractRoyalty<Pack, {
    deploy: ZodObject<{
        app_uri: ZodOptional<ZodString>;
        description: ZodOptional<ZodString>;
        external_link: ZodOptional<ZodString>;
        fee_recipient: ZodDefault<ZodUnion<[ZodType<string, ZodTypeDef, string>, ZodType<`0x${string}`, ZodTypeDef, `${string}.eth` | `${string}.cb.id`>]>>;
        image: ZodOptional<ZodUnion<[ZodUnion<[ZodTypeAny, ZodObject<{
            data: ZodUnion<[ZodTypeAny, ZodString]>;
            name: ZodString;
        }, "strip", ZodTypeAny, {
            data?: any;
            name: string;
        }, {
            data?: any;
            name: string;
        }>]>, ZodString]>>;
        name: ZodString;
        platform_fee_basis_points: ZodDefault<ZodNumber>;
        platform_fee_recipient: ZodDefault<ZodUnion<[ZodType<string, ZodTypeDef, string>, ZodType<`0x${string}`, ZodTypeDef, `${string}.eth` | `${string}.cb.id`>]>>;
        seller_fee_basis_points: ZodDefault<ZodNumber>;
        social_urls: ZodOptional<ZodRecord<ZodString, ZodString>>;
        symbol: ZodDefault<ZodString>;
        trusted_forwarders: ZodDefault<ZodArray<ZodUnion<[ZodType<string, ZodTypeDef, string>, ZodType<`0x${string}`, ZodTypeDef, `${string}.eth` | `${string}.cb.id`>]>, "many">>;
    }, "strip", ZodTypeAny, {
        app_uri?: string;
        description?: string;
        external_link?: string;
        fee_recipient: string;
        image?: any;
        name: string;
        platform_fee_basis_points: number;
        platform_fee_recipient: string;
        seller_fee_basis_points: number;
        social_urls?: Record<string, string>;
        symbol: string;
        trusted_forwarders: string[];
    }, {
        app_uri?: string;
        description?: string;
        external_link?: string;
        fee_recipient?: string;
        image?: any;
        name: string;
        platform_fee_basis_points?: number;
        platform_fee_recipient?: string;
        seller_fee_basis_points?: number;
        social_urls?: Record<string, string>;
        symbol?: string;
        trusted_forwarders?: string[];
    }>;
    input: ZodObject<{
        app_uri: ZodOptional<ZodString>;
        description: ZodOptional<ZodString>;
        external_link: ZodOptional<ZodString>;
        fee_recipient: ZodDefault<ZodUnion<[ZodType<string, ZodTypeDef, string>, ZodType<`0x${string}`, ZodTypeDef, `${string}.eth` | `${string}.cb.id`>]>>;
        image: ZodOptional<ZodUnion<[ZodUnion<[ZodTypeAny, ZodObject<{
            data: ZodUnion<[ZodTypeAny, ZodString]>;
            name: ZodString;
        }, "strip", ZodTypeAny, {
            data?: any;
            name: string;
        }, {
            data?: any;
            name: string;
        }>]>, ZodString]>>;
        name: ZodString;
        seller_fee_basis_points: ZodDefault<ZodNumber>;
        social_urls: ZodOptional<ZodRecord<ZodString, ZodString>>;
        symbol: ZodDefault<ZodString>;
    }, "strip", ZodTypeAny, {
        app_uri?: string;
        description?: string;
        external_link?: string;
        fee_recipient: string;
        image?: any;
        name: string;
        seller_fee_basis_points: number;
        social_urls?: Record<string, string>;
        symbol: string;
    }, {
        app_uri?: string;
        description?: string;
        external_link?: string;
        fee_recipient?: string;
        image?: any;
        name: string;
        seller_fee_basis_points?: number;
        social_urls?: Record<string, string>;
        symbol?: string;
    }>;
    output: ZodObject<{
        app_uri: ZodOptional<ZodString>;
        description: ZodOptional<ZodString>;
        external_link: ZodOptional<ZodString>;
        fee_recipient: ZodDefault<ZodUnion<[ZodType<string, ZodTypeDef, string>, ZodType<`0x${string}`, ZodTypeDef, `${string}.eth` | `${string}.cb.id`>]>>;
        image: ZodOptional<ZodString>;
        name: ZodString;
        seller_fee_basis_points: ZodDefault<ZodNumber>;
        social_urls: ZodOptional<ZodRecord<ZodString, ZodString>>;
        symbol: ZodDefault<ZodString>;
    }, "strip", ZodTypeAny, {
        app_uri?: string;
        description?: string;
        external_link?: string;
        fee_recipient: string;
        image?: string;
        name: string;
        seller_fee_basis_points: number;
        social_urls?: Record<string, string>;
        symbol: string;
    }, {
        app_uri?: string;
        description?: string;
        external_link?: string;
        fee_recipient?: string;
        image?: string;
        name: string;
        seller_fee_basis_points?: number;
        social_urls?: Record<string, string>;
        symbol?: string;
    }>;
}>

Configure royalties

Type declaration

  • deploy: ZodObject<{
        app_uri: ZodOptional<ZodString>;
        description: ZodOptional<ZodString>;
        external_link: ZodOptional<ZodString>;
        fee_recipient: ZodDefault<ZodUnion<[ZodType<string, ZodTypeDef, string>, ZodType<`0x${string}`, ZodTypeDef, `${string}.eth` | `${string}.cb.id`>]>>;
        image: ZodOptional<ZodUnion<[ZodUnion<[ZodTypeAny, ZodObject<{
            data: ZodUnion<[ZodTypeAny, ZodString]>;
            name: ZodString;
        }, "strip", ZodTypeAny, {
            data?: any;
            name: string;
        }, {
            data?: any;
            name: string;
        }>]>, ZodString]>>;
        name: ZodString;
        platform_fee_basis_points: ZodDefault<ZodNumber>;
        platform_fee_recipient: ZodDefault<ZodUnion<[ZodType<string, ZodTypeDef, string>, ZodType<`0x${string}`, ZodTypeDef, `${string}.eth` | `${string}.cb.id`>]>>;
        seller_fee_basis_points: ZodDefault<ZodNumber>;
        social_urls: ZodOptional<ZodRecord<ZodString, ZodString>>;
        symbol: ZodDefault<ZodString>;
        trusted_forwarders: ZodDefault<ZodArray<ZodUnion<[ZodType<string, ZodTypeDef, string>, ZodType<`0x${string}`, ZodTypeDef, `${string}.eth` | `${string}.cb.id`>]>, "many">>;
    }, "strip", ZodTypeAny, {
        app_uri?: string;
        description?: string;
        external_link?: string;
        fee_recipient: string;
        image?: any;
        name: string;
        platform_fee_basis_points: number;
        platform_fee_recipient: string;
        seller_fee_basis_points: number;
        social_urls?: Record<string, string>;
        symbol: string;
        trusted_forwarders: string[];
    }, {
        app_uri?: string;
        description?: string;
        external_link?: string;
        fee_recipient?: string;
        image?: any;
        name: string;
        platform_fee_basis_points?: number;
        platform_fee_recipient?: string;
        seller_fee_basis_points?: number;
        social_urls?: Record<string, string>;
        symbol?: string;
        trusted_forwarders?: string[];
    }>
  • input: ZodObject<{
        app_uri: ZodOptional<ZodString>;
        description: ZodOptional<ZodString>;
        external_link: ZodOptional<ZodString>;
        fee_recipient: ZodDefault<ZodUnion<[ZodType<string, ZodTypeDef, string>, ZodType<`0x${string}`, ZodTypeDef, `${string}.eth` | `${string}.cb.id`>]>>;
        image: ZodOptional<ZodUnion<[ZodUnion<[ZodTypeAny, ZodObject<{
            data: ZodUnion<[ZodTypeAny, ZodString]>;
            name: ZodString;
        }, "strip", ZodTypeAny, {
            data?: any;
            name: string;
        }, {
            data?: any;
            name: string;
        }>]>, ZodString]>>;
        name: ZodString;
        seller_fee_basis_points: ZodDefault<ZodNumber>;
        social_urls: ZodOptional<ZodRecord<ZodString, ZodString>>;
        symbol: ZodDefault<ZodString>;
    }, "strip", ZodTypeAny, {
        app_uri?: string;
        description?: string;
        external_link?: string;
        fee_recipient: string;
        image?: any;
        name: string;
        seller_fee_basis_points: number;
        social_urls?: Record<string, string>;
        symbol: string;
    }, {
        app_uri?: string;
        description?: string;
        external_link?: string;
        fee_recipient?: string;
        image?: any;
        name: string;
        seller_fee_basis_points?: number;
        social_urls?: Record<string, string>;
        symbol?: string;
    }>
  • output: ZodObject<{
        app_uri: ZodOptional<ZodString>;
        description: ZodOptional<ZodString>;
        external_link: ZodOptional<ZodString>;
        fee_recipient: ZodDefault<ZodUnion<[ZodType<string, ZodTypeDef, string>, ZodType<`0x${string}`, ZodTypeDef, `${string}.eth` | `${string}.cb.id`>]>>;
        image: ZodOptional<ZodString>;
        name: ZodString;
        seller_fee_basis_points: ZodDefault<ZodNumber>;
        social_urls: ZodOptional<ZodRecord<ZodString, ZodString>>;
        symbol: ZodDefault<ZodString>;
    }, "strip", ZodTypeAny, {
        app_uri?: string;
        description?: string;
        external_link?: string;
        fee_recipient: string;
        image?: string;
        name: string;
        seller_fee_basis_points: number;
        social_urls?: Record<string, string>;
        symbol: string;
    }, {
        app_uri?: string;
        description?: string;
        external_link?: string;
        fee_recipient?: string;
        image?: string;
        name: string;
        seller_fee_basis_points?: number;
        social_urls?: Record<string, string>;
        symbol?: string;
    }>

Remarks

Set your own royalties for the entire contract or per pack

Example

// royalties on the whole contract
contract.royalties.setDefaultRoyaltyInfo({
seller_fee_basis_points: 100, // 1%
fee_recipient: "0x..."
});
// override royalty for a particular pack
contract.royalties.setTokenRoyaltyInfo(packId, {
seller_fee_basis_points: 500, // 5%
fee_recipient: "0x..."
});
storage: ThirdwebStorage<IpfsUploadBatchOptions>
transfer: {
    prepare: ((...args) => Promise<Transaction<Omit<TransactionResultWithMetadata<unknown>, "data">>>);
    (...args): Promise<TResult>;
} = ...

Type declaration

    • (...args): Promise<TResult>
    • Transfer an NFT

      Parameters

      • Rest ...args: [to: string, tokenId: BigNumberish, amount: BigNumberish, data: BytesLike]

      Returns Promise<TResult>

      Remarks

      Transfer an NFT from the connected wallet to another wallet.

      Example

      // Address of the wallet you want to send the NFT to
      const toAddress = "{{wallet_address}}";
      const tokenId = "0"; // The token ID of the NFT you want to send
      const amount = 3; // How many copies of the NFTs to transfer
      await contract.transfer(toAddress, tokenId, amount);
  • prepare: ((...args) => Promise<Transaction<Omit<TransactionResultWithMetadata<unknown>, "data">>>)
      • (...args): Promise<Transaction<Omit<TransactionResultWithMetadata<unknown>, "data">>>
      • Parameters

        • Rest ...args: [to: string, tokenId: BigNumberish, amount: BigNumberish, data: BytesLike]

        Returns Promise<Transaction<Omit<TransactionResultWithMetadata<unknown>, "data">>>

contractRoles: readonly ["admin", "minter", "asset", "transfer"] = PACK_CONTRACT_ROLES

Accessors

Methods

  • Get NFT Balance

    Parameters

    • address: string
    • tokenId: BigNumberish

    Returns Promise<BigNumber>

    Remarks

    Get a wallets NFT balance (number of NFTs in this contract owned by the wallet).

    Example

    // Address of the wallet to check NFT balance
    const walletAddress = "{{wallet_address}}";
    const tokenId = 0; // Id of the NFT to check
    const balance = await contract.balanceOf(walletAddress, tokenId);
  • Get All Packs

    Parameters

    • Optional queryParams: {
          count?: number;
          start?: number;
      }

      optional filtering to only fetch a subset of results.

      • Optional count?: number
      • Optional start?: number

    Returns Promise<NFT[]>

    The pack metadata for all packs queried.

    Remarks

    Get all the data associated with every pack in this contract.

    By default, returns the first 100 packs, use queryParams to fetch more.

    Example

    const packs = await contract.getAll();
    console.log(packs;
  • Get Owned Packs

    Parameters

    • Optional walletAddress: string

    Returns Promise<NFT[]>

    The pack metadata for all the owned packs in the contract.

    Remarks

    Get all the data associated with the packs owned by a specific wallet.

    Example

    // Address of the wallet to get the packs of
    const address = "{{wallet_address}}";
    const packss = await contract.getOwned(address);
  • Get Pack Contents

    Parameters

    • packId: BigNumberish

      The id of the pack to get the contents of.

    Returns Promise<{
        erc1155Rewards: {
            contractAddress: string;
            quantityPerReward: string;
            tokenId: string;
            totalRewards: string;
        }[];
        erc20Rewards: {
            contractAddress: string;
            quantityPerReward: string;
            totalRewards: string;
        }[];
        erc721Rewards: {
            contractAddress: string;
            tokenId: string;
        }[];
    }>

    • The contents of the pack.

    Remarks

    Get the rewards contained inside a pack.

    Example

    const packId = 0;
    const contents = await contract.getPackContents(packId);
    console.log(contents.erc20Rewards);
    console.log(contents.erc721Rewards);
    console.log(contents.erc1155Rewards);

  • PRIVATE FUNCTIONS


    Parameters

    • metadataWithRewards: {
          erc1155Rewards: {
              contractAddress: string;
              quantityPerReward: string;
              tokenId: string;
              totalRewards: string;
          }[];
          erc20Rewards: {
              contractAddress: string;
              quantityPerReward: string;
              totalRewards: string;
          }[];
          erc721Rewards: {
              contractAddress: string;
              tokenId: string;
          }[];
      }
      • erc1155Rewards: {
            contractAddress: string;
            quantityPerReward: string;
            tokenId: string;
            totalRewards: string;
        }[]
      • erc20Rewards: {
            contractAddress: string;
            quantityPerReward: string;
            totalRewards: string;
        }[]
      • erc721Rewards: {
            contractAddress: string;
            tokenId: string;
        }[]

    Returns Promise<{
        contents: TokenStruct[];
        numOfRewardUnits: string[];
    }>

Generated using TypeDoc