Skip to main content
Sei is fully EVM-compatible, so any standard Ethereum client works with it, including Python’s web3.py. In this guide, you connect to Sei from a Python script and read chain data without credentials. Then you sign and broadcast a transaction.

Install

Use an isolated virtual environment:

Reading chain data

This is the first milestone. It does not need a private key.
You are done when you see:
The exact values are illustrative. Your block number will differ, and so will the balance and nonce of the queried address. The EVM chain ID is always 1329 on Sei Mainnet and 1328 on Sei Testnet.

Try it live

web3.py sends plain JSON-RPC requests internally. These snippets send the same reads to Sei Mainnet, so you do not need Python to run them.

Sending a transaction

This next step requires a funded account. Get testnet SEI from the faucet. Then build the transaction, sign it locally, and broadcast it with eth_sendRawTransaction. Public RPC endpoints do not manage accounts, so you sign the transaction yourself instead of relying on node-managed accounts.
Never hard-code or commit a private key. Load it from an environment variable or a secrets manager. Use a dedicated throwaway key that holds only the funds you need.
In web3.py v7+, the attribute name is signed.raw_transaction. In web3.py v6, it is signed.rawTransaction.

Reading a contract

Next steps