Installation
Guide to install and configure XO Connect in your project.
Installation via npm
npm install xo-connectOr using yarn:
yarn add xo-connectDependencies
XO Connect has the following dependencies:
ethers.js
Version ^5.7.2 - Used for signature verification and utilities
uuid
Version ^11.0.5 - For unique ID generation
Simple Configuration
For basic operations (connect, sign messages, send transactions), you don't need to configure RPCs:
simple.ts
import { XOConnectProvider } from 'xo-connect';
// Simple setup - no RPC needed for connect, sign, and send
const provider = new XOConnectProvider();
// Connect wallet
const accounts = await provider.request({
method: 'eth_requestAccounts'
});
// Sign a message
const signature = await provider.request({
method: 'personal_sign',
params: ['Hello!', accounts[0]]
});Full Configuration (with RPC)
If you need to read blockchain data (balances, transactions, etc.), configure RPC URLs:
full-config.ts
import { XOConnectProvider } from 'xo-connect';
const provider = new XOConnectProvider({
rpcs: {
"0x1": "https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY",
"0x89": "https://polygon-mainnet.g.alchemy.com/v2/YOUR_KEY",
"0xa4b1": "https://arb-mainnet.g.alchemy.com/v2/YOUR_KEY"
},
defaultChainId: "0x1",
debug: false // Set to true for development
});
// Now you can also read blockchain data
const balance = await provider.request({
method: 'eth_getBalance',
params: [accounts[0], 'latest']
});NOT required for: Connect wallet, sign messages, send transactions, switch networks
Required for: Get balances, read contracts, get transaction receipts, estimate gas
Configuration Parameters
| Parameter | Type | Description |
|---|---|---|
| rpcs | Record<string, string> | RPC URLs by chainId (hex) - Optional, only for read operations |
| defaultChainId | string | Default chainId in hex format (optional, defaults to 0x1) |
| debug | boolean | Activates the debug panel (optional) |
Supported Networks
| Network | ChainId (Hex) | ChainId (Decimal) |
|---|---|---|
| Bitcoin | - | - |
| Ethereum Mainnet | 0x1 | 1 |
| Polygon | 0x89 | 137 |
| Arbitrum | 0xa4b1 | 42161 |
| Optimism | 0xa | 10 |
| BSC | 0x38 | 56 |
| Avalanche | 0xa86a | 43114 |