@sign-global/tokentable
v1.8.1
Published
## Install
Readme
@sign-global/tokentable
Install
npm install @sign-global/tokentableBased MerkleTree Airdrop
Initialization
Initialization AirdropClient
AirdropClient supports initialization for two chain types:
The baseURL parameter determines which environment the SDK will interact with. The default is the production environment. You can pass the test environment address for testing.
import { AirdropClient } from '@sign-global/tokentable';
// Initialize with projectId
const client = new AirdropClient({
projectId: "your_project_id",
endpoint: "http://ec2-3-89-178-45.compute-1.amazonaws.com:3030/api" // optional
})
// Or initialize with slug
const client = new AirdropClient({
slug: "your_slug",
endpoint: "optional_api_base_url" // optional
})Main Features
Get Airdrop Claims
const claims = await client.getAirdropClaims({
address: "user_address"
})Get Airdrop Projects Info
// Get project list
const projects = client.getProjectInfo()Claim Airdrop
TON Chain Claiming
const result = await tonClient.claimAirdrop({
claimId: "claim_id",
walletClient: TonConnectUI
}, {
onLoading: () => {
// Handle loading state
}
})EVM Chain Claiming
import { useWalletClient } from 'wagmi';
const { data: walletClient } = useWalletClient();
// or const walletClient = await getWalletClient(wagmiConfig); //wagmi
const result = await evmClient.claimAirdrop({
claimId: "claim_id",
// wallet client
walletClient: walletClient
})Check Claim Status
const isClaimed = await client.checkClaimed("claim_id")Batch Check Claimed (EVM Chain Only)
const isClaimedArr = await client.batchCheckClaimed()TON Chain Specific Features
Check if contract is paused:
const isPaused = await tonClient.getPaused()Important Notes
Before calling claim-related methods, you need to call
getAirdropClaimsto get claim informationTON chain and EVM chain use different claiming methods
All asynchronous operations need proper error handling
Error Handling
The SDK will throw errors in the following cases:
Claim data not found
Contract wrapper not found
Unsupported chain type
API call failures
It's recommended to use try-catch for error handling:
try {
const claims = await client.getAirdropClaims({
address: "user_address"
})
} catch (error) {
console.error("Failed to fetch claims:", error)
}Based Identity Airdrop
AddProvider
import { EvmProvider,SolanaProvider } from '@sign-global/tokentable';
const App = ({children}) => {
return (
<EvmProvider>
<SolanaProvider>
{children}
</SolanaProvider>
</EvmProvider>
)
}
Initialization
import { SignatureAirdropClient } from '@sign-global/tokentable';
const client = new SignatureAirdropClient({
projectId: 'your_project_id', // Project ID
});Main Features
Get Airdrop Claims
const res = await client.getClaims();
console.log(res);Connect Identity
const checkEligibility = () => {
const res = await client.getClaims();
console.log(res);
}
// Connect Twitter account
await client.connectX({
onSuccess: () => {
checkEligibility();
console.log('Twitter connection successful');
},
onError: () => {
console.log('Twitter connection failed');
}
});
// Connect wallet
await client.connectWallet({
chainType: ChainType.Evm, // Supports Evm, Solana
onSuccess: () => {
checkEligibility();
console.log('Wallet connection successful');
},
onError: (error) => {
console.log('Wallet connection failed:', error);
}
});
// Disconnect identity
await client.disconnectIdentity({
recipientType: AirdropSigIdentityTypeEnum.Twitter,
recipient?: 'optional_recipient'
});
Claim Airdrop
EVM
import { useWalletClient } from 'wagmi';
const { data: walletClient } = useWalletClient();
// Check airdrop eligibility
const eligibility = await client.getClaims();
// Batch check claim status
const claimedStatus = await client.batchCheckClaimed();
const claimIds = eligibility.claims.map((claim) => claim.claimId);
// Claim airdrop
const txHash = await client.claimAirdrop({
claimIds: claimIds, // List of claim IDs
walletClient: walletClient, // Wallet client
recipient: 'optional_recipient' // Optional: recipient address
});
Solana
import { useWallet } from '@solana/wallet-adapter-react';
const walletClient = useWallet();
// Check airdrop eligibility
const eligibility = await client.getClaims();
// Batch check claim status
const claimedStatus = await client.batchCheckClaimed();
const claimIds = eligibility.claims.map((claim) => claim.claimId);
// Claim airdrop
await client.claimAirdrop({
claimIds: claimIds, // List of claim IDs
walletClient: walletClient, // Wallet client
});
Error Handling
All SDK methods throw appropriate errors. It's recommended to use try-catch for error handling:
try {
await client.claimAirdrop({...});
} catch (error) {
console.error('Claim failed:', error);
}