For the complete documentation index, see llms.txt. This page is also available as Markdown.

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.solana

TokenPocket also supports Wallet Standard and can be discovered by standard wallet discovery flows.

Wallet Standard is recommended for new integrations. Existing dApps built around window.solana can continue using the traditional Provider interface.

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 is false.

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 disconnect and accountChanged events.

Example:

signTransaction

Signs a single transaction.

Notes:

  • Supports Transaction.

  • Also handles VersionedTransaction compatibility.

  • dApps are recommended to use legacy transactions.

  • Returns the signed transaction object.

  • If the wallet returns unitsConsumed or microLamports, 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 signature as a Base58 string.

  • Returns publicKey as 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.

When the user disconnects or the active account is cleared, accountChanged may receive null. Make sure your dApp handles that case.

Wallet Standard

TokenPocket currently supports these Wallet Standard features:

  • standard:connect

  • standard:events

  • solana:signTransaction

  • solana:signAndSendTransaction

  • solana:signMessage

Official references:

Supported chains:

Notes:

  • The currently declared supportedTransactionVersions value is ['legacy'].

  • dApps should integrate against legacy transaction 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 null values from accountChanged.

Compatibility Notes

  • TokenPocket exposes both window.solana and window.tokenpocket.solana.

  • Wallet Standard is recommended for new integrations.

  • Existing Solana Provider integrations can continue to work directly.