Getting started
Prepare an unsigned transaction with the direct RPC client and keep wallet authorization in your application.
The direct client uses RPC, an expected chain genesis hash, a program address, and a fee payer. It does not need a grapl API URL or key. Preparation reads accounts, assembles instructions, estimates costs, and simulates the final transaction. It does not sign or broadcast.
Prerequisites
- Node.js 24 and the
sdk/source package in a compatible grapl protocol checkout. - Access to a matching deployed program and funded disposable identities for local testing. No public deployment is advertised here.
- Your wallet integration and a trusted RPC endpoint for that deployment.
@grapl/sdk is currently a private source package implemented in the development checkout, not an announced npm release. Availability on a published branch must be checked separately. Build sdk/, then link its package directory from your application. The relative path below must point to your own checkout:
# From the protocol checkout's sdk directory
pnpm install --frozen-lockfile
pnpm build
# From your application's directory
pnpm add @grapl/sdk@file:../grapl/sdk @solana/kit@8.4.0Configure the client
This function accepts deployment values from your application's configuration. Verify the expected genesis hash independently; do not select a chain only by trusting a newly supplied RPC endpoint.
import { GraplClient, createKitRpcPort } from "@grapl/sdk";
import type { Address } from "@solana/kit";
export function connectGrapl(
rpcUrl: string,
programAddress: Address,
expectedGenesisHash: string,
feePayer: Address,
): GraplClient {
return new GraplClient({
rpc: createKitRpcPort(rpcUrl),
programAddress,
genesisHash: expectedGenesisHash,
feePayer,
});
}Prepare a first operation
Create a six-decimal token with an initial supply of one token, expressed as 1_000_000n atoms. mintAuthority: null requests no remaining mint authority. Token IDs must be unique for that creator.
import type { GraplClient, PreparedTransaction } from "@grapl/sdk";
export async function prepareFirstToken(
client: GraplClient,
tokenId: bigint,
): Promise<PreparedTransaction> {
return client.prepareCreateToken({
tokenId,
decimals: 6,
initialSupply: 1_000_000n,
mintAuthority: null,
});
}Inspect the result's summary, addresses, creations, requiredSigners, simulation, and cost estimates. A successful preparation means you have simulated unsigned v0 bytes, not a created token. Your application explicitly asks the wallet to sign, submits through RPC, and checks confirmation. See transaction lifecycle.
Choose your task
| Task | Guide | Current integration surface |
|---|---|---|
| Swap | ExactIn and ExactOut | Prepare a chosen pool with explicit caller-provided limits |
| Zap | Compose a zap | Generated builders and explicit instruction composition |
| Pool Manager | Create a market, manage positions | Token/pool creation, liquidity, positions and fee claims |
| Hooks | Resolve policy accounts | Explicit compatible resolver for hooked operations |
| Transactions & Accounts | Review and sign, pool ALTs | Unsigned preparation, simulation and lookup-table lifecycle |
These groups describe integration tasks, not separate client classes. The client does not select the best pool, produce native executable quotes, sign, send or confirm. Curve and zap composition uses generated builders; native SOL wrapping remains explicit. Use bigint amounts and validate the program/chain identity. See current limitations.
The isolated SDK verification covered 18 scenarios and 94 finalized transactions with disposable identities, including expected rejections. This is local verification of the tested source build; it does not establish a public deployment, npm publication or browser/WASM parity.