Address Derivation

Derive Claimr addresses locally when you have Twitter IDs and want to skip the API.

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

const CLAIMR = new PublicKey('3FsU2B8R7sP5ih7w2RoxtJEHfvBVeXtM8WwF6rjMbUrT');

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

const address = getClaimrAddress('44196397');

Twitter ID, not handle

The function takes a numeric ID. Handles change when people rebrand; IDs don't.

getClaimrAddress('44196397');   // right
getClaimrAddress('elonmusk');   // wrong - completely different address

Don't have the ID? The lookup API gives it to you:

When to use this vs API

API: You have a handle, want balance info, or are doing occasional lookups.

Local: You already have IDs, need to work offline, or are processing batches.

Last updated