What is Chainlink?
Chainlink is the world’s most widely adopted decentralized oracle network. It lets smart contracts securely access off-chain data, APIs, and traditional payment systems. Chainlink Data Streams is a pull-based oracle that delivers high-frequency, low-latency market data directly to smart contracts.What this guide teaches you
This tutorial shows you how to integrate Chainlink Data Streams on Sei to:- Fetch real-time price data with the Chainlink Data Streams SDK
- Deploy a smart contract that can verify and decode price reports on-chain
- Combine off-chain and on-chain components to create a complete oracle solution
- Verify SEI/USDT price feeds as a practical example
Prerequisites
Before you start this tutorial, make sure that you have:Technical requirements
- Node.js (v18 or higher) and npm installed
- Basic knowledge of TypeScript or JavaScript
- Solidity development experience (basic to intermediate)
- Familiarity with tools to deploy smart contracts, such as Remix or Hardhat
Sei network setup
Sei Testnet:- Sei Testnet RPC:
https://evm-rpc-testnet.sei-apis.com - Chain ID: 1328
- Sei Mainnet RPC:
https://evm-rpc.sei-apis.com - Chain ID: 1329
Chainlink Data Streams access
Contact Chainlink to get access to the API credentials for Data Streams.
- API credentials: Contact Chainlink to get access to Data Streams on Sei Mainnet or Sei Testnet
- API Key and User Secret for testnet access
- Feed IDs: This guide uses the SEI/USDT feed ID
0x0003dba2d8553dfd7afe35c2bfe217ef5106d7805e5272c04a08940ddb868117 - VerifierProxy contract address:
0x60fAa7faC949aF392DFc858F5d97E3EEfa07E9EB. Sei Mainnet and Sei Testnet use the same address. For the current list, see Chainlink’s Stream Addresses page.
Step-by-step tutorial
Step 1: Project setup
Create a new directory and initialize your project:.env file in your project root:
Step 2: Fetching price data with TypeScript
Create a file namedsingleStream.ts with this code:
- Creates a Data Streams client with your API credentials
- Fetches the latest report for a given feed ID
- Decodes the raw report into readable price data
- Displays both the raw and the formatted data for debugging
Step 3: Smart contract deployment
Create and deploy the verification contract on Sei. Copy this Solidity code into Remix IDE:- Switch to Sei Testnet in MetaMask
- Deploy the contract with the VerifierProxy address for Sei Testnet:
0x60fAa7faC949aF392DFc858F5d97E3EEfa07E9EB - Save the contract address for testing
Step 4: Complete integration script
CreateverifyOnChain.ts to combine off-chain fetching with on-chain verification:
How to run and test
1. Test off-chain data fetching
Run the single-stream script to test off-chain fetching and decoding:2. Test smart contract deployment
- Copy the raw report blob from the Step 1 output (the long hex string that starts with
0x00090d9e...) - Call
verifyReport()with the entire blob as theunverifiedReportparameter - Call
getLastPrice(). You should see the decoded price (for example,180009506586149300)
3. Test complete integration
Step 3a: Set up the integration script Add your private key to.env:
verifyOnChain.ts, replace YOUR_DEPLOYED_CONTRACT_ADDRESS with the address of your deployed contract.
Step 3b: Run the integration test