Skip to Content
DevelopersAirdrop SDKValidation and Errors

Validation and Errors

Mint Validation

Pre-check whether a mint is compatible with Airdrop Studio flows before building a transaction.

import { validateMintForAirdrop } from '@bonkit/airdrop-sdk' const result = await validateMintForAirdrop({ connection, mint })

Use this to fail early on unsupported mint configurations — for example, certain Token-2022 extensions that the airdrop program does not accept.

Validating before submitting an on-chain transaction saves the user from a confusing wallet-side rejection and avoids the SOL fee for a guaranteed-failed instruction.

Error Helpers

Translate low-level Solana or Anchor failures into stable application-level messages.

normalizeProgramError

Wraps any Solana or Anchor error and returns a normalized error object you can branch on safely.

import { normalizeProgramError } from '@bonkit/airdrop-sdk' try { // ...send transaction... } catch (cause) { const error = normalizeProgramError(cause) // error.code, error.name, error.message }

getAirdropStudioErrorByCode

Looks up a program error by numeric code.

import { getAirdropStudioErrorByCode } from '@bonkit/airdrop-sdk' const error = getAirdropStudioErrorByCode(6001)

getAirdropStudioErrorByName

Looks up a program error by Anchor error name.

import { getAirdropStudioErrorByName } from '@bonkit/airdrop-sdk' const error = getAirdropStudioErrorByName('AirdropNotStarted')
  1. Call validateMintForAirdrop before createMerkleAirdrop or createOnchainAirdrop.
  2. Wrap every transaction submission in a try-catch.
  3. Pass the catch error through normalizeProgramError for stable error inspection.
  4. Use getAirdropStudioErrorByCode or getAirdropStudioErrorByName to attach friendly UI messages.

Next Step

Continue to PDAs for deterministic address derivation, useful in indexers and migration scripts.

Last updated on