Transfer events from USDC on Sei Mainnet as they happen. Then it fetches past Transfer events. USDC has many transfers, so new events usually arrive within a minute.
Pick the right endpoint
Use a different public endpoint for each task: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.
Watch new events
Each script prints a line for every USDC transfer. The script runs until you stop it with Ctrl+C.The web3.py example uses the subscription manager, which needs web3.py 7.7 or later.
Fetch past events
eth_getLogs returns the events in a block range. On the public endpoints, one request can cover at most 2,000 blocks. A larger range fails with block range too large. This example fetches the transfers from the latest 1,000 blocks.
eth_getLogs.
Related recipes
- WebSocket connections: new blocks and the
newHeadssubscription - Transaction lifecycle: decode the events from one transaction’s receipt
- Deploy an ERC-20: deploy a token that emits its own
Transferevents