npm package: @sign-global/tokentable
Description: ## Install
Latest version: 1.8.2



# @sign-global/tokentable

## Install

```bash
npm install @sign-global/tokentable
```

## Based 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.

```typescript
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

```typescript
const claims = await client.getAirdropClaims({
  address: "user_address"
})
```


### Get Airdrop Projects Info

```typescript
// Get project list
const projects = client.getProjectInfo()
```


### Claim Airdrop


#### TON Chain Claiming

```typescript
const result = await tonClient.claimAirdrop({
  claimId: "claim_id",
  walletClient: TonConnectUI
}, {
  onLoading: () => {
    // Handle loading state
  }
})
```


#### EVM Chain Claiming

```typescript
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

```typescript
const isClaimed = await client.checkClaimed("claim_id")
```

### Batch Check Claimed (EVM Chain Only)

```typescript
const isClaimedArr = await client.batchCheckClaimed()
```


### TON Chain Specific Features

Check if contract is paused:

```typescript
const isPaused = await tonClient.getPaused()
```

## Important Notes



1. Before calling claim-related methods, you need to call `getAirdropClaims` to get claim information


2. TON chain and EVM chain use different claiming methods


3. 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:

```typescript
try {
  const claims = await client.getAirdropClaims({
    address: "user_address"
  })
} catch (error) {
  console.error("Failed to fetch claims:", error)
}
```


## Based Identity Airdrop

### AddProvider

```typescript
import { EvmProvider,SolanaProvider } from '@sign-global/tokentable';


const App = ({children}) => {
  return (
    <EvmProvider>
      <SolanaProvider>
        {children}
      </SolanaProvider>
    </EvmProvider>
  )
}

```

### Initialization

```typescript
import { SignatureAirdropClient } from '@sign-global/tokentable';

const client = new SignatureAirdropClient({
  projectId: 'your_project_id',    // Project ID
});
```

### Main Features

#### Get Airdrop Claims

```typescript
const res = await client.getClaims();

console.log(res);
```

#### Connect Identity

```typescript
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

``` typescript
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
``` typescript
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:

``` typescript
try {
  await client.claimAirdrop({...});
} catch (error) {
  console.error('Claim failed:', error);
}
```