BounceBit Documentation
HomepagePortalBounceClub
  • 🔳Welcome to BounceBit
    • BounceBit's Philosophy
    • Challenges Addressed By BounceBit
    • BounceClub: Build on BounceBit
  • CeDeFi
    • 🏦BounceBit CeFi + DeFi
      • Infrastructure
      • Yield Structure
    • 📊CeDeFi Yield
      • Funding Rate Arbitrage
      • Fixed
      • Auto
      • Manual
      • Integration of Node Staking Rewards
      • Rebasing Mechanism
      • Asset Manager Directory
    • 🌎RWA (Real World Assets)
      • RWA in Yield Generation
      • RWA on BounceBit Chain
    • Subscription & Redemption Rules
      • Auto & Manual
      • Fixed
    • Security Risk Management
    • dApp
      • ⚡Superfast
      • Ethena <> BounceBit
      • Convert
  • Infrastructure
    • ⛓️BounceBit PoS Chain
      • Dual-Token Staking Consensus
      • EVM Compatibility and Developer Support
    • 🔐Shared Security Clients
    • 🌉BTC Bridge
    • 🔮Oracle
      • Price Feed On-chain
      • Price Feed Off-chain
      • Data Feed Addresses
    • 💽Ecosystem Integrations
  • ♣️BounceClub
    • Intro
    • 🫂BounceClub Membership
    • MEME
    • Quanto
    • AI Agents
  • Token
    • 🏦BounceBit Tokenomics
      • Key Terms
      • 🪙BB Coin
      • Liquid Staking Token (stBBTC & stBB)
      • Bitcoin on BounceBit (BBTC)
      • Stablecoins on BounceBit (BBUSD)
    • 🧱Staking Delegation
    • 💧Liquid Staking
    • 📤Liquid Custody
    • 🍞Bread and Butter (BB Cross-chain Liquidity)
  • User Guides
    • General
      • How to Get BTCB from Binance
        • How to Transfer BTCB to your Binance Web3 Wallet
      • How to Use the Testnet Faucet
      • How to Add BounceBit Network to Your Wallet
    • 🌉Bridging
      • Portal Bridge
      • MultiBit Bridge
    • BounceClub V2
      • How to Launch a Memecoin
      • Arcade
      • DeFi
        • Quanto
        • Stablecoin
      • AI Agents
    • 📊CeDeFi
      • How to Withdraw/Redeem Your LCT
      • How to Subscribe to CeDeFi (V2)
      • How to Unsubscribe from CeDeFi (V2)
      • How to Wrap / How to get BBTC, BBUSD
      • Ethena <> BounceBit
      • Superfast Trading Guide
    • 💠Node Staking and Delegation
      • How to Stake/Unstake on Portal
      • How to Stake/Unstake BB and BBTC (Delegation)
  • Assets
    • 🪪Brand Guidelines
      • 🎨Logo Kit
    • ✅BounceBit's TVL
    • ✅Smart Contract Audit Report
    • First BounceBit's BTC TVL Audit Report
  • Developer Resources
    • BounceBit Mainnet Node Setup
      • Cosmovisor
    • Chain Info
    • RPC Support
    • How to Verify Smart Contracts
    • How to Withdraw Validator Commission
  • OTHER
    • 🌐BounceBit Official Social Media Channels
    • Terms of Use
    • Privacy Policy
Powered by GitBook
On this page
  1. Infrastructure
  2. Oracle

Price Feed Off-chain

Use Data Feed Off-chain

Javascript

This example uses ethers.js to retrieve feed data from the ETH / USD feed on the ArbitrumSepolia testnet.

/**
 * THIS IS EXAMPLE CODE THAT USES HARDCODED VALUES FOR CLARITY.
 * THIS IS EXAMPLE CODE THAT USES UN-AUDITED CODE.
 * DO NOT USE THIS CODE IN PRODUCTION.
 */

const { ethers } = require("ethers") // for nodejs only
const provider = new ethers.providers.JsonRpcProvider("https://endpoints.omniatech.io/v1/arbitrum/sepolia/public")
const aggregatorABI = [
  {
    inputs: [],
    name: "decimals",
    outputs: [{ internalType: "uint8", name: "", type: "uint8" }],
    stateMutability: "view",
    type: "function",
  },
  {
    inputs: [],
    name: "description",
    outputs: [{ internalType: "string", name: "", type: "string" }],
    stateMutability: "view",
    type: "function",
  },
  {
    inputs: [{ internalType: "uint80", name: "_roundId", type: "uint80" }],
    name: "getRoundData",
    outputs: [
      { internalType: "uint80", name: "roundId", type: "uint80" },
      { internalType: "int256", name: "answer", type: "int256" },
      { internalType: "uint256", name: "startedAt", type: "uint256" },
      { internalType: "uint256", name: "updatedAt", type: "uint256" },
      { internalType: "uint80", name: "answeredInRound", type: "uint80" },
    ],
    stateMutability: "view",
    type: "function",
  },
  {
    inputs: [],
    name: "latestRoundData",
    outputs: [
      { internalType: "uint80", name: "roundId", type: "uint80" },
      { internalType: "int256", name: "answer", type: "int256" },
      { internalType: "uint256", name: "startedAt", type: "uint256" },
      { internalType: "uint256", name: "updatedAt", type: "uint256" },
      { internalType: "uint80", name: "answeredInRound", type: "uint80" },
    ],
    stateMutability: "view",
    type: "function",
  },
  {
    inputs: [],
    name: "version",
    outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
    stateMutability: "view",
    type: "function",
  },
]
const addr = "0xf136f4Af2F431034C8803C4c892609292D915A46"
const priceFeed = new ethers.Contract(addr, aggregatorABI, provider)
priceFeed.latestRoundData().then((roundData) => {
  // Do something with roundData
  console.log("Latest Round Data", roundData)
})
PreviousPrice Feed On-chainNextData Feed Addresses

Last updated 11 months ago

🔮