Taquito Beacon Wallet package
Documentation can be found here TypeDoc style documentation is available here
General Information
@taquito/taquito-beacon-wallet is an npm package implementing the TZIP-10 standard that describes the communication between decentralized applications and wallets. The package provides developers a way to connect a dapp built with Taquito to a wallet giving the freedom to the users of the dapp to choose the wallet they want.
Install
Install the package as follows
npm install @taquito/beacon-wallet
Usage
Create a wallet instance with defined option parameters and set the wallet provider using setWalletProvider to the TezosToolkit instance
import { TezosToolkit } from '@taquito/taquito';
import { BeaconEvent, BeaconWallet } from '@taquito/beacon-wallet';
import { NetworkType } from '@taquito/beacon-wallet/types';
const wallet = new BeaconWallet({
name: 'MyAwesomeDapp',
iconUrl: 'https://taquito.io/img/favicon.svg',
network: { type: NetworkType.SHADOWNET },
});
const unsubscribeAccount = await wallet.subscribeToEvent(
BeaconEvent.ACTIVE_ACCOUNT_SET,
async (account) => {
// An active account has been set or cleared; update the dApp UI
console.log(`${BeaconEvent.ACTIVE_ACCOUNT_SET} triggered:`, account);
},
);
await wallet.requestPermissions();
const Tezos = new TezosToolkit('https://YOUR_PREFERRED_RPC_URL');
Tezos.setWalletProvider(wallet);
Active Wallet Metadata (getWalletInfo())
import type { WalletInfo } from '@taquito/beacon-wallet';
const info: WalletInfo | undefined = await wallet.getWalletInfo();
if (info) {
console.log(info.name, info.type, info.icon, info.deeplink);
}
getWalletInfo() delegates to Beacon's DAppClient.getActiveWalletInfo(). It returns the active wallet's resolved name, optional icon (data URI or extension URL), deeplink, and type ('extension' | 'mobile' | 'web' | 'desktop'), or undefined when disconnected. It does not initialize a transport or prompt for permissions.
Transport & Connection Observability
Query the current transport status and health without blocking on transport initialization, or subscribe to live transitions:
import {
BeaconEvent,
type ConnectionInfo,
type TransportStatusChangedInfo,
} from '@taquito/beacon-wallet';
const connection: ConnectionInfo = await wallet.getConnectionInfo();
// { transport?: 'postmessage' | 'p2p' | 'walletconnect', status: TransportStatus, health: 'ok' | 'degraded', relayServer?, senderId? }
const unsubscribeStatus = await wallet.subscribeToEvent(
BeaconEvent.TRANSPORT_STATUS_CHANGED,
(change: TransportStatusChangedInfo) => {
if (change.health === 'degraded') {
console.warn(`Relay degraded (${change.reason}):`, change.relayServer);
}
},
);
Request Lifecycle, Acknowledgements & Custom UI
When building a custom request progress UI, you can suppress Beacon's built-in Shadow DOM progress toasts via uiOptions: { enableToasts: false } (while keeping the built-in pairing modal and error alerts), track in-flight requests with wallet.getPendingRequests(), and correlate lifecycle events by requestId:
import {
BeaconEvent,
BeaconWallet,
isBeaconError,
TransactionInvalidBeaconError,
toBeaconError,
} from '@taquito/beacon-wallet';
const wallet = new BeaconWallet({
name: 'MyAwesomeDapp',
ackTimeoutMs: 5_000,
uiOptions: { enableToasts: false },
});
await wallet.subscribeToEvent(BeaconEvent.OPERATION_REQUEST_SENT, (sent) => {
// sent.dispatchStage is 'transport' (with sent.sentAt) or 'forwarded' (with sent.forwardedAt)
console.log('Sent request', sent.requestId, 'to', sent.walletInfo.name);
});
await wallet.subscribeToEvent(BeaconEvent.ACKNOWLEDGE_RECEIVED, (ack) => {
if (ack.correlated) {
console.log('Wallet acknowledged request', ack.requestId);
}
});
await wallet.subscribeToEvent(BeaconEvent.WAITING_FOR_WALLET_ACK, (waiting) => {
console.warn(`Still waiting for wallet ACK (${waiting.elapsedMs}ms) on ${waiting.requestId}`);
});
await wallet.subscribeToEvent(BeaconEvent.LATE_RESPONSE_RECEIVED, (late) => {
if (late.kind === 'success') {
console.warn('Wallet responded after local timeout:', late.transactionHash);
}
});
// Inspect currently open requests synchronously at any point:
const pending = wallet.getPendingRequests();
Typed BeaconError Handling & Protocol Message Stream
Request methods (requestPermissions, sendOperations, sign) reject with typed BeaconError subclasses (AbortedBeaconError, TransactionInvalidBeaconError, PeerUnreachableBeaconError, etc.):
try {
await wallet.sendOperations(operations);
} catch (err) {
if (isBeaconError(err)) {
// err.errorOrigin is 'wallet' | 'local'
console.error(err.errorType, err.errorOrigin, err.title, err.description);
if (err instanceof TransactionInvalidBeaconError) {
console.error('RPC errors:', err.rpcErrors);
}
}
}
// Note: *_REQUEST_ERROR events emit a plain WireRequestErrorResponse in data.errorResponse
// (where errorType is a string to preserve unfamiliar wallet codes). Narrow with
// isRequestErrorResponse(data.errorResponse) before indexing by BeaconErrorType,
// or pass it to toBeaconError(data.errorResponse) for a typed BeaconError instance.
For debugging or telemetry, observe immutable plaintext protocol messages across all transports (including incoming routing disposition: 'handled' | 'stale' | 'unknown-request' | 'invalid') or configure Beacon's logger without installing @ecadlabs/beacon-core directly:
import {
setDebugEnabled,
setLogger,
type LoggerInterface,
} from '@taquito/beacon-wallet';
setDebugEnabled(true);
const stopMessages = wallet.subscribeToMessages((record) => {
console.debug(record.direction, record.transport, record.disposition, record.message);
});
Internationalization (i18n) & RTL Layout Support
Beacon includes built-in translations for English (en), French (fr), Spanish (es), German (de), Japanese (ja), and Arabic (ar, with automatic Right-to-Left rtl layout across <beacon-alert> and <beacon-toast> shadow roots), as well as full WCAG/WAI-ARIA keyboard navigation and screen-reader announcements.
By default, BeaconWallet automatically detects the user's preferred language from the browser (navigator.languages / navigator.language, or a non-English <html lang="..."> attribute, falling back to 'en'). To pin Beacon's UI and error messages to English regardless of the user's browser language, pass locale: 'en' explicitly.
You can override the locale, text direction ('ltr' | 'rtl' | 'auto'), and partial translation strings programmatically in constructor options or at runtime:
import {
BeaconWallet,
configureBeaconI18n,
setBeaconLocale,
} from '@taquito/beacon-wallet';
// 1. Override in constructor options:
const wallet = new BeaconWallet({
name: 'MyAwesomeDapp',
locale: 'fr',
direction: 'auto',
translations: {
ui: {
connectWallet: 'Connecter votre portefeuille Tezos',
},
},
});
// 2. Or switch language/direction dynamically at runtime (updates open modals/toasts immediately):
wallet.setLocale('ar'); // switches to Arabic and sets dir="rtl"
wallet.setLocale(undefined); // clears this client's override and reverts to global baseline or detected browser language
// Or via top-level global baseline helpers:
setBeaconLocale('es');
configureBeaconI18n({ locale: 'de', direction: 'ltr' });
If you provide custom translations for a language not in builtInLocales (such as Italian 'it' or Persian 'fa'), pass locale: 'it' (or locale: 'fa') alongside translations so Beacon sets lang and dir appropriately on its shadow hosts.
Side-Effect-Free Types (@taquito/beacon-wallet/types)
To import Beacon enums, error classes, error guards, or TypeScript types without pulling in @ecadlabs/beacon-dapp runtime side effects:
import {
BeaconErrorType,
isBeaconError,
NetworkType,
PermissionScope,
SigningType,
TransportStatus,
TransportType,
type ConnectionInfo,
type PendingRequestInfo,
type WalletInfo,
} from '@taquito/beacon-wallet/types';
WalletConnect Project ID
Under the covers, Beacon selects a transport per wallet: browser extensions (such as Temple) communicate locally via postMessage, TZIP-10 P2P wallets (such as Kukai web) use Matrix relay nodes (curated by Taquito by default), and WalletConnect-enabled wallets (such as Kukai iOS) use WalletConnect v2. walletConnectOptions does not replace Matrix or extension transports.
If your dApp supports WalletConnect connections, register your own projectId at Reown Cloud, configure your allowed origins list, and pass it in BeaconWallet options (in web dApps, typically via a build-time environment variable such as VITE_* or NEXT_PUBLIC_*):
const wallet = new BeaconWallet({
name: 'MyAwesomeDapp',
walletConnectOptions: {
projectId: import.meta.env.VITE_REOWN_PROJECT_ID,
},
});
A projectId is a public client identifier (not a secret), with access control enforced through your Reown Cloud domain allowlist. Any built-in fallback projectId in the underlying Beacon SDK is for demo/testing purposes only; using it in production may put your project in breach of the WalletConnect/Reown Terms of Service, and it will be removed in the next minor release (after which omitting projectId will only disable WalletConnect pairings, while extension and Matrix wallets continue to work).