Installation

Installation

Guide to install and configure XO Connect in your project.

Installation via npm

npm install xo-connect

Or using yarn:

yarn add xo-connect

Dependencies

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

ParameterTypeDescription
rpcsRecord<string, string>RPC URLs by chainId (hex) - Optional, only for read operations
defaultChainIdstringDefault chainId in hex format (optional, defaults to 0x1)
debugbooleanActivates the debug panel (optional)

Supported Networks

NetworkChainId (Hex)ChainId (Decimal)
Bitcoin--
Ethereum Mainnet0x11
Polygon0x89137
Arbitrum0xa4b142161
Optimism0xa10
BSC0x3856
Avalanche0xa86a43114