API Notes
This guide lists the UKey Wallet Conflux Provider methods, RPCs, events, deprecated interfaces, and error codes. New integrations should call through request({ method, params }).
Methods
| Method | Details |
|---|---|
request({ action, params }) | Send JSON-RPC request |
isConnected() | Check connection status |
on(event, callback) | Subscribe to events |
off(event, callback) | Unsubscribe from events |
RPC method
| Method | Details |
|---|---|
cfx_requestAccounts | Request connection |
cfx_accounts | Get connected accounts |
cfx_chainId | Get the chain ID |
cfx_sendTransaction | Send transaction |
cfx_call | Call contract (read-only) |
cfx_estimateGasAndCollateral | Estimate gas |
cfx_getBalance | Get the account balance |
cfx_getTransactionByHash | Get the transaction |
cfx_getTransactionReceipt | Get the receipt |
net_version | Get the network ID |
Events
| Event | Inputs | Details |
|---|---|---|
connect | { chainId, networkId } | Connected to the network |
disconnect | - | Connection closed |
chainChanged | chainId | Network updated |
accountsChanged | accounts[] | Selected account changed |
Deprecated method
The following compatible methods will still work, but new code should use request instead:
// 已废弃,改用 request({ method: 'cfx_requestAccounts' })
await provider.enable();
// 已废弃,改用 request()
await provider.send({ method: "cfx_accounts" });
await provider.sendAsync({ method: "cfx_accounts" }, callback);
// 已废弃,改用 request({ method: 'cfx_chainId' })
provider.chainId;
// 已废弃,改用 request({ method: 'net_version' })
provider.networkVersion;
// 已废弃,改用 request({ method: 'cfx_accounts' })
provider.selectedAddress;
error code
| Code | Details |
|---|---|
| 4001 | User rejected the request |
| -32700 | Failed to parse the request |
| -32600 | Request shape is invalid |
| -32601 | Requested method is unknown |
| -32602 | Parameters failed validation |
| -32603 | Provider internal failure |