Codama -> @solana/web3.js Legacy Renderer
June 2, 2026 · View on GitHub
@pratikbuilds/web3js-legacy is a Codama renderer for generating TypeScript
clients that use the classic @solana/web3.js APIs.
It takes a Solana IDL and generates code for:
- instruction builders
- account data types and fetch helpers
- defined type codecs
- PDA helpers
- program constants and exports
Use this when your project wants generated Solana client code but still works
with PublicKey, Connection, TransactionInstruction, and the rest of
@solana/web3.js v1.
Installation
pnpm add @pratikbuilds/web3js-legacy
pnpm add -D @codama/cli
Requires Node.js >=20.18.0.
Usage
Add the renderer to your codama.json.
{
"idl": "idl.json",
"scripts": {
"web3js": {
"from": "@pratikbuilds/web3js-legacy",
"args": ["src/generated"]
}
}
}
Run it:
pnpm codama run web3js
The first argument is the output folder. In this example, generated files are
written to src/generated.
Generated Code
The generated folder usually looks like this:
src/generated/
├── index.ts
├── accounts/
├── instructions/
├── pdas/
└── types/
Instruction builders return TransactionInstruction.
import { createTransferSolInstruction } from './generated/instructions/transferSol';
const instruction = createTransferSolInstruction(
{
source: payer.publicKey,
destination,
},
{
amount: 1_000_000n,
},
);
Account helpers can fetch and deserialize account data.
import { fetchNonceAccount } from './generated/accounts/nonce';
const nonce = await fetchNonceAccount(connection, nonceAddress);
Development
pnpm install
pnpm build
pnpm test
Useful focused commands:
pnpm run test:unit
pnpm run test:types
pnpm run test:e2e
pnpm run test:generated
Contributing
Contributions are welcome. Please keep changes focused and include tests for any generated-code behavior you change.
For renderer changes, it is helpful to:
- update the related unit tests
- regenerate affected fixtures under
test/e2e - run
pnpm build - run the relevant tests, or
pnpm test
License
MIT