Skip to Content
dApp 接入

API 参考

OneKey TON provider 方法和类型的完整参考。


方法

方法描述
connect(version?, request?)连接钱包
restoreConnection()恢复之前的会话
disconnect()断开钱包连接
send(message)发送 RPC 请求
listen(callback)监听钱包事件

Send 方法

方法描述
sendTransaction发送 TON 或与合约交互
signData签署任意数据 cell
disconnect通过 RPC 断开连接

类型

账户信息

interface AccountInfo { address: string // 原始地址 (0:<hex>) network: string // 网络 ID (-239 主网, -3 测试网) publicKey: string // 十六进制公钥(无 0x 前缀) walletStateInit: string // Base64 编码的状态初始化 }

交易请求

interface TransactionRequest { valid_until?: number // 有效期 UNIX 时间戳 network?: string // 网络 ID from?: string // 发送者地址 messages: Message[] // 最多 4 条消息 }

消息

interface Message { address: string // 接收者(原始格式) amount: string // 金额(nanotons) payload?: string // 合约调用的 Base64 BOC stateInit?: string // 部署用的 Base64 StateInit }

签署数据请求

interface SignDataRequest { schema_crc: number // Schema 标识符 cell: string // Base64 编码的 cell publicKey?: string // 可选的特定密钥 }

签署数据结果

interface SignDataResult { signature: string // Base64 签名 timestamp: number // UNIX 时间戳 (UTC) }

设备信息

interface DeviceInfo { platform: string // 'iphone' | 'android' | 'windows' | 'mac' | 'linux' appName: string // 'onekey' appVersion: string // 钱包版本 maxProtocolVersion: number // 2 features: string[] // 支持的功能 }

网络

网络网络 ID
主网-239
测试网-3

事件

事件描述
accountChanged账户已变更
disconnect钱包已断开连接

错误码

错误码描述
0未知错误
1请求错误
100未知应用
300用户拒绝请求
400不支持的方法
Last updated on