solana-foundation/solana-web3.js/web3js-v1-to-v3-migration
Claude Code and agent skill by solana-foundation/solana-web3.js
- community
Checking that the SKILL.md file is still in the repository.
Migrate legacy @solana/web3.js v1 applications to v3, including the `@solana/spl-token` → `@solana-program/token` token surface. Use when auditing or fixing code after upgrading for Address/PublicKey changes, Keypair.address vs publicKey changes, Kit signer API interop, passing Connection and PublicKey to Kit/Codama program clients, removed unique/Account/FeeCalculator APIs, async Keypair and transaction flows, Connection commitment and bigint changes, Buffer-to-Uint8Array migration, readonly R…
Install
npx vskill@latest install solana-foundation/solana-web3.js/web3js-v1-to-v3-migrationSKILL.md
The same SKILL.md was published earlier as solana-foundation/solana-web3.js/web3js-v1-to-v3-migration.
Web3.js V1 To V3 Migration
For human-facing background, see `docs/web3js-v1-to-v3-migration.md`. This skill is the execution-oriented companion for agents fixing code.
If the migration also touches @solana/spl-token usage (token instructions, ATAs, mint/account fetches), read `reference/spl-token.md` for that surface — it covers @solana/spl-token → @solana-program/token while staying on the v3 Connection/Transaction/Keypair API. Load it as soon as Fast Triage (below) turns up any @solana/spl-token imports.
Target Versions
Migrate to these versions (or newer) so the Kit interop below works without adapters:
| Package | Minimum | Why | ||
|---|---|---|---|---|
@solana/web3.js | 3.1.0 | Connection implements Kit's ClientWithRpc<SolanaRpcApi>, ClientWithRpcSubscriptions<SolanaRpcSubscriptionsApi>, and ClientWithGetMinimumBalance, so it can be passed to Kit APIs that take a client. PublicKey implements Kit's HasAddress (since 3.0.0). | ||
@solana-program/system | 0.16.0 | Generated clients accept `Address \ | HasAddress for account inputs, address data args, PDA seeds, and programAddress` config. | |
@solana-program/token | 0.18.0 | Same HasAddress coverage, including the plan helpers. See `reference/spl-token.md`. | ||
@solana-program/token-2022 | 0.20.0 | Same as token. | ||
@solana-program/compute-budget | 0.20.0 | Same HasAddress coverage. | ||
@solana-program/address-lookup-table | 0.16.0 | Same HasAddress coverage. | ||
@solana-program/stake | 0.11.0 | Same HasAddress coverage. | ||
@solana-program/loader-v3 | 0.8.0 | Same HasAddress coverage. | ||
@solana/kit | ^8.5.0 | Peer dependency of the program clients above. |
With these versions, a v3 PublicKey passes directly to any Codama-generated client input that names an address, and a Connection passes directly to any Kit API that expects one of the client interfaces above.
When to Use
- Migrating an application, SDK, script, or test suite from legacy
@solana/web3.jsv1 assumptions to the v3 API and runtime model. - Auditing a codebase after a dependency bump when failures likely come from removed helpers, async key or transaction APIs, stricter key handling,
bigintRPC values, readonly wrappers, or byte-array changes. - Updating older examples or guides that still use
PublicKey-specific internals, assumekeypair.addressis a web3.jsPublicKeyobject, wrap Kit signers unnecessarily, use removedunique()helpers, removedConnectionmethods,Buffer-centric code, or older program helpers. - Reviewing a migration PR to find compatibility gaps, silent behavior changes, and missing regression tests.
Goal
Provide an agent workflow that finds the highest-risk breakage first, makes concrete code updates, and validates each migrated slice before moving on.
Operating Model
- Work in narrow, behavior-scoped slices. Start at a shared boundary, fix one class of breakage, validate it, then widen.
- Treat most churn as mechanical rather than architectural:
bigintnumerics,Uint8Arrayaccount data, async key and transaction helpers, readonly RPC results, and stricter SDK value types are the main recurring sources of breakage. - Prefer SDK-derived types and current public APIs over app-local compatibility shims unless the shim clearly owns a boundary.
Fast Triage
Use regex-capable search for these patterns before chasing softer type churn:
PublicKey.uniquenew AccountFeeCalculator|getRecentBlockhash|getRecentBlockhashAndContext|getFeeCalculatorForBlockhashsign|partialSign|VersionedTransaction.signnew Keypair\(|Keypair.generate\(\)\.publicKey|Keypair.generate\(|fromSecretKey\(|fromSeed\(|createProgramAddressSync|findProgramAddressSynckeypair\.address\.|\.address\.toBytes|\.address\.equals|\.address\.toBase58createNoopSigner|createSignerFromKeyPair|KeyPairSigner|MessagePartialSigner|TransactionPartialSigner|signMessages|signTransactions- app-local wrappers around message signing or signature verification
serialize()on legacyTransactioncall sites that assume sync behaviorPublicKeyData|_bn|new PublicKey(AccountInfo<Buffer>|ParsedAccountData \| BufferBuffer.from|Buffer.alloc|Buffer.concat- arithmetic or comparisons on
slot,blockHeight,context.slot,transactionCount,minContextSlot .sort\(|\.push\(|logMessages|readonlyimport .*\bAddress\b.* from ['"]@solana/web3.js['"]andtoBase58\(\) as— code written against an earlier 3.0.0-rc that imported the since-removedAddressclass or hand-brandedtoBase58()results; renameAddress→PublicKeyand drop the casts —.toBase58()is already typed as the kitAddressbrand.\.toBase58\(\)passed into@solana-program/*builders, PDA helpers, or plan helpers — unnecessary at the Target Versions; pass thePublicKey.from ['"]@solana/spl-token['"]— if present, the migration also touches the token surface; read `reference/spl-token.md` and follow its workflow for those call sites.
Recommended Agent Workflow
1. Start at the dependency boundary
Search for @solana/web3.js imports, wrapper modules, and app-local compatibility layers that re-export Solana types. Migrate the narrowest shared boundary first so downstream fixes become smaller.
2. Audit hard breaks first
Search for removed APIs and signatures before chasing softer type churn:
PublicKey.uniquenew AccountFeeCalculatorgetRecentBlockhashgetRecentBlockhashAndContextgetFeeCalculatorForBlockhash
3. Migrate key and address handling
Check whether the app only uses public keys as opaque values, or whether it depends on old PublicKey constructor internals, identity checks, BN.js inputs, or custom wrappers around those behaviors.
keypair.publicKeyremains the canonical web3.js identity accessor. Use it whenever code needs.toBytes(),.equals(...),.toBase58(),.verifySignature(...), or any API that takes a class-basedPublicKeyvalue. This is the default choice for web3.js consumers.- Do not use
keypair.address. It exists for ecosystem signer interop only — it returns Kit's brandedAddressstring so aKeypaircan satisfy Kit'sTransactionSignershape. Do not reach for it in normal web3.js code. - If code only stores, passes, compares, or prints key values, pass base58 strings or
PublicKeyinstances; the constructor validates input. PublicKeyimplements Kit'sHasAddress, so pass thePublicKeyitself to@solana-program/*clients (at the Target Versions above) and other Kit APIs typedAddress | HasAddress. Do not add.toBase58()at those call sites.PublicKey.toBase58()returns the kit-brandedAddressstring; prefer it overpublicKey.address. Use it only where anAddressorstringis required;Addressis astringsubtype, so code that expects a plainstringkeeps working as in v1.- If code depends on constructor internals, BN.js coercions, or class identity details, rewrite those call sites directly rather than assuming the class preserves legacy internals.
- Replace removed
PublicKey.unique()usage with a local dummy-address generator in tests and fixtures.
4. Migrate async crypto and transaction flows
Find call sites that previously assumed sync behavior for signature verification, key generation, message signing, transaction signing, PDA derivation, or legacy transaction serialization.
- The
Keypairconstructor is no longer public —new Keypair(...)will fail to typecheck. Replace it withawait Keypair.generate()(orawait Keypair.fromSecretKey(...)/await Keypair.fromSeed(...)when reconstructing from existing bytes). - Add
awaitto current async methods:transaction.sign(...),transaction.partialSign(...), andversionedTransaction.sign(...). - Prefer Kit-compatible signer APIs when integrating with Kit, Kit Plugins, Codama-generated clients, browser wallets, ledgers, or custom signing systems.
KeypairprovidessignMessages(...),signTransactions(...), andkeyPair, and implements Kit'sKeyPairSignerinterface so it can be passed directly to Kit APIs that accept aTransactionSignerorKeyPairSigner. - Pass any Kit
TransactionPartialSigner(including the web3.jsSignertype,MessagePartialSigner & TransactionPartialSigner) directly to web3.js transaction signing APIs instead of adapting them through noop signers only to satisfy legacy types. - Do not assume every Kit
TransactionSignercan sign a web3.js transaction. Transaction signing APIs accept any KitTransactionPartialSignerand only ever callsignTransactions; the exportedSignertype,MessagePartialSigner & TransactionPartialSigner(whatKeypairprovides), satisfies it, while message-only signers are rejected. Sending-only, modifying-only, or message-only signers need a boundary that understands those behaviors. Custom signers that only expose an ad-hocsignBytes(...)function should implement Kit'sTransactionPartialSignershape rather than relying on a bespoke web3.js byte-signer interface. - The v1
Signerinterface ({publicKey, secretKey}) is no longer accepted. Replace signer literals with aKeypair(await Keypair.fromSecretKey(legacySigner.secretKey)) or another Kit signer. - Replace sync PDA helpers with the current async surfaces:
PublicKey.createProgramAddressSync(...)->await PublicKey.createProgramAddress(...)PublicKey.findProgramAddressSync(...)->await PublicKey.findProgramAddress(...)- For raw message signing or signature verification, prefer the direct v3 object methods instead of app-local wrappers:
- sign raw bytes with
await keypair.signBytes(messageBytes) - verify signatures with
await keypair.verifySignature(signature, messageBytes)orawait publicKey.verifySignature(signature, messageBytes) - Add
asyncto any function that now callsKeypair.generate(),Keypair.fromSecretKey(...),Keypair.fromSeed(...),PublicKey.createProgramAddress(...),PublicKey.findProgramAddress(...), transaction signing, signature verification, or legacyTransaction.serialize(...), then add the correspondingawaitat each call site. - Fix immediate sync assumptions after those calls: if code reads
.publicKeyfrom a newly created keypair, inspects transaction signatures right after signing, serializes a legacy transaction, or sends it immediately after signing, move that logic after the awaited call. - If code converts a web3.js keypair for Kit APIs, pass the keypair directly —
Keypairimplements Kit'sKeyPairSigner, so it is accepted wherever aTransactionSigner,MessagePartialSigner, orKeyPairSigneris expected, andisKeyPairSigner(keypair)returnstrue. - Do not hide async migration work behind mixed sync wrappers unless the wrapper owns real scheduling or lifecycle behavior.
- Pay special attention to tests and stories that used
Keypair.generate().publicKeyor the removedPublicKey.unique()helper as shorthand for a unique address; replace them with a dummy-address helper instead of spreading async churn through the test.
5. Audit Connection behavior and numeric types
Identify code that relied on the old implicit finalized default or on numeric RPC results being JavaScript number values.
- If the app needs
finalized, set it explicitly. - If the app performs arithmetic, comparisons, JSON serialization, or schema validation on slots, counts, context slots, block heights, or similar fields, update those paths to accept
bigintor convert intentionally at the edge with safe-range checks. - If those values appear in fixtures or mocked RPC payloads, update the fixtures too instead of coercing production code back to
number.
5a. Use Connection as the Kit client
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/web3js-v1-to-v3-migration/SKILL.md
Popularity
- Repository stars
- 2,782
- Repository forks
- 1,092
- 7-day trend score
- 40
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/solana-foundation/solana-web3.js/web3js-v1-to-v3-migration)