Skip to Content
dApps
On this page

API Reference

Reference for OneKey’s Conflux provider methods and types.


Methods

MethodDescription
request({ method, params })Send JSON-RPC request
isConnected()Check connection status
on(event, callback)Subscribe to events
off(event, callback)Unsubscribe from events

RPC Methods

MethodDescription
cfx_requestAccountsRequest connection
cfx_accountsGet connected accounts
cfx_chainIdGet chain ID
cfx_sendTransactionSend transaction
cfx_callCall contract (read-only)
cfx_estimateGasAndCollateralEstimate gas
cfx_getBalanceGet account balance
cfx_getTransactionByHashGet transaction
cfx_getTransactionReceiptGet receipt
net_versionGet network ID

Events

EventParametersDescription
connect{ chainId, networkId }Connected to network
disconnect-Disconnected
chainChangedchainIdNetwork changed
accountsChangedaccounts[]Accounts changed

Deprecated Methods

These methods still work but are deprecated:

// Deprecated: use request({ method: 'cfx_requestAccounts' }) await provider.enable() // Deprecated: use request() await provider.send({ method: 'cfx_accounts' }) await provider.sendAsync({ method: 'cfx_accounts' }, callback) // Deprecated: use request({ method: 'cfx_chainId' }) provider.chainId // Deprecated: use request({ method: 'net_version' }) provider.networkVersion // Deprecated: use request({ method: 'cfx_accounts' }) provider.selectedAddress

Error Codes

CodeDescription
4001User rejected request
-32700Parse error
-32600Invalid request
-32601Method not found
-32602Invalid params
-32603Internal error
Last updated on