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:
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:
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 lootboxgasOverrides
: 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
, orERC1155
items.Lootbox creation fails.
Important Notes:
For an existing
ERC20
,ERC1155
orERC721
item,name
,symbol
, anduriBase
(in case ofERC1155
andERC721
items) is not required. Therefore, you can pass empty strings as a value for these arguments:Examples:
For a new
ERC20
,ERC1155
orERC721
item, pass the zero address as a value of thecontractAddress
forERC20Item
,ERC1155Item
, orERC721Item
.Examples:
REMARKS -
This function is part of the
LyncLootBoxCreator
class and cannot be called independently. It must be called on an instance of theLyncLootBoxCreator
class.
Last updated