@p76/batch-sdk
v0.2.2
Published
Encoder, decoder, and inner-instruction helpers for the p-token batch(0xFF) instruction. The same 0xFF that minted $76.
Maintainers
Readme
@p76/batch-sdk
Encoder, decoder, and inner-instruction helpers for the p-token batch(0xFF) instruction. The same 0xFF that minted $76.
Zero runtime dependencies. Compatible with any Solana web3 client (legacy @solana/web3.js or Anza's @solana/kit).
Install
npm install @p76/batch-sdkWhat it does
p-token's batch(0xFF) instruction packs multiple inner token instructions into a single CPI to the token program. This SDK handles the wire format both ways, plus typed helpers for the common inner ops (Transfer, MintTo, Burn, CloseAccount, TransferChecked).
Wire format:
[0xFF] [n_accounts: u8] [data_len: u8] [data ...] [n_accounts: u8] ...Use
High-level: typed inner builders
import { encodeBatchData, transferInner, closeAccountInner } from '@p76/batch-sdk';
// Three Transfer inners + one CloseAccount inner, all in one batch tx
const batchData = encodeBatchData([
transferInner(1_000_000n),
transferInner(2_500_000n),
transferInner(500_000n),
closeAccountInner(),
]);
// -> Uint8Array starting with 0xFF, ready to use as TransactionInstruction.dataPlace this batchData as the data field of a TransactionInstruction targeting the token program (TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA). The outer ix's keys must list the per-inner accounts in order: for the example above, [src, dest1, owner, src, dest2, owner, src, dest3, owner, ata_to_close, rent_dest, owner].
Available inner builders
| Builder | Numbers of accounts the outer ix consumes per inner | Wire format |
|---|---|---|
| transferInner(amount) | 3: [source, dest, owner] | 0x03 + amount LE u64 |
| mintToInner(amount) | 3: [mint, dest, mint_authority] | 0x07 + amount LE u64 |
| burnInner(amount) | 3: [account, mint, owner] | 0x08 + amount LE u64 |
| closeAccountInner() | 3: [account, destination, owner] | 0x09 |
| transferCheckedInner(amount, decimals) | 4: [source, mint, dest, owner] | 0x0C + amount LE u64 + decimals u8 |
For other Token program ops not yet wrapped, build the InnerIx manually:
import { encodeBatchData, type InnerIx, TOKEN_IX } from '@p76/batch-sdk';
const customInner: InnerIx = {
numAccounts: 2,
data: new Uint8Array([TOKEN_IX.APPROVE, /* ... */]),
};Low-level: raw encode/decode
import { encodeBatchData, decodeBatchData } from '@p76/batch-sdk';
// Wrap a single MintTo of 76,000,000 atomic units (the $76 genesis tx)
const encoded = encodeBatchData([
{
numAccounts: 3, // mint, dest_ata, mint_authority
data: new Uint8Array([
0x07, // MintTo disc
0x00, 0xab, 0x87, 0x04, 0x00, 0x00, 0x00, 0x00, // amount u64 LE
]),
},
]);
// -> Uint8Array(12) [255, 3, 9, 7, 0, 171, 135, 4, 0, 0, 0, 0]
const inners = decodeBatchData(encoded);
// -> [{ numAccounts: 3, data: Uint8Array(9) [...] }]What can be wrapped
Inner instructions are dispatched inside the p-token program. They cannot CPI to other programs. Valid inner discriminators (exposed as TOKEN_IX):
| Disc | Op | Builder |
|---:|---|---|
| 0 | InitializeMint | raw |
| 1 | InitializeAccount | raw |
| 3 | Transfer | transferInner |
| 4 | Approve | raw |
| 5 | Revoke | raw |
| 6 | SetAuthority | raw |
| 7 | MintTo | mintToInner |
| 8 | Burn | burnInner |
| 9 | CloseAccount | closeAccountInner |
| 10 | FreezeAccount | raw |
| 11 | ThawAccount | raw |
| 12 | TransferChecked | transferCheckedInner |
| 15 | BurnChecked | raw |
| 17 | SyncNative | raw |
| 18 | InitializeAccount3 | raw |
| 22 | InitializeImmutableOwner | raw |
CreateAssociatedTokenAccount lives in the ATA program, not p-token, so it cannot be wrapped. See BATCH_FORMAT.md in the parent repo for the dispatch source.
Production proof
Three batch(0xFF) inner ops verified end-to-end on Solana mainnet by the p76 ATA Factory app:
| Inner | First mainnet tx |
|---|---|
| MintTo | 5cqt...iW8 ($76 genesis, 14 May 2026) |
| Transfer | 3ZGf...Nn2G |
| CloseAccount | 2QWh...3ABG |
Benchmarks
Per-ATA CU measured at ~15,500 CU on devnet (post-SIMD-0266 p-token activation). Mainnet observed even lower at 8-12k for createATA, ~2.5k for CloseAccount inside a batch. See BENCHMARKS.md for the full table and the reproducible script.
Why this exists
$76 is a memecoin minted via the first-ever batch(0xFF) instruction on Solana mainnet (May 2026). This package was extracted from the p76 ATA Factory app so other Solana projects can build on the same primitive without reimplementing the wire format.
Credits
batch(0xFF) is a p-token instruction. p-token is the Pinocchio-based Token program rewrite shipped by Anza and activated on Solana mainnet on 2026-05-13 via SIMD-0266. This SDK encodes the wire format; the runtime that dispatches every batch call is Anza's implementation.
Changelog
0.2.0(2026-05-22): typed inner builders (transferInner,mintToInner,burnInner,closeAccountInner,transferCheckedInner),TOKEN_IXconstants. Wire encoder/decoder unchanged.0.1.0(2026-05-22): initial release.encodeBatchData+decodeBatchData.
License
MIT.
