Getting Started

Connect to TON using OneKey's TON Connect compatible provider

Learn how to detect, connect, and interact with TON using OneKey's provider.

OneKey implements the TON Connect 2.0 protocol, ensuring compatibility with all TON dApps.


Provider Detection

// Detect OneKey TON provider
const provider = window.$onekey?.tonconnect

if (!provider) {
  throw new Error('OneKey TON provider not detected')
}

// Check device and wallet info
console.log('Device:', provider.deviceInfo)
console.log('Wallet:', provider.walletInfo)
console.log('Protocol Version:', provider.protocolVersion) // 2

Connect Wallet

// Basic connection
const connectEvent = await provider.connect()

if (connectEvent.event === 'connect') {
  const addressItem = connectEvent.payload.items.find(
    item => item.name === 'ton_addr'
  )
  console.log('Connected:', addressItem.address)
} else {
  console.error('Connection failed:', connectEvent.payload.message)
}

Connect with Manifest

For production apps, provide a manifest URL:


App Manifest Format

Create tonconnect-manifest.json in your app root:


Restore Connection

Restore a previous session:


Disconnect


Event Handling


Using with TON Connect SDK

For React applications, use the official TON Connect SDK:

OneKey is automatically detected by TON Connect SDK.

Last updated

Was this helpful?