@airdropprotocol/sdk
v0.3.2
Published
Client SDK for airdrop-protocol: proof lookup, claim transaction building, types. Framework-agnostic.
Downloads
300
Maintainers
Readme
@airdropprotocol/sdk
Framework-agnostic client SDK for airdrop-protocol. Fetch proofs, look up allocations, build Jupiter-compatible claim transactions.
npm install @airdropprotocol/sdk @solana/web3.jsQuickstart
import { Connection, PublicKey } from "@solana/web3.js";
import {
fetchProofs,
lookupAllocation,
buildClaimTransaction,
isClaimed,
} from "@airdropprotocol/sdk";
const proofs = await fetchProofs("/proofs.json");
const allocation = lookupAllocation(proofs, walletPubkey.toBase58());
if (!allocation) return "not eligible";
const tx = await buildClaimTransaction({
connection,
claimant: walletPubkey,
distributor: new PublicKey("..."),
vault: new PublicKey("..."),
mint: new PublicKey(proofs.mint),
allocation,
});
const signed = await wallet.signTransaction(tx);
const sig = await connection.sendRawTransaction(signed.serialize());API
Proofs
fetchProofs(url)— load aproofs.jsonfrom any URL. Validates shape.lookupAllocation(proofs, owner)— returnsAllocation | nullwith raw + UI amounts and the proof.
Merkle (new in 0.3)
computeLeaf(index, owner, amount)— Jupiter-exact leaf encoding, Buffer output.verifyProof(root, leaf, proof)— sorted-pair keccak256 verifier. Accepts Buffer or 0x-hex.
Claim transactions
buildClaimTransaction(args)— returns a ready-to-signTransactionwith recent blockhash and ATA creation if needed.buildClaimInstruction(args)— lower-level: just the instruction, no blockhash / no ATA logic.isClaimed(connection, claimant, distributor)— checks whether theClaimStatusPDA exists on-chain.
Addresses
deriveDistributorAddress/deriveClaimStatusAddress— PDA helpers.JUPITER_DISTRIBUTOR_PROGRAM_ID— default programId; every helper accepts an override for forks.
Formatting (new in 0.3)
formatAmount(raw, decimals, opts?)— decimals-aware output with optional trim / compact / custom separators.shortAddress(addr, head?, tail?)/shortSignature(sig, head?, tail?)— truncation for UI.solscanTx(sig, cluster?)/solscanAccount(addr, cluster?)— explorer URL builders.
Full API reference: docs/sdk.md.
License
MIT
