跳到主要内容

Sei API Quick Start Guide

BlockEden.xyz provides high-performance infrastructure for Sei, the first parallelized EVM blockchain. Access Sei's unique dual-architecture through our enterprise-grade API endpoints with sub-second response times.

What is Sei?

Sei is a parallelized EVM blockchain that combines Ethereum compatibility with Cosmos SDK functionality:

  • Sub-second Finality: Fastest transaction confirmation in the industry
  • Parallelized Execution: Optimistic parallel processing for maximum throughput
  • Dual Architecture: Both EVM (Ethereum) and Cosmos SDK APIs
  • High Performance: Thousands of transactions per second
  • Full EVM Compatibility: Use existing Ethereum tools and wallets

API Endpoints

BlockEden.xyz supports all Sei API types through our global infrastructure:

Mainnet

  • EVM JSON-RPC: https://api.blockeden.xyz/sei/<your-api-key>
  • WebSocket: wss://api.blockeden.xyz/sei/<your-api-key>
  • Cosmos REST: https://api.blockeden.xyz/sei/<your-api-key>/cosmos/
  • Tendermint RPC: https://api.blockeden.xyz/sei/<your-api-key>/tm/

Quick Start

Step 1: Get Your API Key

  1. Visit BlockEden.xyz Dashboard
  2. Create a new API key for Sei
  3. Select Mainnet

Step 2: Test Connection

EVM JSON-RPC (Ethereum Compatible)

curl -X POST https://api.blockeden.xyz/sei/<your-api-key> \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_blockNumber",
"params": [],
"id": 1
}'

Cosmos REST API

curl -X GET https://api.blockeden.xyz/sei/<your-api-key>/cosmos/bank/v1beta1/supply

Tendermint RPC

curl -X POST https://api.blockeden.xyz/sei/<your-api-key>/tm \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "status",
"params": [],
"id": 1
}'

Supported API Methods

EVM JSON-RPC Methods

All standard Ethereum JSON-RPC methods are supported:

  • Account Methods: eth_getBalance, eth_getTransactionCount, eth_getCode
  • Block Methods: eth_blockNumber, eth_getBlockByNumber, eth_getBlockByHash
  • Transaction Methods: eth_sendRawTransaction, eth_getTransactionReceipt
  • Contract Methods: eth_call, eth_estimateGas, eth_getLogs
  • Gas Methods: eth_gasPrice, eth_feeHistory, eth_maxPriorityFeePerGas
  • Network Methods: eth_chainId, net_version

Cosmos REST Endpoints

  • Bank Module: /cosmos/bank/v1beta1/* - Token balances and transfers
  • Staking Module: /cosmos/staking/v1beta1/* - Validator and delegation info
  • Governance Module: /cosmos/gov/v1beta1/* - Proposals and voting
  • Distribution Module: /cosmos/distribution/v1beta1/* - Rewards and commission
  • Auth Module: /cosmos/auth/v1beta1/* - Account information

Tendermint RPC Methods

  • Blockchain Info: status, health, net_info
  • Block Data: block, block_by_hash, blockchain
  • Transaction Data: tx, tx_search, broadcast_tx_sync
  • Consensus: validators, consensus_state

Code Examples

JavaScript/TypeScript

// EVM (Ethereum-style) usage
import { ethers } from 'ethers';

const provider = new ethers.JsonRpcProvider('https://api.blockeden.xyz/sei/<your-api-key>');

// Get latest block
const blockNumber = await provider.getBlockNumber();
console.log('Latest block:', blockNumber);

// Get account balance
const balance = await provider.getBalance('0x742D5Cc6bF2442E8C7c74c7b4Be6AB9d6f10f5B4');
console.log('Balance:', ethers.formatEther(balance), 'SEI');
// Cosmos SDK usage
import { StargateClient } from '@cosmjs/stargate';

const client = await StargateClient.connect('https://api.blockeden.xyz/sei/<your-api-key>');

// Get account balance
const balance = await client.getBalance('sei1abc...xyz', 'usei');
console.log('Balance:', balance.amount, balance.denom);

Python

import requests

# EVM JSON-RPC
def get_block_number():
url = "https://api.blockeden.xyz/sei/<your-api-key>"
payload = {
"jsonrpc": "2.0",
"method": "eth_blockNumber",
"params": [],
"id": 1
}
response = requests.post(url, json=payload)
return int(response.json()['result'], 16)

# Cosmos REST API
def get_bank_balance(address):
url = f"https://api.blockeden.xyz/sei/<your-api-key>/cosmos/bank/v1beta1/balances/{address}"
response = requests.get(url)
return response.json()

Go

package main

import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)

type RPCRequest struct {
JSONRPC string `json:"jsonrpc"`
Method string `json:"method"`
Params []interface{} `json:"params"`
ID int `json:"id"`
}

func getBlockNumber() {
url := "https://api.blockeden.xyz/sei/<your-api-key>"

req := RPCRequest{
JSONRPC: "2.0",
Method: "eth_blockNumber",
Params: []interface{}{},
ID: 1,
}

jsonData, _ := json.Marshal(req)
resp, _ := http.Post(url, "application/json", bytes.NewBuffer(jsonData))
defer resp.Body.Close()

// Handle response...
}

Authentication

All API requests require your API key in the URL path:

https://api.blockeden.xyz/sei/<your-api-key>/[optional-path]

Examples:

  • EVM: https://api.blockeden.xyz/sei/abc123/
  • Cosmos: https://api.blockeden.xyz/sei/abc123/cosmos/bank/v1beta1/supply
  • Tendermint: https://api.blockeden.xyz/sei/abc123/tm

Rate Limits

  • Free Tier: 100 requests/second, 86,400 requests/day
  • Pro Tier: 1,000 requests/second, 10M requests/day
  • Enterprise: Custom limits based on your needs

Rate limit headers are included in responses:

X-RateLimit-Limit: 100
X-RateLimit-Remaining: 99
X-RateLimit-Reset: 1640995200

Network Information

Mainnet (Pacific-1)

  • Chain ID: pacific-1 (Cosmos), 1329 (EVM)
  • Native Token: SEI (6 decimals)
  • Block Time: ~0.4 seconds
  • Explorer: https://seitrace.com

WebSocket Subscriptions

Real-time data streaming for both EVM and Tendermint events:

// EVM event subscriptions
const ws = new WebSocket('wss://api.blockeden.xyz/sei/<your-api-key>');

ws.onopen = () => {
ws.send(JSON.stringify({
jsonrpc: '2.0',
method: 'eth_subscribe',
params: ['newHeads'],
id: 1
}));
};

ws.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log('New block:', data);
};

Error Handling

Common HTTP Status Codes

  • 200: Success
  • 400: Bad Request (invalid JSON or parameters)
  • 401: Unauthorized (invalid API key)
  • 429: Too Many Requests (rate limit exceeded)
  • 500: Internal Server Error

JSON-RPC Error Codes

  • -32700: Parse error
  • -32600: Invalid Request
  • -32601: Method not found
  • -32602: Invalid params
  • -32603: Internal error
  • -32000: Server error

Example Error Response

{
"jsonrpc": "2.0",
"error": {
"code": -32602,
"message": "Invalid params",
"data": "Missing required parameter"
},
"id": 1
}

Best Practices

Performance Optimization

  1. Use WebSockets for real-time data instead of polling
  2. Batch requests when possible to reduce latency
  3. Cache responses for frequently accessed data
  4. Use appropriate timeouts (recommend 30s for HTTP)

Error Handling

async function makeRequest(method, params) {
try {
const response = await fetch(endpoint, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ jsonrpc: '2.0', method, params, id: 1 })
});

if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
}

const data = await response.json();
if (data.error) {
throw new Error(`RPC Error ${data.error.code}: ${data.error.message}`);
}

return data.result;
} catch (error) {
console.error('API request failed:', error);
throw error;
}
}

Retry Logic

async function withRetry(fn, maxRetries = 3) {
for (let i = 0; i < maxRetries; i++) {
try {
return await fn();
} catch (error) {
if (i === maxRetries - 1) throw error;
await new Promise(resolve => setTimeout(resolve, 1000 * Math.pow(2, i)));
}
}
}

Next Steps

Support