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
tsx (Node 18+):
Read-Only Provider
Reading Chain Data
This is the first milestone — it needs no private key.getBlockNumber() and getTransactionCount() return a number, while getBalance() returns a bigint in wei (format it with ethers.formatEther()).
Try It Live
Run these read-only calls against Sei mainnet right now — no install, no private key. They’re plain JSON-RPC, the same reads the script above performs.Edit and run
Edit and re-run the full ethers code from this page live in the browser — a real ethers v6JsonRpcProvider reading Sei testnet:
Browser Provider
In a browser context, connect to the user’s injected wallet:Wallet from Private Key
For scripts and backend services:Sending a Transaction
Next step — this requires a funded account; get testnet SEI from the faucet.Reading a Contract
Writing to a Contract
Pass a signer (wallet or browser signer) to the contract constructor for write operations:Estimating Gas
Listening for Events
Next Steps
- Python quickstart (web3.py) — the same first steps in Python
- ERC-20 interaction — full token read/write examples
- ERC-721 interaction — NFT ownership, transfers, and approvals
- Pointer contracts — interact with CosmWasm tokens via ERC interfaces
- WebSocket connections — real-time block and event subscriptions