Skip to main content

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

MethodDetails
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

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

Events

EventInputsDetails
connect{ chainId, networkId }Connected to the network
disconnect-Connection closed
chainChangedchainIdNetwork updated
accountsChangedaccounts[]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

CodeDetails
4001User rejected the request
-32700Failed to parse the request
-32600Request shape is invalid
-32601Requested method is unknown
-32602Parameters failed validation
-32603Provider internal failure