Airdrops
Last updated
Last updated
It is possible to incentivize and reward users in experiences by dropping items directly to their wallet as part of the experience mechanics. This should be done on the server side, and the player must have a connected wallet for it to work. Make sure the inventory is set up as well. In the airdrop node, you need to set two values:
YomPlayer: Specify the player to whom the item will be airdropped.
Item ID: Provide the ID of the item that will be airdropped. There are separate IDs for devnet and mainnet.
The airdrop node will add an item based on the item ID to the player's wallet. Please note that the airdrop function will not work for users who haven't logged in with a wallet.
If you want to check if a user has already received an airdrop, you can follow these steps:
Retrieve the YomPlayer of the player.
Get the inventory of the YomPlayer.
Check if there is an item in the inventory with the ID of your master NFT ID. If an item with that ID exists, it means the user has already received the airdrop.
To check if a user has a wallet connected, follow these steps:
Get the player you want to check.
Retrieve the YomPlayer from that player.
Get the wallet of the YomPlayer.
Check if the wallet ID is empty. If it's not empty, it means the user has a wallet connected.
Fetching the wallet may take some time, so there is a callback function called "OnInventoryFetched" that you can use. To check if the wallet has been fetched, do the following:
Get the YomPlayer from the player.
Check if the YomPlayer has a valid inventory.
Bind an event to the "OnInventoryFetched" callback to be notified when the inventory is fetched.
Note: Airdrops last until the maximum supply of the item has been reached.