Solana Provider API
TokenPocket Extension injects a Solana Provider into the page. Developers can integrate Solana wallet capabilities through the traditional Provider interface or Wallet Standard.
Provider Injection
The following objects are available on the page:
window.solana
window.tokenpocket.solanaTokenPocket also supports Wallet Standard and can be discovered by standard wallet discovery flows.
Quick Start
Connect Wallet
const provider = window.solana;
const res = await provider.connect();
console.log(res.address);
console.log(res.publicKey.toBase58());
console.log(res.accounts);Sign a Message
Sign a Transaction
API List
connect
Connects the current site to a Solana account.
Parameters:
silent: Whether to connect silently. Default isfalse.
Notes:
When
silent: true, an account is returned only if the wallet is unlocked and the current site already has an authorized address.The call throws an error if no connection is available.
Example:
disconnect
Disconnects the current session.
Notes:
Clears the current account state.
Triggers the
disconnectandaccountChangedevents.
Example:
signTransaction
Signs a single transaction.
Notes:
Supports
Transaction.Also handles
VersionedTransactioncompatibility.dApps are recommended to use
legacytransactions.Returns the signed transaction object.
If the wallet returns
unitsConsumedormicroLamports, the Provider automatically appends Compute Budget instructions.
Example:
signAllTransactions
Signs multiple transactions.
Notes:
The current implementation signs transactions one by one through
signTransaction.
Example:
signMessage
Signs a message.
Notes:
Supports a raw
Uint8Array.Also accepts a
{ message }wrapper.
Example:
signAndSendTransaction
Signs and sends a transaction.
Notes:
Builds a transaction from the provided
instructions.Returns
signatureas a Base58 string.Returns
publicKeyas the signing address.
Example:
Events
The Provider supports event subscriptions.
connect
Triggered after a successful connection.
disconnect
Triggered after disconnect.
accountChanged
Triggered when the active account changes.
Wallet Standard
TokenPocket currently supports these Wallet Standard features:
standard:connectstandard:eventssolana:signTransactionsolana:signAndSendTransactionsolana:signMessage
Official references:
Supported chains:
Notes:
The currently declared
supportedTransactionVersionsvalue is['legacy'].dApps should integrate against
legacytransaction support.
Wallet Standard Example
Error Handling
Use try/catch for all Provider calls.
Common failure cases:
User rejects the connection request.
User rejects a signature request.
Wallet is locked.
The current site is not authorized.
Transaction or message format is invalid.
Best Practices
Prefer Wallet Standard for new integrations.
Existing dApps can keep using
window.solana.Treat transaction support as
legacy.Handle exceptions for all connect and signing flows.
Handle
nullvalues fromaccountChanged.
Compatibility Notes
TokenPocket exposes both
window.solanaandwindow.tokenpocket.solana.Wallet Standard is recommended for new integrations.
Existing Solana Provider integrations can continue to work directly.