# @tonconnect/protocol

> ℹ️ If you want to integrate TonConnect to your dApp, you should use [@tonconnect/sdk](https://www.npmjs.com/package/@tonconnect/sdk)

Latest version **3.0.0** (published 2026-06-10) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @tonconnect/protocol
pnpm add @tonconnect/protocol
yarn add @tonconnect/protocol
bun add @tonconnect/protocol
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2026-06-10 |
| First published | 2022-10-26 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 113.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 560 |
| Author | tonconnect |
| Maintainers | thekiba, it-tonstudio-io |
| Keywords | TON, Wallet, ton-connect, Connect, Tonkeeper |

## Links

- npm: https://www.npmjs.com/package/@tonconnect/protocol
- Repository: https://github.com/ton-connect/sdk
- Homepage: https://github.com/ton-connect/sdk/tree/main/packages/protocol
- Issues: https://github.com/ton-connect/sdk/issues
- npm.io page: https://npm.io/package/@tonconnect/protocol

## Dependencies (2)

- [tweetnacl](https://npm.io/package/tweetnacl.md) ^1.0.3
- [tweetnacl-util](https://npm.io/package/tweetnacl-util.md) ^0.15.1

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 3.0.0 (latest) — 2026-06-10
- 3.0.0-beta.2 (beta) — 2026-05-18
- 2.5.0-alpha.1 (alpha) — 2026-05-15
- 2.5.0-alpha.0 — 2026-05-13
- 2.4.0 — 2026-01-28
- 2.4.0-beta.0 — 2025-11-17
- 2.3.0 — 2025-06-25
- 2.3.0-beta.0 — 2025-05-08
- 2.2.7 — 2025-03-06
- 2.2.7-alpha.1 — 2025-02-18
- 2.2.7-alpha.0 — 2025-02-17
- 2.2.6 — 2023-11-06
- 2.2.6-beta.0 — 2023-11-02
- 2.2.5 — 2023-03-09
- 2.2.4 — 2023-03-01
- … 32 more at https://npm.io/package/@tonconnect/protocol/versions

## README

# TON Connect protocol models

ℹ️ If you want to integrate TonConnect to your dApp, you should use [@tonconnect/sdk](https://www.npmjs.com/package/@tonconnect/sdk)

[Latest API documentation](https://docs.ton.org/applications/ton-connect/api-reference/protocol)

## Summary
Package contains protocol requests, responses and event models and encoding, decoding functions.

You can use it to integrate TonConnect to your wallet app (written with TypeScript).

## Get started

### Install package
`npm i @tonconnect/protocol`

### Use protocol models in your app

```ts
import { AppRequest, RpcMethod, WalletResponse } from '@tonconnect/protocol';

function myWalletAppRequestsHandler<T extends RpcMethod>(request: AppRequest<T>): Promise<WalletResponse<T>> {
    // handle request, ask the user for a confirmation and return WalletResponse
}

```

### Use protocol cryptography in your app

```ts
import { SessionCrypto, WalletMessage, Base64, hexToByteArray } from '@tonconnect/protocol';

function encodeIncommingHTTPBridgeRequest(encryptedMessage: string, from: string): WalletMessage {
    const sessionCrypto = new SessionCrypto(yourStoredSessionReypair);

    const decryptedMessage =
        sessionCrypto.decrypt(
            Base64.decode(bridgeIncomingMessage.message).toUint8Array(),
            hexToByteArray(bridgeIncomingMessage.from)
        );
    
    return  JSON.parse(decryptedMessage);
}
```

### Network identifiers

The package exports `CHAIN` enum with values `MAINNET = '-239'` and `TESTNET = '-3'` representing TON network IDs. The `ChainId` type (`CHAIN | string`) allows using these predefined values or any custom network identifier string, enabling support for custom networks and future network additions without protocol changes.

The `ChainId` is used to specify the desired network when establishing wallet connections (via `TonAddressItem.network` field), and for indicating the network context in transaction sending and data signing operations (like `SignDataPayload.network` field), ensuring that all protocol operations can target the correct network.

---
_Source: https://npm.io/package/@tonconnect/protocol · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
