Skip to main content

Documentation Index

Fetch the complete documentation index at: https://seilabs-docs-evm-reference-and-sei-js-examples.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

WebSocket Connections

Sei supports eth_subscribe over WebSocket. You can subscribe to new blocks, event logs, and pending transactions using standard library WebSocket transports.

Endpoints

NetworkWebSocket endpoint
Mainnetwss://evm-ws.sei-apis.com
Testnetwss://evm-ws-testnet.sei-apis.com
Devnetwss://evm-ws-arctic-1.sei-apis.com

Connecting

import { createPublicClient, webSocket } from 'viem';
import { sei } from '@sei-js/precompiles/viem';

const client = createPublicClient({
  chain: sei,
  transport: webSocket('wss://evm-ws.sei-apis.com'),
});

Watching New Blocks

const unwatch = client.watchBlocks({
  onBlock: (block) => {
    console.log('New block:', block.number);
  },
});

// Stop watching
unwatch();

Watching Contract Events

import { parseAbiItem } from 'viem';

const unwatch = client.watchEvent({
  address: '0xContractAddress',
  event: parseAbiItem('event Transfer(address indexed from, address indexed to, uint256 value)'),
  onLogs: (logs) => {
    console.log('Transfer events:', logs);
  },
});

Watching ERC-20 Transfers Across All Contracts

viem
import { parseAbiItem } from 'viem';

const unwatch = client.watchEvent({
  event: parseAbiItem('event Transfer(address indexed from, address indexed to, uint256 value)'),
  onLogs: (logs) => {
    logs.forEach((log) => {
      console.log(`Transfer on ${log.address}:`, log.args);
    });
  },
});

Notes

  • Sei’s instant finality means every block emitted over WebSocket is already final — no need to wait for additional confirmations before acting on an event.
  • Pending transaction subscriptions (newPendingTransactions) are supported at the RPC level but Sei does not guarantee Ethereum-style pending state visibility.