Skip to main content

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

Reading Chain Data

This is the first milestone — it needs no private key.
You’re done when you see:
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()).

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 v6 JsonRpcProvider reading Sei testnet (atlantic-2), so its block number and balances won’t match the mainnet reads above:

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