npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

grape-distributor-sdk

v0.1.6

Published

TypeScript SDK for the Grape Merkle Distributor Solana program.

Readme

grape-distributor-sdk

TypeScript SDK for the grape_merkle_distributor Anchor program at:

GCLMhBGsDMHbxYyayzZyDY85cF89XNGgEhss4GXd9cHk

Install

npm install grape-distributor-sdk

What this SDK includes

  • PDA helpers for distributor, vault authority, and claim status
  • Instruction builders for:
    • initialize_distributor
    • set_root
    • claim
    • close_claim_status (requires program upgrade)
    • clawback
  • Merkle helpers matching on-chain logic:
    • leaf hashing with LEAF_TAG
    • sorted-pair proof verification
  • Account decoders for Distributor and ClaimStatus
  • High-level client that builds claim instructions (including idempotent ATA create)
  • Optional claim + SPL Governance deposit flow for realm voting power

Basic usage

import { Connection, PublicKey, Transaction } from "@solana/web3.js";
import {
  GrapeDistributorClient,
  computeLeaf,
  verifyMerkleProofSorted,
} from "grape-distributor-sdk";

const connection = new Connection("https://api.mainnet-beta.solana.com");
const client = new GrapeDistributorClient(connection);

const mint = new PublicKey("MINT_PUBKEY_HERE");
const claimant = new PublicKey("CLAIMANT_PUBKEY_HERE");
const vault = new PublicKey("VAULT_TOKEN_ACCOUNT_HERE");

const index = 0n;
const amount = 1_000_000n;
const proof: Uint8Array[] = []; // fill with 32-byte siblings

const root = new Uint8Array(32); // distributor merkle root
const distributor = client.findDistributorPda(mint)[0];
const leaf = computeLeaf(distributor, claimant, index, amount);
const isValid = verifyMerkleProofSorted(leaf, proof, root);

if (!isValid) {
  throw new Error("Invalid local merkle proof");
}

const { instructions } = await client.buildClaimInstructions({
  claimant,
  mint,
  vault,
  index,
  amount,
  proof,
});

const tx = new Transaction().add(...instructions);

Claim directly into SPL Governance deposit

If the realm’s governing token mint is the same mint you are distributing, you can atomically:

  1. claim from distributor to claimant ATA
  2. deposit into the realm’s governing token holding account
const { instructions, tokenOwnerRecord } =
  await client.buildClaimAndDepositToRealmInstructions({
    claimant,
    mint,
    vault,
    index,
    amount,
    proof,
    realm: new PublicKey("REALM_PUBKEY_HERE"),
    governanceProgramId: new PublicKey("GovER5Lthms3bLBqWub97yVrMmEogzX7xNjdXpPPCVZw"),
  });

const tx = new Transaction().add(...instructions);

Optional:

  • pass governanceProgramVersion to skip version lookup RPC
  • pass depositAmount if you do not want to deposit the entire claimed amount

Claw back unclaimed vault tokens

const { instruction: clawbackIx } = client.buildClawbackInstruction({
  authority,
  mint,
  distributor,
  vault,
  amount: 5_000_000n,
});

Close claim status (rent reclaim)

claim_status rent can only be reclaimed if your on-chain program exposes a close instruction.

SDK usage after that instruction exists:

const { instruction: closeIx } = client.buildCloseClaimStatusInstruction({
  claimant,
  distributor,
  index,
});

const closeTx = new Transaction().add(closeIx);

If you already computed the PDA externally, you can pass claimStatus directly instead of index.

Allocation indexing

For the updated program, claim_status is derived with:

  • distributor
  • claimant
  • index (u64 little-endian)

This means each wallet must use a unique index for each distribution round.
Do not reuse the same (claimant, index) pair across rounds, or claims will collide on the same PDA.

Notes

  • claim_status PDA is derived by (distributor, claimant, index).
  • All roots/proof nodes must be exactly 32 bytes.