Documentation Index
Fetch the complete documentation index at: https://seilabs-docs-bridge-seictl-pr-184.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
ethers v6 Quickstart
This example covers ethers v6 with Sei. The patterns apply whether you are writing a Node.js script, a CLI tool, or a browser app.
Install
Read-Only Provider
import { ethers } from 'ethers';
const provider = new ethers.JsonRpcProvider('https://evm-rpc.sei-apis.com');
Reading Chain Data
This is the first milestone — it needs no private key.
const blockNumber = await provider.getBlockNumber(); // number
console.log('Block number:', blockNumber);
const balance = await provider.getBalance('0xYourAddress'); // bigint, wei
console.log('Balance (SEI):', ethers.formatEther(balance));
const nonce = await provider.getTransactionCount('0xYourAddress'); // number
console.log('Nonce:', nonce);
You’re done when you see:
Block number: 148203117
Balance (SEI): 12.5
Nonce: 7
The exact numbers are illustrative — your block number and balance will differ. getBlockNumber() and getTransactionCount() return a number, while getBalance() returns a bigint in wei (format it with ethers.formatEther()).
Browser Provider
In a browser context, connect to the user’s injected wallet:
const provider = new ethers.BrowserProvider(window.ethereum);
const signer = await provider.getSigner();
const address = await signer.getAddress();
Wallet from Private Key
For scripts and backend services:
const wallet = new ethers.Wallet('0xYourPrivateKey', provider);
Sending a Transaction
Next step — this requires a funded account; get testnet SEI from the faucet.
const tx = await wallet.sendTransaction({
to: '0xRecipient',
value: ethers.parseEther('1'),
});
const receipt = await tx.wait();
// receipt is final immediately — Sei has instant finality
Reading a Contract
const abi = ['function balanceOf(address owner) view returns (uint256)'];
const contract = new ethers.Contract('0xTokenAddress', abi, provider);
const balance = await contract.balanceOf('0xYourAddress');
Writing to a Contract
Pass a signer (wallet or browser signer) to the contract constructor for write operations:
const contract = new ethers.Contract('0xTokenAddress', abi, wallet);
const tx = await contract.transfer('0xRecipient', 1_000_000n);
const receipt = await tx.wait();
Estimating Gas
const gas = await provider.estimateGas({
from: wallet.address,
to: '0xContractAddress',
data: '0xCalldata',
});
Listening for Events
contract.on('Transfer', (from, to, value) => {
console.log('Transfer:', { from, to, value });
});
// Stop listening
contract.off('Transfer');
Using Python (web3.py)
Sei is fully EVM-compatible, so any standard Ethereum client works — including Python’s web3.py.
from web3 import Web3
w3 = Web3(Web3.HTTPProvider("https://evm-rpc.sei-apis.com"))
print("Connected:", w3.is_connected())
print("Latest block:", w3.eth.block_number)
print("Chain ID:", w3.eth.chain_id) # 1329
You’re done when you see:
Connected: True
Latest block: 148203117
Chain ID: 1329
The block number is illustrative; the chain ID is always 1329 on mainnet.
Next Steps