What is Chainlink?
Chainlink is the world’s most widely adopted decentralized oracle network, enabling smart contracts to securely access off-chain data, APIs, and traditional payment systems. Chainlink Data Streams is a pull-based oracle solution that delivers high-frequency, low-latency market data directly to smart contracts.What This Guide Teaches You
This tutorial will walk you through integrating Chainlink Data Streams on Sei Network to:- Fetch real-time price data using 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 starting this tutorial, ensure you have:Technical Requirements
- Node.js (v18 or higher) and npm installed
- Basic knowledge of TypeScript/JavaScript
- Solidity development experience (basic to intermediate)
- Familiarity with smart contract deployment tools like Remix or Hardhat
Sei Network Setup
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
You need to contact Chainlink for getting access to API credentials of Data Streams.
- API credentials: Contact Chainlink to get access to Data Streams on Sei Mainnet/testnet
- API Key and User Secret for testnet access
- Feed IDs: We’ll use SEI/USDT feed ID
0x0003dba2d8553dfd7afe35c2bfe217ef5106d7805e5272c04a08940ddb868117 - VerifierProxy contract address:
0x60fAa7faC949aF392DFc858F5d97E3EEfa07E9EB— the same address is used on Sei mainnet and Sei testnet. See Chainlink’s Stream Addresses page for the current list.
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 calledsingleStream.ts with the following 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 raw and formatted data for debugging
Step 3: Smart Contract Deployment
Create and deploy the verification contract on Sei Network. Copy this Solidity code into Remix IDE:- Switch to Sei Testnet in MetaMask
- Deploy with Sei testnet VerifierProxy address:
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 verify off-chain fetching and decoding:2. Test Smart Contract Deployment
- Copy the raw report blob from Step 1 output (the long hex string starting with
0x00090d9e...) - Call
verifyReport()and paste the entire blob as theunverifiedReportparameter - Call
getLastPrice()- you should see the decoded price (e.g.,180009506586149300)
3. Test Complete Integration
Step 3a: Setup Integration Script Add your private key to.env:
verifyOnChain.ts with your deployed contract address:
Replace YOUR_DEPLOYED_CONTRACT_ADDRESS in the script with your actual contract address.
Step 3b: Run Integration Test