LYNC
DashboardSupport
  • 👋Introducing LYNC
  • Products
    • LYNC Account Abstraction SDK
    • LYNC Account Abstraction WebGL SDK
    • Metamask Wallet
    • LYNC Metamask PC SDK
    • OKX Wallet
    • LYNC In-Game Marketplace SDK
    • NFT Fetcher
    • No-Code Smart Contract Deployer
    • EVM Lootbox SDK
      • Getting Started
      • Using the SDK
        • Creating a new lootbox
        • Opening a lootbox
        • Claiming rewards
        • Whitelisting users using lootbox
        • Lootbox admin functions
        • Useful information functions from LyncLootBox class
        • Multicall : opening and claiming multiple lootboxes in a single transaction
      • Example Codes in React & TypeScript
        • Example code for creating a new lootbox
        • Example code for opening a lootbox
        • Example code for claiming a lootbox
    • Launch your products on Telegram
      • Configure Your Telegram Bot
      • Deploying Your Product on TG
  • APTOS
    • LYNC Paymaster - Supporting Aptos
      • How to Register on LYNC Dashboard
      • How to Create Paymaster
      • How to Fund the Paymaster
      • Module & Function Whitelist
      • How to Integrate Paymaster
        • Unity
        • API
        • JavaScript/ TypeScript
    • LYNC Unity Aptos SDK
    • Keyless Accounts
      • Configure Your OIDC Provider
      • Integrate Keyless in Unity
    • Wallet Creation and Transaction APIs
      • Pre-requisites
      • Integration
        • API Overview
        • Create a new wallet
        • Get already created wallet
        • Mint NFT transactions
        • Send generic transactions on Aptos
    • LYNC Social Login SDK on Aptos
      • Getting Started
      • Using the SDK
      • Example Codes in React & TypeScript
      • Types Used in the Methods Provided by the SDK
      • Other Specification
    • LYNC Aptos Lootbox
      • Getting Started
      • Creating a Lootbox
      • Opening a Lootbox
      • Claiming the Rewards
      • Conclusion
  • Movement Labs
    • 📇Indexer
      • How to run index custom data?
      • Example Queries
        • Get Token Info
        • Get Token Balances
        • Get NFTs Owned by an Account
    • NFT Deployer
    • LYNC Social Login SDK on Movement
      • Getting Started
      • Using the SDK
      • Example Codes in React & TypeScript
      • Types and Enums Used in the Methods Provided by the SDK
      • Other Specification
    • LYNC Unity Movement SDK
    • Wallet Creation and Transaction APIs
      • Pre-requisites
      • Integration
        • API Overview
        • Create a new wallet
        • Get already created wallet
        • Mint NFT transactions
    • LYNC Paymaster - Supporting Movement
      • How to Register on LYNC Dashboard
      • How to Create Paymaster
      • How to Fund the Paymaster
      • Module & Function Whitelist
      • How to Integrate Paymaster
        • JavaScript/ TypeScript
  • Supra
    • LYNC Paymaster - Supporting Supra L1
      • How to Register on LYNC Dashboard
      • How to Create Paymaster
      • How to Fund the Paymaster
      • Module & Function Whitelist
      • How to Integrate Paymaster
        • JavaScript/ TypeScript
    • LYNC Unity SUPRA SDK
    • Wallet Creation and Transaction APIs
      • Pre-requisites
      • Integration
        • API Overview
        • Create a new wallet
        • Get already created wallet
        • Mint NFT transactions
  • Fuel
    • LYNC Unity Fuel SDK
    • LYNC NFT Deployer
      • Introduction
      • Getting Started
      • Deploying Your NFTs
        • Launch Your Entire Collection
      • Troubleshooting and FAQs
    • LYNC Fuel Lootbox
      • Getting Started
      • Creating a Lootbox
      • Opening a Lootbox
      • Claiming the Rewards
      • Conclusion
    • Wallet Creation and Transaction APIs
      • Pre-requisites
      • Integration
        • API Overview
        • Create a new wallet
        • Get already created wallet
    • Fuel Marketplace NPM SDK
      • Getting Started
      • Using the SDK
        • Using hooks to get the marketplace data
        • Using services provided by the SDK to list, buy, and manage tokens
        • Some useful functions provided by the SDK
        • Error codes for the SDK
        • Interfaces and Enums provided by the SDK
      • Support
  • Metis
    • Wallet Creation and Transaction APIs
      • Pre-requisites
      • Integration
        • API Overview
        • Create a new wallet
        • Get already created wallet
        • Mint NFT transactions
  • NPM Packages
    • Marketplace
      • Hook: useAllCollectionNFT
      • Hook: useAllBuyNFT
      • Hook: useAllOwnerNFT
      • Hook: useNFTDetails
      • Hook: useAllNFTForRent
Powered by GitBook
On this page
  • Method Overview:
  • Syntax:
  • Parameters:
  • Return Value:
  • Errors:
  • Important Notes:
  1. Products
  2. EVM Lootbox SDK
  3. Using the SDK

Creating a new lootbox

For creating a new Lootbox using @lyncworld/lootbox-evm-sdk, you will need to create an instance of LyncLootboxManager class provided by the SDK. Here is an example of creating a new Lootbox using the SDK:

import { LyncLootBoxCreator, ChainIdentifier } from "@lyncworld/lootbox-evm-sdk";
const lootboxCreator = new LyncLootBoxCreator();
await lootboxCreator.initialize(ChainIdentifier.BASE_SEPOLIA, provider);

After creating an instance of Lync Lootbox Creator class, you can utilize the createLootbox method provided by the LyncLootBoxCreator class. Here is the complete specification of the method and an example function for creating a new Lootbox:

Method Overview:

The createLootbox function is an asynchronous method in the LyncLootBoxCreator class. This function is responsible for creating a new loot box with ERC20, ERC721, and ERC1155 items.

Syntax:

async createLootbox(
    signer: Signer,
    erc20Items: ERC20Item[],
    erc721Items: ERC721Item[],
    erc1155Items: ERC1155Item[],
    whitelist: string[],
    trustedForwarder: string, // for meta transactions
    activateLootbox: boolean,
    maxOpensPerAddress: number,
    gasOverrides?: Overrides = {}

): Promise<TransactionResponse[]>

Parameters:

  • signer (Signer)*: The signer who will be signing the transactions.

  • erc20Items (ERC20Item[])*: An array of ERC20 items to be included in the loot box.

  • erc721Items (ERC721Item[])*: An array of ERC721 items to be included in the loot box.

  • erc1155Items (ERC1155Item[])*: An array of ERC1155 items to be included in the loot box.

  • whitelist (string[])*: An array of addresses that are whitelisted. Keep empty for no whitelist.

  • trustedForwarder (string)*: The address of the trusted forwarder for meta transactions. Pass in zero address if you don’t want to enable meta txns.

  • activateLootbox (boolean)*: A boolean indicating whether to start the loot box.

  • maxOpensPerAddress (number)*: The maximum number of times each address can open the lootbox

  • gasOverrides : Gas override parameters (such as gasLimit, gasPrice, and maxFeePerGas from ethers) that you may need to adjust if transactions are failing to go through.

All the parameters marked with * in the above list are required parameters for creating a loot box.

Return Value:

This function returns a Promise that resolves to an array of TransactionResponse objects. Each TransactionResponse object contains the transaction, the receipt of the transaction, and additional data related to the transaction.

Errors:

This function throws a LootBoxError if:

  • Approval fails for ERC20, ERC721, or ERC1155 items.

  • Lootbox creation fails.

Important Notes:

  • For an existing ERC20, ERC1155 or ERC721 item, name, symbol, and uriBase (in case of ERC1155 and ERC721 items) is not required. Therefore, you can pass empty strings as a value for these arguments:

    • Examples:

      // For existing ERC20 item:
      const existingERC20Item = {
        contractAddress: "0x...", // contract address of existing ERC20 token
        name: "", // pass empty string for existing token
        symbol: "", // pass empty string for existing token
        ...
      }
      
      // For existing ERC1155 item:
      const existingERC1155Item = {
      	contractAddress: "0x...", // contract address of existing ERC1155 collection
        name: "", // pass empty string for existing collection
        symbol: "", // pass empty string for existing collection
        uriBase: "", // pass empty string for existing collection
        ...
      }
      
      // For existing ERC721 item:
      const existingERC721Item = {
      	contractAddress: "0x...", // contract address of existing ERC721 collection
        name: "", // pass empty string for existing collection
        symbol: "", // pass empty string for existing collection
        uriBase: "", // pass empty string for existing collection
        ...
      }
      
  • For a new ERC20, ERC1155 or ERC721 item, pass the zero address as a value of the contractAddress for ERC20Item, ERC1155Item, or ERC721Item.

    • Examples:

      import { ethers } from "ethers";
      
      // For existing ERC20 item:
      const existingERC20Item = {
        contractAddress: ethers.constants.AddressZero, // zero address for new ERC20 token
        ...
      }
      
      // For existing ERC1155 item:
      const existingERC1155Item = {
      	contractAddress: ethers.constants.AddressZero, // zero address for new ERC1155 collection
        ...
      }
      
      // For existing ERC721 item:
      const existingERC721Item = {
      	contractAddress: ethers.constants.AddressZero, // zero address for new ERC721 collection
        ...
      }
      

REMARKS -

This function is part of the LyncLootBoxCreator class and cannot be called independently. It must be called on an instance of the LyncLootBoxCreator class.

PreviousUsing the SDKNextOpening a lootbox

Last updated 8 months ago