Overview
Subscription is a payment charged periodically
To create your own subscription, first deploy the category smartcontract
contract MyGameBattlePass is InventoryCategoryNFT {
string public override name = "Battle passes";
string public override description = "Battle passes";
string public override imageUrl = "http://example.com/battle_passes.webp";
}
Once category NFT is deployed, it's address is used as category identifier. Then you need to deploy the subscription NFT
contract MyGameMonthlyBattlePassItem is SubscriptionNFT {
string public override name = "Monthly pass";
string public override description = "Monthly battle pass";
string public override imageUrl = "http://example.com/monthly_battle_pass.webp";
address[] public override categories = [0xf20e05E89758Cc985E7d80d33F2f6D8573A17827];
bool public override transferable = false;
uint256 public override price = 10 * 10**18;
uint256 public override period = SubscriptionPeriod.Monthly;
address public override payToken = 0x2A24CC451ca8Ab8A77EcD7483080E3Dce47B8578;
LootboxMode public override mode = LootboxMode.BOX;
address[] public override itemsInside = [
0x52B38e83fdEa0c5D52E558B29ffd22DC5d7D04Fa,
0x0d2b3DF1fCed0ad692d852feEe0320d68C95933D,
0xeC33aEB0C733705a8374601082B3C05ddC1ca891
];
address[] public override amounts = [150, 1, 1];
}
After contract deployment user can request subscription creation
const userInventory = await gamingSdk.user.current.subscriptions.create(SUBSCRIPTION_ITEM_ADDRESS, 1);