Documentation Index
Fetch the complete documentation index at: https://seilabs-docs-evm-fixes-hardhat-v3.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
These snippets are TypeScript. Run any of them with no separate build step using tsx (Node 18+):
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.
// Any valid Sei EVM address — swap in your own
const address = '0x0000000000000000000000000000000000000000';
const blockNumber = await provider.getBlockNumber(); // number
console.log('Block number:', blockNumber);
const balance = await provider.getBalance(address); // bigint, wei
console.log('Balance (SEI):', ethers.formatEther(balance));
const nonce = await provider.getTransactionCount(address); // 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');
Next Steps