wallet
A type that describes a browser extension wallet that implements the wallet-standard.
Registered wallets are stored using this type.
Structure
#![allow(unused)] fn main() { #[derive(Clone, Default, PartialEq, Eq)] pub struct Wallet { name: String, version: SemverVersion, icon: Option<WalletIcon>, accounts: Vec<WalletAccount>, chains: Vec<Cluster>, pub(crate) features: Features, //.... } }
Wallet Field
Describes the name of the wallet as a UTF-8 String.
version field
The Semantic Version of the wallet-standard this wallet supports.
icon field
An optional wallet icon encoded as Base64 image.
accounts field
A sequence of accounts wallet accounts provided by the connected wallet
chains field
A sequence of Clusters supported by the wallet.
features field
The features of the wallet-standard supported by the wallet
Methods on Wallet type
Let's initialize a WalletAdapter
and assume we already connected to a browser extension wallet.
#![allow(unused)] fn main() { use wallet_adapter::{WalletAdapter, WalletError}; // Initialize wallet adapter let adapter = WalletAdapter::init()?; // Get the connection information // (we assumed we already connected to a browser extension wallet) let connection_info = adapter.connection_info().await; // If you just want to test out a wallet you can // 1. Get all wallets that registered themselves let wallet = adapter.wallets().get(0).ok_or(WalletError::Op("No wallets found"))?; // 2. Get a certain wallet by it's name, let's assume Solflare is installed let wallet = adapter.get_wallet("sOlFlare").await?; // The wallet name is case-insensitive // Get the connected wallet that we will use in the examples below // rather than repeating this processes again let wallet = connection_info.connected_wallet()?; }
Get the wallet name
#![allow(unused)] fn main() { wallet.name(); }
Get the optional
wallet icon
#![allow(unused)] fn main() { wallet.icon(); }
Get the SemVer version of the wallet-standard supported by the wallet
#![allow(unused)] fn main() { wallet.version(); }
Get the accounts if any are connected
#![allow(unused)] fn main() { wallet.accounts(); }
Get the chains supported by the wallet
#![allow(unused)] fn main() { wallet.chains(); }
Check whether the wallet supports mainnet
#![allow(unused)] fn main() { wallet.mainnet(); }
Check whether the wallet supports testnet
#![allow(unused)] fn main() { wallet.testnet(); }
Check whether the wallet supports devnet
#![allow(unused)] fn main() { wallet.devnet(); }
Check whether the wallet supports localnet
#![allow(unused)] fn main() { wallet.localnet(); }
Get the features of the wallet-standard supported by the wallet
#![allow(unused)] fn main() { wallet.features(); }
Check if the wallet supports standard:connect
feature
#![allow(unused)] fn main() { wallet.standard_connect(); }
Check if the wallet supports standard:disconnect
feature
#![allow(unused)] fn main() { wallet.standard_disconnect(); }
Check if the wallet supports standard:events
feature
#![allow(unused)] fn main() { wallet.standard_events(); }
Check if the wallet supports solana:signIn
feature
#![allow(unused)] fn main() { wallet.solana_signin(); }
Check if the wallet supports solana:signMessage
feature
#![allow(unused)] fn main() { wallet.solana_sign_message(); }
Check if the wallet supports solana:signTransaction
feature
#![allow(unused)] fn main() { wallet.solana_sign_transaction(); }
Check if the wallet supports solana:signAndSendTransaction
feature
#![allow(unused)] fn main() { wallet.solana_sign_and_send_transaction(); }