solana-wallet-adapter
Trigger: wallet-adapter, Solana wallet connect, Phantom, SIWS, sign message, sign transaction, WASM wallet. Connect browser-extension Solana wallets from Rust/WASM frontends via the wallet-adapter crate.
- License 许可
- Apache-2.0
- 最近更新
- 2026-08-26
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- solana-wallet-adapter
- license
- Apache-2.0
- metadata
- { "author": "gentleman-programming", "version": "1.0" }
- description
- Trigger: wallet-adapter, Solana wallet connect, Phantom, SIWS, sign message, sign transaction, WASM wallet. Connect browser-extension Solana wallets from Rust/WASM frontends via the wallet-adapter crate.
02 资源文件 2
- 资产文件assets/examples.md4.6 KB
- 参考文档references/upstream.md610 B
03 SKILL.md 正文
Solana Wallet Adapter (Rust / WASM)
Activation Contract
Use when building a Rust frontend (Dioxus, Leptos, Yew, Sycamore, or any trunk/wasm-bindgen app) that must connect to a browser-extension Solana wallet (Phantom, Solflare, Backpack) and sign messages or transactions through the Wallet Standard. This crate is NOT for native/CLI clients.
Hard Rules
- WASM-only: compile to
wasm32-unknown-unknownwith a bundler (trunk ordioxus web). It will not link in a native binary. - Init once: call
WalletAdapter::init()(orinit_with_channel_capacity/init_custom) exactly once at startup. It registerswallet-standard:register-walletandwallet-standard:app-readyevents onwindow/document. Without it,adapter.wallets()stays empty. - No web-sys flags needed: the crate already enables the required
web-sysfeatures in its own manifest. Addsolana-sdk,bincode,jzon,serdeonly for the sign/send flows. - SIWS needs address:
sign_inREQUIRESSigninInput::set_address(&address); omitting it throwsMessageResponseMismatch. - Async connection info:
adapter.connection_info()/connected_account()areasync(RwLock-wrapped). Await them. CloneConnectionInfo/WalletStoragebefore moving into closures orasync movebackground tasks. - Tx = bincode bytes: serialize with
bincode::serialize(&tx); the wallet deserializes from bytes. Build withsolana_sdk::transaction::Transaction. - Send needs blockhash:
sign_and_send_transactionrequires a valid recent blockhash in the tx (fetchgetLatestBlockhash) plusSendOptions. - Verify signatures: every
sign_*returnsWalletErroron mismatch — never trust output without handling the error.
Decision Gates
| Goal | Method |
| Connect a wallet | connect_by_name("Phantom") or connect(wallet) |
| Disconnect | disconnect().await |
| Login / auth (SIWS) | sign_in(&SigninInput, pubkey).await |
| Prove ownership off-chain | sign_message(bytes).await |
| Sign, send yourself | sign_transaction(&tx_bytes, Some(cluster)).await |
| Sign + broadcast | sign_and_send_transaction(&tx_bytes, cluster, SendOptions).await |
Execution Steps
- Add deps — see
assets/examples.md#cargo. let mut adapter = WalletAdapter::init()?;once at startup.adapter.connect_by_name("Phantom").await?;then guard withif adapter.is_connected().await { .. }.- Check support before calling:
if adapter.solana_sign_transaction().await? { .. }. - Perform the action from the table above.
- Listen for
WalletEvents (Register,Disconnected,AccountChanged) viaadapter.events().recv().await.
Output Contract
Return a snippet tailored to the requested operation (connect / SIWS / sign message / sign tx / sign+send) plus the matching Cargo deps and the init-once reminder.
References
references/upstream.md— docs.rs, book, and repo links.assets/examples.md— full runnable Cargo.toml and code per operation.
04 同仓库更多 Skills
zustand-5
Zustand 5 state management patterns. Trigger: When managing React state with Zustand.
zod-4
Zod 4 schema validation patterns. Trigger: When using Zod for validation - breaking changes from v3.
x-bookmark-quote-posts
Workflow para revisar bookmarks de X/Twitter y convertirlos en drafts de quote posts. Accede a la sección de bookmarks vía browser headless, extrae posts recientes, y genera drafts con voz personal del usuario. No publica ni muta X — solo genera contenido para revisión. Trigger: X bookmarks, Twitter bookmarks, quote posts, bookmark automation, crear quote posts, revisar bookmarks, growth content X.
writing-skills
Use when creating new skills, editing existing skills, or verifying skills work before deployment
writing-plans
Use when you have a spec or requirements for a multi-step task, before touching code
work-unit-commits
Plan commits as reviewable work units. Trigger: implementation, commit splitting, chained PRs, or keeping tests and docs with code.