diff --git a/ecosystem/ton-connect/walletkit/web/connections.mdx b/ecosystem/ton-connect/walletkit/web/connections.mdx
index d3a8e8f9e..f1a708501 100644
--- a/ecosystem/ton-connect/walletkit/web/connections.mdx
+++ b/ecosystem/ton-connect/walletkit/web/connections.mdx
@@ -52,12 +52,12 @@ kit.onConnectRequest(async (event) => {
await kit.rejectConnectRequest(event, 'No wallets available');
return;
}
- const dappName = event.preview.manifest?.name || 'Unknown dApp';
- const dappUrl = event.preview.manifest?.url || 'Unknown URL';
+ const dappName = event.preview.dAppInfo?.name || 'Unknown dApp';
+ const dappUrl = event.preview.dAppInfo?.url || event.preview.dAppInfo?.manifestUrl || 'Unknown URL';
// Show the connection confirmation UI to the user of the wallet service
if (confirm(`Connect to ${dappName} from ${dappUrl}?`)) {
- // Set wallet address on the request before approving
- event.walletAddress = wallets[0].getAddress();
+ // Set `walletId` on the request before approving
+ event.walletId = wallets[0].getWalletId();
await kit.approveConnectRequest(event);
console.log('Connected to:', dappName);
} else {
@@ -101,12 +101,12 @@ kit.onConnectRequest(async (event) => {
await kit.rejectConnectRequest(event, 'No wallet selected');
return;
}
- const dappName = event.preview.manifest?.name || 'Unknown dApp';
- const dappUrl = event.preview.manifest?.url || 'Unknown URL';
+ const dappName = event.preview.dAppInfo?.name || 'Unknown dApp';
+ const dappUrl = event.preview.dAppInfo?.url || event.preview.dAppInfo?.manifestUrl || 'Unknown URL';
// Show the connection confirmation UI to the user of the wallet service
if (confirm(`Connect to ${dappName} from ${dappUrl}?`)) {
- // Set wallet address on the request before approving
- event.walletAddress = selectedWallet.wallet.getAddress();
+ // Set `walletId` on the request before approving
+ event.walletId = selectedWallet.wallet.getWalletId();
await kit.approveConnectRequest(event);
console.log('Connected to:', dappName);
} else {
diff --git a/ecosystem/ton-connect/walletkit/web/events.mdx b/ecosystem/ton-connect/walletkit/web/events.mdx
index 53311581d..36a629175 100644
--- a/ecosystem/ton-connect/walletkit/web/events.mdx
+++ b/ecosystem/ton-connect/walletkit/web/events.mdx
@@ -27,22 +27,24 @@ If a dApp is connected to the wallet service, the former can request to initiate
On TON, transactions are initiated by sending an external message to the TON wallet contract, which then processes it and sends internal messages as requested. To estimate money flows for planned transactions, WalletKit uses emulation via the configured API client, if supported.
```ts title="TypeScript"
kit.onTransactionRequest(async (event) => {
try {
- if (event.preview.result === 'success') {
+ if (!event.preview.data) {
+ console.log('Transaction emulation skipped');
+ } else if (event.preview.data.result === 'success') {
// If the emulation was successful,
// show net asset changes to the user for a confirmation.
// There, positive amounts mean incoming transfers,
// and negative mean outgoing ones.
- console.log(event.preview.moneyFlow.ourTransfers);
+ console.log(event.preview.data.moneyFlow?.ourTransfers ?? []);
} else {
// Transaction emulation was not successful,
// but you can still allow a user to proceed — with a warning.
- console.log('Transaction emulation failed');
+ console.warn('Transaction emulation failed');
}
if (confirm('Do you confirm this transaction?')) {
await kit.approveTransactionRequest(event);
@@ -67,34 +69,35 @@ kit.onSignDataRequest(async (event) => {
try {
// Data to be signed can be of three distinct types.
// Depending on a type, show it to the user for a confirmation.
- switch (event.request.type) {
+ const dataToSign = event.payload.data;
+ switch (dataToSign.type) {
case 'text':
- console.log(event.request.text);
+ console.log(dataToSign.value.content);
break;
case 'binary':
- console.log(event.request.bytes);
+ console.log(dataToSign.value.content);
break;
case 'cell':
// The `request.cell` contains a hex-encoded string with a serialized cell
// and the `request.schema` describes a TL-B schema to parse the `request.cell`
- console.log(event.request.cell);
- console.log(event.request.schema);
+ console.log(dataToSign.value.content);
+ console.log(dataToSign.value.schema);
break;
}
if (confirm('Do you confirm this data sign request?')) {
try {
- // Sign the data receiver with the user's approval
- const result = await kit.signDataRequest(event);
+ // Sign the data with the user's approval
+ const result = await kit.approveSignDataRequest(event);
console.log('Signed successfully:', result);
} catch (error) {
console.error('Signing failed:', error);
}
} else {
- await kit.rejectTransactionRequest(event, 'User rejected');
+ await kit.rejectSignDataRequest(event, 'User rejected');
}
} catch (error) {
console.error('Data sign handler error:', error);
- await kit.rejectTransactionRequest(event, 'Fatal error in the data sign handler');
+ await kit.rejectSignDataRequest(event, 'Fatal error in the data sign handler');
}
});
```
@@ -104,29 +107,10 @@ kit.onSignDataRequest(async (event) => {
Upon any error in any of the requests, the `onRequestError()` method is invoked. Provide it with a callback function that would handle arbitrary errors and display useful information to the user.
```ts title="TypeScript"
-await kit.onRequestError(async (event) => {
- // To distinguish incoming events, look for their corresponding type:
- console.error(event.incomingEvent.method);
-
- // Event's .method can be one of the following:
- // - connect (failure in onConnectRequest)
- // - disconnect (failure in onDisconnect)
- // - transaction (failure in onTransactionRequest)
- // - signData (failure in onSignDataRequest)
- // - restoreConnection (JS bridge failures)
- // - none (generic request errors)
- console.error(event.incomingEvent);
-
- // The result is a following object:
- // {
- // id: string,
- // error: {
- // code: number,
- // message: string,
- // data?: unknown,
- // }
- // }
- console.error(event.result);
+kit.onRequestError(async (event) => {
+ console.error('Error in request ID:', event.id);
+ console.error('Details:', event.error);
+ console.error('Data:', event.data);
});
```
diff --git a/ecosystem/ton-connect/walletkit/web/init.mdx b/ecosystem/ton-connect/walletkit/web/init.mdx
index 41f44d317..d6a68d1a0 100644
--- a/ecosystem/ton-connect/walletkit/web/init.mdx
+++ b/ecosystem/ton-connect/walletkit/web/init.mdx
@@ -33,25 +33,44 @@ Alternatively, explore the complete demo wallet with WalletKit integration:
## Initialization
-The basic kit initialization consists of creating a corresponding object by passing it a minimal set of necessary arguments. One needs to pick a TON network to operate on, provide the necessary device and wallet manifest configurations.
+The basic kit initialization consists of creating a corresponding object by passing it a minimal set of necessary arguments: TON networks to operate on.
+
+Yet, it's often useful to configure optional parameters right away — the following example also specifies core wallet information, TON Connect manifest, and bridge settings.
```ts
import {
// Main class
TonWalletKit,
- // Network constants (MAINNET/TESTNET)
- CHAIN,
+ // Network object
+ Network,
// Helper functions
createDeviceInfo,
createWalletManifest,
} from '@ton/walletkit';
-// 0. Create a kit object
+// 0. Create a kit object.
const kit = new TonWalletKit({
- // 1. Pick a network — prefer CHAIN.TESTNET during development,
- // and only switch to CHAIN.MAINNET and production deployments
- // after rigorous testing.
- network: CHAIN.TESTNET,
+ // 1. Configure networks.
+ networks: {
+ // Production network. All contracts and funds are real.
+ [Network.mainnet().chainId]: {
+ apiClient: {
+ // Most commonly used, official API provider.
+ url: 'https://toncenter.com',
+
+ // A key to access higher RPS limits.
+ // Get it from https://t.me/toncenter
+ key: '',
+ },
+ },
+ // Testing network. For experiments, beta tests, and feature previews.
+ [Network.testnet().chainId]: {
+ apiClient: {
+ url: 'https://testnet.toncenter.com',
+ key: '',
+ },
+ },
+ },
// 2. Specify core information and constraints of the given wallet.
deviceInfo: createDeviceInfo({
@@ -70,9 +89,18 @@ const kit = new TonWalletKit({
// but you may want to specify some custom values,
// such as the human-readable name of your wallet or its icon image url.
walletManifest: createWalletManifest(),
+
+ // 4. Specify the TON Connect's bridge settings
+ bridge: {
+ // The main TON Connect bridge for dApp communication.
+ // It is capable to withstand significant load.
+ //
+ // To self-host, see https://github.com/ton-connect/bridge
+ bridgeUrl: 'https://connect.ton.org/bridge',
+ },
});
-// 4. Finally, wait for the initialization to complete
+// 5. Finally, wait for the initialization to complete
await kit.waitForReady();
```
@@ -100,29 +128,67 @@ See also: [TON Connect's wallet manifest](/ecosystem/ton-connect/manifest#wallet
### Required
- The TON network to use.
+ For one or more TON networks, configure their respective API or RPC providers to interact with.
```ts
- import { CHAIN } from '@ton/walletkit';
+ import { Network } from '@ton/walletkit';
+
+ new TonWalletKit({
+ networks: {
+ // Production network. All contracts and funds are real.
+ [Network.mainnet().chainId]: { // "-239"
+ apiClient: {
+ // Most commonly used, official API provider.
+ //
+ // To self-host, see:
+ // * Real-time API: https://github.com/toncenter/ton-http-api-cpp
+ // * Indexer: https://github.com/toncenter/ton-indexer
+ // It is important to put real-time API under `/api/v2` route and indexer API under `/api/v3` route.
+ url: 'https://toncenter.com',
+
+ // Optional key to access higher RPS limits.
+ key: '',
+ },
+ },
+ // Testing network. For experiments, beta tests, and feature previews.
+ [Network.testnet().chainId]: { // "-3"
+ apiClient: {
+ url: 'https://testnet.toncenter.com',
+ key: '',
+ },
+ },
+ },
+ // ...later fields...
+ });
+ ```
- // Testing network of TON Blockchain. For experiments, beta tests, and feature previews.
- CHAIN.TESTNET; // "-3"
+ It is also possible to provide an entirely custom provider with its own `ApiClient` interface implementation.
- // Production network of TON Blockchain. All contracts and funds are real.
- CHAIN.MAINNET; // "-239"
+ ```ts
+ import { Network } from '@ton/walletkit';
+
+ new TonWalletKit({
+ networks: {
+ [Network.testnet().chainId]: { // "-3"
+ apiClient: /* A complete ApiClient interface implementation */,
+ },
+ },
+ // ...later fields...
+ });
```
+### Optional
+
- Core information and constraints of the given wallet.
+ Core information and constraints of the given wallet. If not provided, defaults will be used.
```ts
interface DeviceInfo {
@@ -184,9 +250,8 @@ See also: [TON Connect's wallet manifest](/ecosystem/ton-connect/manifest#wallet
- How your wallet interacts with the TON Connect. This field is closely related to the [corresponding JSON manifest file](/ecosystem/ton-connect/manifest#wallet-manifest).
+ How your wallet interacts with the TON Connect. If not provided, defaults will be used. This field is closely related to the [corresponding JSON manifest file](/ecosystem/ton-connect/manifest#wallet-manifest).
```ts expandable
interface WalletInfo {
@@ -260,27 +325,6 @@ See also: [TON Connect's wallet manifest](/ecosystem/ton-connect/manifest#wallet
```
-### Optional
-
-
- Which API or RPC provider to use to interact with TON Blockchain.
-
- ```ts
- // Either a small object:
- const _: {
- // Defaults to "https://toncenter.com".
- url?: string;
-
- // A key to access higher RPS limits.
- key?: string;
- }
- // Or a complete ApiClient interface implementation.
- ```
-
-
@@ -385,6 +433,13 @@ See also: [TON Connect's wallet manifest](/ecosystem/ton-connect/manifest#wallet
horizontal="true"
href="/ecosystem/ton-connect/walletkit/web/wallets"
/>
+
+
## See also
diff --git a/ecosystem/ton-connect/walletkit/web/toncoin.mdx b/ecosystem/ton-connect/walletkit/web/toncoin.mdx
index c1d41494c..9bb16ee99 100644
--- a/ecosystem/ton-connect/walletkit/web/toncoin.mdx
+++ b/ecosystem/ton-connect/walletkit/web/toncoin.mdx
@@ -18,7 +18,7 @@ Blockchain state changes constantly as new blocks are produced. This has implica
- [Discrete one-off checks](#on-demand-balance-check) have almost no value on their own — the state might change immediately after the query completes, invalidating its results. Thus, such checks are only practical when handling `transaction` requests.
- [Continuous monitoring](#continuous-balance-monitoring) is useful for UI display, showing the most recent balance to users, but should not be used for transaction confirmations.
-Notice that both cases require querying the blockchain data via the API client set during the [WalletKit initialization](/ecosystem/ton-connect/walletkit/web/init#param-api-client). Obtain and provide the key from the selected client to access higher requests-per-second limits.
+Notice that both cases require querying the blockchain data via the API client set during the [WalletKit initialization](/ecosystem/ton-connect/walletkit/web/init#param-networks). Obtain and provide the key from the selected client to access higher requests-per-second limits.
### On-demand balance check
@@ -31,9 +31,9 @@ Use the `getBalance()` method to check the wallet contract balance in TON wallet
```ts title="TypeScript"
-async function getBalance(address: string): Promise {
+async function getBalance(walletId: string): Promise {
// Get TON wallet instance
- const wallet = kit.getWallet(address);
+ const wallet = kit.getWallet(walletId);
if (!wallet) return;
// Query its balance in nanoToncoin
@@ -52,7 +52,7 @@ The most practical use of one-off balance checks is right before approving a tra
import { SEND_TRANSACTION_ERROR_CODES } from '@ton/walletkit';
kit.onTransactionRequest(async (event) => {
- const wallet = kit.getWallet(event.walletAddress ?? '');
+ const wallet = kit.getWallet(event.walletId ?? '');
if (!wallet) {
console.error('Wallet not found for a transaction request', event);
await kit.rejectTransactionRequest(event, {
@@ -94,21 +94,21 @@ This example should be modified according to the wallet service's logic:
const POLLING_INTERVAL_MS = 10_000;
/**
- * Starts the monitoring of a given wallet contract `address`,
+ * Starts the monitoring of a given `walletId`,
* calling `onBalanceUpdate()` each `intervalMs` milliseconds
*
* @returns a function to stop monitoring
*/
export function startBalanceMonitoring(
- address: string,
- onBalanceUpdate: (balance: bigint) => void,
+ walletId: string,
+ onBalanceUpdate: (balance: string) => void,
intervalMs: number = POLLING_INTERVAL_MS,
): () => void {
let isRunning = true;
const poll = async () => {
while (isRunning) {
- const wallet = kit.getWallet(address);
+ const wallet = kit.getWallet(walletId);
if (wallet) {
const balance = await wallet.getBalance();
onBalanceUpdate(balance);
@@ -128,7 +128,7 @@ export function startBalanceMonitoring(
// Usage
const stopMonitoring = startBalanceMonitoring(
- walletAddress,
+ walletId,
// The updateUI() function is exemplary and should be replaced by
// a wallet service function that refreshes the
// state of the balance displayed in the interface
@@ -168,13 +168,15 @@ sequenceDiagram
### Emulation and preview
-WalletKit automatically emulates every incoming transaction request before presenting it to the user. The emulation result is available in the `event.preview` object:
+WalletKit tries to automatically emulate every incoming transaction request before presenting it to the user. The emulation result is available in the `event.preview.data` object, which can be `undefined` if emulation was skipped:
```ts title="TypeScript"
kit.onTransactionRequest(async (event) => {
- if (event.preview.result === 'success') {
+ if (!event.preview.data) {
+ console.log('Transaction emulation skipped');
+ } else if (event.preview.data.result === 'success') {
// Emulation succeeded — show the predicted money flow
- const { ourTransfers } = event.preview.moneyFlow;
+ const { ourTransfers } = event.preview.data.moneyFlow;
// This is an array of values,
// where positive amounts mean incoming funds
@@ -191,7 +193,7 @@ kit.onTransactionRequest(async (event) => {
```
### Approve or reject
@@ -199,22 +201,26 @@ kit.onTransactionRequest(async (event) => {
After showing the preview, handle the user's decision:
```ts title="TypeScript" expandable
-// An enumeration of various common error codes
-import { SEND_TRANSACTION_ERROR_CODES } from '@ton/walletkit';
+import {
+ // An enumeration of various common error codes
+ SEND_TRANSACTION_ERROR_CODES,
+ // The transfer type
+ type TransactionTraceMoneyFlowItem,
+} from '@ton/walletkit';
kit.onTransactionRequest(async (event) => {
try {
// Show the emulation preview to the wallet service user
const preview = event.preview;
- const isEmulationSuccessful = preview.result === 'success';
+ const isEmulationSuccessful = preview.data?.result === 'success';
// Build a confirmation message
let confirmMessage = 'Confirm this transaction?';
if (isEmulationSuccessful) {
- const transfers = preview.moneyFlow.ourTransfers;
+ const transfers = preview.data.moneyFlow?.ourTransfers || [];
confirmMessage = `Send ${formatTransfers(transfers)}?`;
} else {
- confirmMessage = 'Emulation failed. Proceed anyway?';
+ confirmMessage = 'Emulation failed or skipped. Proceed anyway?';
}
// Handle user's decision
@@ -239,14 +245,12 @@ kit.onTransactionRequest(async (event) => {
}
});
-function formatTransfers(
- transfers: Array<{ amount: bigint; asset: string }>,
-): string {
- const formatNano = (value: bigint, decimals: number = 9): string => {
- const isNegative = value < 0n;
- const str = (isNegative ? -value : value)
- .toString()
- .padStart(decimals + 1, '0');
+function formatTransfers(transfers: Array): string {
+ const formatNano = (value: string, decimals: number = 9): string => {
+ const bigintValue = BigInt(value);
+ const isNegative = bigintValue < 0n;
+ const absoluteValue = bigintValue < 0n ? -bigintValue : bigintValue;
+ const str = absoluteValue.toString().padStart(decimals + 1, '0');
const intPart = str.slice(0, -decimals) || '0';
const fracPart = str.slice(-decimals).replace(/0+$/, '');
@@ -255,9 +259,7 @@ function formatTransfers(
return `${isNegative ? '-' : ''}${formatted}`;
};
- return transfers
- .map((t) => `${formatNano(t.amount)} ${t.asset}`)
- .join(', ');
+ return transfers.map((t) => `${formatNano(t.amount)} ${t.assetType}`).join(', ');
}
```
@@ -278,11 +280,13 @@ Transactions can be created directly from the wallet service (not from dApps) an
This example should be modified according to the wallet service's logic:
```ts title="TypeScript"
-import { type TonTransferParams } from '@ton/walletkit';
+import { type TONTransferRequest } from '@ton/walletkit';
async function sendToncoin(
- // Recipient's TON wallet contract address as a string
- address: string,
+ // Sender's TON `walletId` as a string
+ walletId: string,
+ // Recipient's TON wallet address as a string
+ recipientAddress: string,
// Amount in nanoToncoins
nanoAmount: BigInt,
// Optional comment string
@@ -295,28 +299,44 @@ async function sendToncoin(
return;
}
- const from = kit.getWallet(address);
- if (!from) {
+ const fromWallet = kit.getWallet(walletId);
+ if (!fromWallet) {
console.error('No wallet contract found');
return;
}
- const transferParams: TonTransferParams = {
- toAddress: address,
- amount: nanoAmount.toString(),
+ const transferParams: TONTransferRequest = {
+ recipientAddress: recipientAddress,
+ transferAmount: nanoAmount.toString(),
// Optional comment OR payload, not both
...(comment && { comment: comment }),
}
// Build transaction content
- const tx = await from.createTransferTonTransaction(transferParams);
+ const tx = await fromWallet.createTransferTonTransaction(transferParams);
// Route into the normal flow,
// triggering the onTransactionRequest() handler
- await kit.handleNewTransaction(from, tx);
+ await kit.handleNewTransaction(fromWallet, tx);
}
```
+
+
## See also
- [Handle transaction requests](/ecosystem/ton-connect/walletkit/web/events#handle-ontransactionrequest)
diff --git a/ecosystem/ton-connect/walletkit/web/wallets.mdx b/ecosystem/ton-connect/walletkit/web/wallets.mdx
index 6781f2b56..146ce233d 100644
--- a/ecosystem/ton-connect/walletkit/web/wallets.mdx
+++ b/ecosystem/ton-connect/walletkit/web/wallets.mdx
@@ -19,15 +19,15 @@ The [basic configuration earlier](/ecosystem/ton-connect/walletkit/web/init#init
Adapter takes in a signer from the previous step and a number of options, namely:
- - `network` — TON Blockchain network, either `CHAIN.MAINNET` or `CHAIN.TESTNET`.
- - `client` — API client to communicate with TON Blockchain. In most cases, the client of the initialized kit via `kit.getApiClient()` would suffice.
+ - `network` — TON Blockchain network: `Network.mainnet()`, `Network.testnet()`, or `Network.custom(chainId)`.
+ - `client` — API client to communicate with TON Blockchain. Use `kit.getApiClient(network)` to get the client for the specified network from the `networks` configuration passed during [WalletKit initialization](/ecosystem/ton-connect/walletkit/web/init).
- `walletId` — identifier of the new wallet, which is used to make its smart contract address unique.
- `workchain` — either `0` for the basechain (default), or `-1` for the masterchain.
```ts title="TypeScript"
import {
- // Network constants (MAINNET/TESTNET)
- CHAIN,
+ // Network object
+ Network,
// Latest wallet version (recommended)
WalletV5R1Adapter,
defaultWalletIdV5R1,
@@ -37,8 +37,8 @@ The [basic configuration earlier](/ecosystem/ton-connect/walletkit/web/init#init
} from '@ton/walletkit';
const walletAdapter = await WalletV5R1Adapter.create(signer, {
- network: CHAIN.TESTNET,
- client: kit.getApiClient(),
+ network: Network.mainnet(),
+ client: kit.getApiClient(Network.mainnet()),
// Either 0 for the basechain (default),
// or -1 for the masterchain
@@ -64,6 +64,10 @@ The [basic configuration earlier](/ecosystem/ton-connect/walletkit/web/init#init
console.log('Wallet address:', wallet.getAddress());
```
+
+
See the complete example for each signer kind:
@@ -104,8 +108,8 @@ import {
Signer,
// Latest wallet version (recommended)
WalletV5R1Adapter,
- // Network constants (MAINNET/TESTNET)
- CHAIN,
+ // Network object
+ Network,
} from '@ton/walletkit';
// 1.
@@ -126,8 +130,8 @@ const signer = await Signer.fromMnemonic(
// 2.
const walletAdapter = await WalletV5R1Adapter.create(signer, {
- network: CHAIN.TESTNET,
- client: kit.getApiClient(),
+ network: Network.mainnet(),
+ client: kit.getApiClient(Network.mainnet()),
});
// 3.
@@ -171,8 +175,8 @@ import {
WalletV5R1Adapter,
// Conversion function
MnemonicToKeyPair,
- // Network constants (MAINNET/TESTNET)
- CHAIN,
+ // Network object
+ Network,
} from '@ton/walletkit';
// 1.
@@ -185,8 +189,8 @@ const signer = await Signer.fromPrivateKey(
// 2.
const walletAdapter = await WalletV5R1Adapter.create(signer, {
- network: CHAIN.TESTNET,
- client: kit.getApiClient(),
+ network: Network.mainnet(),
+ client: kit.getApiClient(Network.mainnet()),
});
// 3.
@@ -215,8 +219,8 @@ A custom signer is useful to maintain complete control over the signing process,
```ts title="TypeScript" expandable
import {
- // Network constants (MAINNET/TESTNET)
- CHAIN,
+ // Network object
+ Network,
// Latest wallet version (recommended)
WalletV5R1Adapter,
// Conversion function
@@ -248,13 +252,13 @@ const signer: WalletSigner = {
},
// Public key as a Hex
- publicKey: Uint8ArrayToHex(keyPair.publicKey),
+ publicKey: Uint8ArrayToHex(keyPair.publicKey) as Hex,
};
// 2.
const walletAdapter = await WalletV5R1Adapter.create(signer, {
- network: CHAIN.TESTNET,
- client: kit.getApiClient(),
+ network: Network.mainnet(),
+ client: kit.getApiClient(Network.mainnet()),
});
// 3.
@@ -278,11 +282,21 @@ Providing the same wallet adapter to the kit multiple times will return the wall
### Get a single wallet
-To get a single wallet by its address, use the `getWallet()` method of the initialized kit.
+The `getWallet()` method expects a wallet identifier string. Note that the same wallet on different chains must have different identifiers. Compose it via the `createWalletId()` helper function:
```ts title="TypeScript"
-const wallet: IWallet = kit.getWallet(walletAdapter.getAddress());
-console.log('TON wallet address:', wallet.getAddress());
+import { createWalletId, Network, type Wallet } from '@ton/walletkit';
+
+// Using the helper function to create a wallet identifier.
+const walletId = createWalletId(
+ Network.mainnet(),
+ walletAdapter.getAddress(),
+);
+const wallet: Wallet | undefined = kit.getWallet(walletId);
+
+if (wallet) {
+ console.log('Wallet address: ', wallet.getAddress());
+}
```
### Get all wallets
@@ -290,16 +304,26 @@ console.log('TON wallet address:', wallet.getAddress());
To obtain all added wallets, use the `getWallets()` method of the initialized kit.
```ts title="TypeScript"
-const wallets: IWallet[] = kit.getWallets();
+const wallets: Wallet[] = kit.getWallets();
wallets.forEach(w => console.log('TON wallet address:', w.getAddress()));
```
### Remove a single wallet
-To remove a single wallet by its address, use the `removeWallet()` method of the initialized kit.
+The `kit.removeWallet()` method accepts either a `walletId` or the adapter instance itself. Compose the identifier via the `createWalletId()` helper function or pass the adapter used when adding the wallet:
```ts title="TypeScript"
-await kit.removeWallet(wallet.getAddress());
+import { createWalletId, Network } from '@ton/walletkit';
+
+// Using the helper function to create a wallet identifier.
+const walletId = createWalletId(
+ Network.mainnet(),
+ walletAdapter.getAddress(),
+);
+await kit.removeWallet(walletId);
+
+// Alternatively, pass the adapter directly.
+await kit.removeWallet(walletAdapter);
```
### Clear all wallets
@@ -310,6 +334,17 @@ To remove all previously added wallets from the kit, use the `clearWallets()` me
await kit.clearWallets();
```
+## Next steps
+
+
+
+
+
## See also
- [WalletKit overview](/ecosystem/ton-connect/walletkit/overview)