API Reference
Complete XO Connect API documentation.
XOConnectProvider
EIP-1193 compatible provider for use with ethers.js and other Web3 libraries.
Constructor
new XOConnectProvider(options?: {
rpcs?: Record<string, string>; // Optional - only for read operations
defaultChainId?: string; // Optional - defaults to "0x1"
debug?: boolean; // Optional - enables debug panel
})request()
Main EIP-1193 method for all operations.
provider.request({
method: string,
params?: any[]
}): Promise<any>on()
Subscribe to provider events.
provider.on(event: string, listener: (...args: any[]) => void): void
// Available events:
// - 'connect'
// - 'chainChanged'
// - 'accountsChanged'removeListener()
provider.removeListener(event: string, listener: Function): voidgetClient()
Gets connected client information.
provider.getClient(): Promise<Client>getAvailableCurrencies()
Gets available currencies with valid chainId.
provider.getAvailableCurrencies(): Promise<Currency[]>XOConnect (Singleton)
Core class for direct communication with XO wallet.
connect()
XOConnect.connect(): Promise<{ id: string; client: Client }>getClient()
XOConnect.getClient(): Promise<Client | null>sendRequest()
XOConnect.sendRequest(params: {
method: Method;
data?: any;
currency?: string;
onSuccess: (response: Response) => void;
onCancel: () => void;
}): string // Returns request IDdisconnect()
XOConnect.disconnect(): voidcancelRequest()
XOConnect.cancelRequest(id: string): voidSupported JSON-RPC Methods
Accounts and SigningRequires wallet
| Method | Description | Returns |
|---|---|---|
| eth_requestAccounts | Request connection and return accounts | string[] |
| eth_accounts | Return connected accounts | string[] |
| personal_sign | Sign a message (EIP-191) | string |
| eth_sendTransaction | Send a transaction | string (tx hash) |
| eth_signTypedData | Sign typed data (EIP-712) | string |
| eth_signTypedData_v4 | Sign typed data v4 | string |
Network Management
| Method | Description | Returns |
|---|---|---|
| eth_chainId | Return current chainId | string (hex) |
| net_version | Return network ID | string (decimal) |
| wallet_switchEthereumChain | Switch to another network | null |
Reads (via RPC)Requires RPC
| Method | Description |
|---|---|
| eth_blockNumber | Current block number |
| eth_gasPrice | Current gas price |
| eth_getBalance | Account balance |
| eth_getTransactionCount | Account nonce |
| eth_getCode | Contract code |
| eth_call | Execute read call |
| eth_estimateGas | Estimate transaction gas |
| eth_getLogs | Get logs/events |
| eth_getBlockByNumber | Block info by number |
| eth_getBlockByHash | Block info by hash |
| eth_getTransactionByHash | Transaction info |
| eth_getTransactionReceipt | Transaction receipt |
TypeScript Interfaces
Client
interface Client {
_id: string;
alias: string;
image: string;
currencies: Currency[];
}Currency
interface Currency {
id: string; // e.g.: "ethereum.mainnet.native.eth"
address: string; // Ethereum address
chainId?: string; // ChainId in hex (e.g.: "0x1")
}Method (Enum)
enum Method {
connect = "connect",
personalSign = "personalSign",
transactionSign = "transactionSign",
typedDataSign = "typedDataSign",
available = "available"
}