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

What You’ll Be Doing in This Guide

In this tutorial, you’ll learn how to:
  1. Integrate API3’s data feeds into your smart contract on the SEI network
  2. Retrieve real-time SEI token price data using 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’ll have a working smart contract that can fetch SEI price data from API3’s decentralized oracle network.

Prerequisites

Before starting this tutorial, ensure you have:

Technical Requirements

  • Solidity Knowledge: Basic understanding of Solidity smart contract development
  • Development Environment: Remix IDE, Hardhat, or similar Solidity development setup
  • SEI Network Access: RPC endpoint and mainnet access for SEI

Required Dependencies

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

Install

SEI Network Configuration

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

Contract Code

Here’s the complete smart contract code for integrating with API3 to read SEI price data:

Contract Breakdown

Key Components:
  1. Proxy Address: The contract stores the API3 proxy address that provides SEI price data
  2. Data Validation: The contract validates that price values are positive and timestamps are recent
  3. IApi3ReaderProxy Interface: This interface provides the read() function to fetch 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
  • Validates data freshness (within 1 day)
  • Ensures price is positive

Proxy Address

For this tutorial, we’ll be using the following API3 proxy address on SEI: 0x09c6e594DE2EB633902f00B87A43b27F80a31a60 This proxy provides 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 called DataFeedReaderExample.sol
  3. Paste the contract code above
  4. Compile the contract using Solidity compiler ^0.8.0
  5. Deploy with constructor parameter: 0x09c6e594DE2EB633902f00B87A43b27F80a31a60
Using Hardhat:

2. Read Price Data

After deployment, call the readDataFeed() function to retrieve the current SEI price:
Expected Output Format:
  • value: SEI price in USD (with 18 decimals, e.g., 300000000000000000 = $0.3)
  • timestamp: Unix timestamp of the last price update

3. Integration Examples

Basic Price Display: