Supra
Overview
Integration Process
1. Smart Contract Setup
// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;
import "@openzeppelin/contracts/access/Ownable.sol";
interface ISupraOraclePull {
struct PriceData {
uint256[] pairs; // List of pairs
uint256[] prices; // prices[i] is the price of pairs[i]
uint256[] decimals; // decimals[i] is the decimals of pairs[i]
}
function verifyOracleProof(bytes calldata _bytesproof)
external
returns (PriceData memory);
}
contract SupraPriceConsumer is Ownable {
ISupraOraclePull internal oracle;
// Store latest prices
mapping(uint256 => uint256) public latestPrices;
constructor(address oracle_) Ownable(msg.sender) {
oracle = ISupraOraclePull(oracle_);
}
function deliverPriceData(bytes calldata _bytesProof)
external
onlyOwner
{
ISupraOraclePull.PriceData memory prices =
oracle.verifyOracleProof(_bytesProof);
// Store the latest prices
for (uint256 i = 0; i < prices.pairs.length; i++) {
latestPrices[prices.pairs[i]] = prices.prices[i];
}
}
function updateOracleAddress(address oracle_)
external
onlyOwner
{
oracle = ISupraOraclePull(oracle_);
}
}2. Web2 Integration
3. Contract Deployment
Best Practices
Technical Specifications
Support & Resources
Last updated
Was this helpful?