On this page
API Reference
Reference for OneKey’s Conflux provider methods and types.
Methods
| Method | Description |
|---|---|
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
| Method | Description |
|---|---|
cfx_requestAccounts | Request connection |
cfx_accounts | Get connected accounts |
cfx_chainId | Get chain ID |
cfx_sendTransaction | Send transaction |
cfx_call | Call contract (read-only) |
cfx_estimateGasAndCollateral | Estimate gas |
cfx_getBalance | Get account balance |
cfx_getTransactionByHash | Get transaction |
cfx_getTransactionReceipt | Get receipt |
net_version | Get network ID |
Events
| Event | Parameters | Description |
|---|---|---|
connect | { chainId, networkId } | Connected to network |
disconnect | - | Disconnected |
chainChanged | chainId | Network changed |
accountsChanged | accounts[] | 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.selectedAddressError Codes
| Code | Description |
|---|---|
| 4001 | User rejected request |
| -32700 | Parse error |
| -32600 | Invalid request |
| -32601 | Method not found |
| -32602 | Invalid params |
| -32603 | Internal error |
Last updated on