Tthewoodfish

solana-web3js-to-kit

Migrate @solana/web3.js v1 to @solana/kit — 10 transforms, 85% automation coverage

Public
0 executions

Run locally

npx codemod solana-web3js-to-kit

solana-web3js-to-kit

Automatically migrate your codebase from @solana/web3.js v1 to @solana/kit.

bash

What It Does

10 deterministic transforms. ~85% automation coverage. Zero false positives.

TransformWhat changes
01-imports@solana/web3.js@solana/kit named imports
02-connectionnew Connection(url)createSolanaRpc(url)
03-publickeynew PublicKey('str')address('str')
04-keypair-generateKeypair.generate()await generateKeyPairSigner()
05-keypair-props.publicKey.address, .secretKey.privateKey
06-system-transferSystemProgram.transfer({...})getTransferSolInstruction({...})
07-send-confirmsendAndConfirmTransaction(conn, tx, [s]) → kit signature
08-cluster-api-urlclusterApiUrl('devnet')'https://api.devnet.solana.com'
09-rpc-sendrpc.getBalance()rpc.getBalance().send() (all 40+ RPC methods)
10-type-annotationsPublicKey, Keypair, TransactionInstruction type annotations → kit equivalents

Before / After

Before:

typescript

After:

typescript

What Requires Manual Review

These patterns are intentionally left for human review:

  • Keypair.fromSecretKey(bytes) → use createKeyPairSignerFromBytes()
  • new PublicKey(buffer) → non-string PublicKey construction
  • Multi-instruction Transaction.add().add() chains → rewrite to pipe() pattern
  • Commitment level configuration → must move to per-call options
  • sendAndConfirmTransactionFactory wiring → requires rpc + rpcSubscriptions in scope

Running Individual Transforms

bash

Transforms are numbered — run them in order (01 → 10) if applying manually.


Tests

24 test fixtures across all 10 transforms. All passing.

bash

Source: github.com/thewoodfish/codemon

Ready to contribute?

Build your own codemod and share it with the community.