Skip to main content
The native Oracle precompile is retired, so price data on Sei comes from third-party oracles. This recipe reads API3’s SEI/USD feed. API3 pushes new prices on-chain, so a contract already stores the latest price. You read it with a free view call. You do not need a key, an API token, or SEI.
Read the feed on Sei Mainnet, because a data feed on a testnet can be stale. Always check the timestamp, as the examples below do.

Try it live

This call runs the proxy’s read() function (selector 0x57de26a4) from your browser. The response holds two 32-byte values. The first is the price with 18 decimals. The second is the Unix time of the last update.

Install

The TypeScript examples use top-level 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 the price

You are done when you see:
The price is illustrative. API3 updates a feed when the price moves past the feed’s deviation threshold. When the price is flat, API3 updates the feed at least once every 24 hours. The examples therefore reject a value that is not positive or that is more than 24 hours old. See API3’s update parameters for details.

Use the price in a contract

A contract reads the same proxy through API3’s IApi3ReaderProxy interface and should apply the same checks. The API3 guide has a complete consumer contract.

Other oracles on Sei

Chainlink Data Streams, Pyth, and RedStone are pull oracles. Your transaction carries a signed, current price with it. A view call on its own returns either nothing or the last price that someone else submitted, which can be old. To use one of them, follow its guide.