-
Notifications
You must be signed in to change notification settings - Fork 2
Bridge API
The WebSocket bridge connects the browser to the TON blockchain via a local tonutils-bridge process. It exposes a JSON-RPC 2.0 interface over WebSocket, organized into namespaces.
- Address:
ws://127.0.0.1:<wsPort>(default 8081, configurable in Settings > Network) - Reconnect delay: 2 seconds on disconnect
- RPC timeout: 60 seconds per request
- Request IDs are rewritten internally (UUID) and restored in responses
Push notifications (messages with method but no id) are forwarded only to tabs that have made at least one subscribe.* call.
| Namespace | Description |
|---|---|
lite |
Blockchain queries: accounts, transactions, blocks, send messages |
wallet |
Wallet seqno and public key queries |
subscribe |
Real-time account state and transaction subscriptions |
dns |
TON DNS domain resolution |
Enable via Settings > Bridge > Namespaces.
| Namespace | Description |
|---|---|
jetton |
Jetton token data and wallet addresses |
nft |
NFT item and collection data |
sbt |
Soul-bound token queries |
payment |
Payment channel state queries |
network |
Network status and connectivity info |
adnl |
Peer-to-peer ADNL connections |
overlay |
Overlay network participation |
dht |
Distributed hash table lookups |
subscribe_trace |
Deep transaction trace subscriptions |
A namespace is disabled only when enabled is explicitly set to false. If absent from configuration, it defaults to enabled.
Some namespaces support additional options:
lite: send_wait_timeout, watch_timeout
subscribe: max_subscriptions, max_multi_accounts, max_config_params
subscribe_trace: max_depth, default_depth, max_msg_timeout, default_msg_timeout, max_resolvers
adnl: max_peers, query_max_timeout, ssrf_protection
overlay: max_overlays, query_max_timeout
dht: tunnel_timeout, allow_write
Every JSON-RPC method requires a permission check before it reaches the bridge.
| Scope | Description | Namespaces |
|---|---|---|
blockchain |
Read blockchain data | lite, subscribe, dns, jetton, nft, wallet, sbt, payment, network |
p2p |
Connect to the TON P2P network | adnl, overlay, dht (read methods) |
write |
Broadcast data to the network | Specific methods only (see below) |
These methods require write permission regardless of their namespace:
-
lite.sendMessage,lite.sendMessageWait,lite.sendAndWatch -
dht.storeAddress,dht.storeOverlayNodes -
adnl.sendMessage,adnl.setQueryHandler,adnl.answer -
overlay.sendMessage,overlay.setQueryHandler,overlay.answer
Methods not matching any known namespace return JSON-RPC error -32601 (Unknown method).
| Decision | Meaning | Persisted to disk |
|---|---|---|
granted |
Permanently allowed (user clicked "Always Allow") | Yes |
denied |
Permanently blocked | Yes |
session |
Allowed until the last tab for that domain closes | No |
-
methodToScope(method)determines the required scope. Unknown methods return error-32601. - Existing permission is checked for the domain + scope pair:
-
denied: return error-32003immediately -
grantedorsession: forward to bridge -
unknown: check default policy
-
- If default policy is
deny: return error-32003without prompting - If default policy is
ask: show permission prompt
A centered overlay dialog (400 x 240 px) with:
- Title: "Bridge Permission: <domain>"
- Description of what the scope allows
- Three buttons: Deny, Allow (session-only), Always Allow (permanent)
- Dismissing the dialog is treated as Deny
Concurrent requests for the same domain + scope share a single prompt. The second request waits for the first prompt to resolve.
When a tab closes:
- The tab is removed from active tracking
- If no other tab shares the same domain, all
sessiongrants for that domain are revoked - Permanent grants (
granted,denied) are unaffected
Configurable in Settings > Bridge > Default Policy:
-
ask(default): show permission prompt for unknown requests -
deny: reject all unknown requests silently
tonnet.resistance.dog · GitHub · MIT License
Tonnet Browser
Getting Started
Reference
Development