Private
Optional
_vrfAdd Pack Contents
Rest
...args: [packId: BigNumberish, packContents: { Add contents to an existing pack. See Pack.addPackContents
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);
Rest
...args: [packId: BigNumberish, packContents: { Airdrop multiple NFTs
Rest
...args: [tokenId: BigNumberish, addresses: string[] | { Airdrop one or multiple NFTs to the provided wallet addresses.
ERC1155
// 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);
Rest
...args: [tokenId: BigNumberish, addresses: string[] | { Protected
contractCreate Pack
Rest
...args: [metadataWithRewards: { Create a new pack with the given metadata and rewards and mint it to the connected wallet. See Pack.createTo
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);
Rest
...args: [metadataWithRewards: { Create Pack To Wallet
Rest
...args: [to: string, metadataWithRewards: { Create a new pack with the given metadata and rewards and mint it to the specified address.
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);
Rest
...args: [to: string, metadataWithRewards: { Open Pack
Rest
...args: [tokenId: BigNumberish, amount: BigNumberish, gasLimit: any]const tokenId = 0
const amount = 1
const tx = await contract.open(tokenId, amount);
Rest
...args: [tokenId: BigNumberish, amount: BigNumberish, gasLimit: any]Configure royalties
Set your own royalties for the entire contract or per pack
// 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..."
});
Protected
storageTransfer an NFT
Rest
...args: [to: string, tokenId: BigNumberish, amount: BigNumberish, data: BytesLike]Transfer an NFT from the connected wallet to another wallet.
// 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);
Rest
...args: [to: string, tokenId: BigNumberish, amount: BigNumberish, data: BytesLike]Static
contractIf enabled in the contract, use the Chainlink VRF functionality to open packs
Get NFT Balance
Get a wallets NFT balance (number of NFTs in this contract owned by the wallet).
// 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);
Private
detectGet All Packs
Optional
queryParams: { optional filtering to only fetch a subset of results.
Optional
count?: numberOptional
start?: numberThe pack metadata for all packs queried.
Get all the data associated with every pack in this contract.
By default, returns the first 100 packs, use queryParams to fetch more.
const packs = await contract.getAll();
console.log(packs;
Get Owned Packs
Optional
walletAddress: stringThe pack metadata for all the owned packs in the contract.
Get all the data associated with the packs owned by a specific wallet.
// Address of the wallet to get the packs of
const address = "{{wallet_address}}";
const packss = await contract.getOwned(address);
Get Pack Contents
The id of the pack to get the contents of.
Get the rewards contained inside a pack.
const packId = 0;
const contents = await contract.getPackContents(packId);
console.log(contents.erc20Rewards);
console.log(contents.erc721Rewards);
console.log(contents.erc1155Rewards);
Private
toPRIVATE FUNCTIONS
Generated using TypeDoc
Create lootboxes of NFTs with rarity based open mechanics.
Example