Overview

No package required. Use the API directly or copy the derivation functions below.

API vs Local Derivation

Task
Recommendation

Look up by handle

API (handles Twitter ID resolution)

Derive from Twitter ID

Local (if you already have the ID)

Check balance

API (combines PDA and vault balances)

Trigger collection

API (handles transaction building)

Reference Implementation

import { PublicKey } from '@solana/web3.js';

const CLAIMR = new PublicKey('3FsU2B8R7sP5ih7w2RoxtJEHfvBVeXtM8WwF6rjMbUrT');
const PUMP = new PublicKey('6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P');

function getClaimrAddress(twitterId: string): PublicKey {
  const [pda] = PublicKey.findProgramAddressSync(
    [Buffer.from('claimr'), Buffer.from(twitterId)],
    CLAIMR
  );
  return pda;
}

function getCreatorVault(creator: PublicKey): PublicKey {
  const [vault] = PublicKey.findProgramAddressSync(
    [Buffer.from('creator-vault'), creator.toBuffer()],
    PUMP
  );
  return vault;
}

For local derivation: npm install @solana/web3.js

Last updated