TRON
TRON integration via OneKey's TronLink-compatible provider
Integrate TRON blockchain using OneKey's TronLink-compatible provider. Access via window.$onekey.tron or window.tronWeb.
OneKey's TRON provider is fully compatible with TronLink, including TronWeb and SunWeb instances.
Quick Links
Provider Detection
// OneKey injects both the provider and TronWeb instances
const provider = window.$onekey?.tron
// TronWeb is available globally after connection
const tronWeb = window.tronWeb
if (!provider) {
throw new Error('OneKey TRON provider not detected')
}
// Check if it's TronLink compatible
console.log('isTronLink:', provider.isTronLink) // trueQuick Start
Request Accounts
Check Connection Status
Using TronWeb
After connection, TronWeb instance is available globally:
Get Balance
Send TRX
Send TRC20 Token
Transactions
Sign Transaction
Sign a transaction without broadcasting:
Smart Contract Interaction
Trigger Smart Contract
Message Signing
Sign Message V1 (Hex)
Sign hex-encoded messages:
Sign Message V2 (UTF-8)
Sign UTF-8 messages directly:
Verify Signature
Event Handling
Listen for Account Changes
Listen for Network Changes
Window Events (TronLink Compatible)
API Reference
Provider Methods
request({ method, params })
Generic JSON-RPC request
sign(transaction)
Sign a transaction
signMessage(hexMessage)
Sign hex message (V1)
signMessageV2(message)
Sign UTF-8 message (V2)
Request Methods
tron_requestAccounts
Request connection
tron_getProviderState
Get provider state
tron_signTransaction
Sign transaction
signMessageV1
Sign message V1
signMessageV2
Sign message V2
Response Codes
200
Success
4000
User rejected
4001
Request in queue
Events
accountsChanged
Account changed
chainChanged
Network changed
connect
Connected
disconnect
Disconnected
Using SunWeb
For DappChain (side chain) operations:
Error Handling
Migration from TronLink
OneKey is TronLink-compatible. Update your detection logic:
Last updated
Was this helpful?