@broxus/airdrop-ui
v1.0.6
Published
Ton aidrop ui utils
Downloads
13
Keywords
Readme
The library provides the AirdropUI
utility for implementing an airdrop form, examples of usage.
To implement your own logic:
checkQueue
-- checks if the user has an airdrop and their position in the queueimport { checkQueue } from '@broxus/airdrop-ui' const checkResult = await checkQueue(apiBaseUrl, workspaceId, userAddress)
checkResult
will have one of the following values:noReward
-- no reward for the user.inQueue
-- a reward is available, and the user is in the queue. checkResult.place contains the user's current position in the queue. In this case, you need to repeat thecheckQueue
operation every 30 seconds.signed
-- the user's turn has come, and you can proceed to the next step.
buildTransaction
-- prepares the data for calling a transactionimport { buildTransaction } from '@broxus/airdrop-ui' import { Clock, EverscaleStandaloneClient } from 'everscale-standalone-client' import { CHAIN } from '@tonconnect/ui' const clock = new Clock() const providerRpcClient = new ProviderRpcClient({ fallback: () => EverscaleStandaloneClient.create({ clock, connection: { data: { endpoint: 'https://jrpc-ton.broxus.com/rpc', }, id: Number(CHAIN.MAINNET), type: 'jrpc', }, }), forceUseFallback: true, }) const trxData = await buildTransaction(claimData, providerRpcClient, clock)
Execute the transaction
import { TonConnectUI } from '@tonconnect/ui' const tonConnectUI = new TonConnectUI() tonConnectUI.sendTransaction(trxData)