Skip to main content
API3 is a decentralized oracle network that supplies real-time data feeds to smart contracts. Traditional oracles rely on third-party intermediaries. API3 instead connects APIs directly to the blockchain through first-party oracles that the API providers operate themselves. This approach reduces trust assumptions and potential points of failure.

What you’ll be doing in this guide

This tutorial shows you how to:
  1. Integrate API3’s data feeds into your smart contract on Sei
  2. Get real-time price data for the SEI token from API3’s proxy contract
  3. Understand the structure of API3’s reader proxy interface
  4. Deploy and test your integration on Sei
By the end of this guide, you will have a working smart contract that can fetch SEI price data from API3’s decentralized oracle network.

Prerequisites

Before you start this tutorial, make sure that you have:

Technical requirements

  • Solidity knowledge: A basic understanding of smart contract development in Solidity
  • Development environment: Remix IDE, Hardhat, or a similar Solidity development setup
  • Sei network access: An RPC endpoint and access to Sei Mainnet

Required dependencies

  • OpenZeppelin Contracts library (@openzeppelin/contracts)
  • API3 Contracts library (@api3/contracts)

Install

Sei network configuration

Make sure that your development environment is configured for Sei:
  • Mainnet RPC: https://evm-rpc.sei-apis.com
  • Chain ID: 1329 (Sei Mainnet)

Contract code

This complete smart contract reads SEI price data from API3:

Contract breakdown

Main components:
  1. Proxy address: The contract stores the address of the API3 proxy that supplies SEI price data
  2. Data validation: The contract validates that price values are positive and that timestamps are recent
  3. IApi3ReaderProxy interface: This interface has the read() function, which fetches price data
The readDataFeed() function:
  • Returns int224 value: The SEI price (likely in USD with 18 decimal places)
  • Returns uint256 timestamp: When the price was last updated
  • Checks that the data is fresh (within 1 day)
  • Checks that the price is positive

Proxy address

This tutorial uses the API3 proxy at this address on Sei: 0x09c6e594DE2EB633902f00B87A43b27F80a31a60 This proxy supplies real-time SEI/USD price data from API3’s decentralized oracle network.

How to test

1. Deploy the contract

Using Remix IDE:
  1. Open Remix IDE
  2. Create a new file named DataFeedReaderExample.sol
  3. Paste the contract code from above
  4. Compile the contract with the Solidity compiler (version ^0.8.0)
  5. Deploy with this constructor parameter: 0x09c6e594DE2EB633902f00B87A43b27F80a31a60
Using Hardhat:

2. Read price data

After you deploy the contract, call the readDataFeed() function to get the current SEI price:
Expected output format:
  • value: The SEI price in USD (with 18 decimals, for example 300000000000000000 = $0.3)
  • timestamp: Unix timestamp of the last price update

3. Integration examples

Basic price display: