Try it live
This call runs from your browser against Sei Mainnet. It returns the balance in wei, the smallest unit of SEI. One SEI is 1018 wei.Install
await. Save each one as a .mts file, such as script.mts. Run it with npx tsx script.mts on Node.js 18 or later. In a new npm project, tsx compiles a plain .ts file as CommonJS, where top-level await does not work.
Read a native balance
The native balance is the amount of SEI that an address holds.bigint in viem and ethers, and an int in web3.py. The formatEther and from_wei(…, 'ether') helpers divide by 1018. They carry Ethereum names, but they apply to SEI because SEI also uses 18 decimals on the EVM.
EVM RPC methods take
0x addresses. If you have a sei1… address, see Accounts to find the EVM address of the same account. web3.py also requires the checksummed form of an address, which Web3.to_checksum_address produces from a lowercase one.Read an ERC-20 balance
The token contract stores the token balances, so you call itsbalanceOf function. Then you scale the result by the token’s decimals. This example reads USDC on Sei Mainnet at 0xe15fC38F6D8c56aF07bbCBe3BAf5708A2Bf42392, which uses 6 decimals.
0 USDC. ethers prints 0.0 USDC, because formatUnits in ethers always includes a decimal place. To see a real balance, replace address with your own address.
Read many balances at once
Each read above is a separate RPC request. To read dozens of balances in one request, batch them with Multicall3. Multicall3 is deployed at0xcA11bde05977b3631167028862bE2a173976CA11 on Sei Mainnet and Sei Testnet.
Related recipes
- Send SEI: move SEI to another address
- ERC-20 interaction: token metadata, transfers, and approvals
- Multicall: batch many reads into one request