RedStone 백서

RedStone

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 3쪽 중 2쪽

nst wrappedContract = WrapperBuilder . wrap ( contract ) . usingDataService ( { dataPackagesIds : [ "ETH" , "BTC" ] , authorizedSigners : getSignersForDataServiceId ( DATA_SERVICE_ID ) , authenticatedGateways : [ { url : "<your-proxy-url>" , apiKey : "" } ] , } ) ; Now you can access any of the contract's methods in exactly the same way as interacting with the ethers-js code: wrappedContract . executeYourMethod ( ) ; Authenticated gateways ​ Fetching data packages (both for contract wrapping and for the manual payload flow) requires an authenticatedGateways parameter: a list of gateways to query, each with its own API key. authenticatedGateways : { url : string ; apiKey : string ; } [ ] ; apiKey - sent as an x-api-key header on every request to that gateway. url - the gateway address to call. For backend/script/bot code, use the authenticated gateway URL RedStone gives you (see below). Frontend code must instead point it at your own proxy. Rate limit on RedStone's own gateway: 1 request/second per API key . For better availability, use both (gateway, API key) pairs RedStone gives you - the second one serves as a fallback. Don't call RedStone's gateway directly from a dApp's frontend A frontend runs in every visitor's browser, so any API key embedded in it is exposed - readable straight from the page source, the JS bundle, or a network inspector. Anyone can extract it and hammer RedStone's gateway with it directly, exhausting your 1 request/second limit and getting the key rate-limited or blocked for every legitimate user of your dApp. Instead, run a small proxy/cache backend that you control: it holds your real API key, fetches from RedStone's gateway, and caches the response for a few seconds so you stay within the rate limit regardless of traffic. Point your frontend's authenticatedGateways at your proxy's URL with apiKey: "" . Backend code that never reaches end users (a relayer, a bot, a script) can skip the proxy and pass the real API key directly, as in the example above. Proxy setup ​ Put a proxy in front of RedStone's gateway that caches responses and attaches your API key on the way through, so callers never see it. A CDN like AWS CloudFront can do this directly - just add your API key as a custom origin request header and enable caching, no custom backend needed. To get an API key and gateway url , fill out this form . Testing ​ Hardhat ​ If you'd like to use the wrapper in a test context, we recommend using a mock wrapper so that you can easily override the oracle values to test different scenarios. To use the mock wrapper just use the usingMockData(signedDataPackages) function instead of the usingDataService function. const { SimpleNumericMockWrapper , } = require ( "@redstone-finance/evm-connector/dist/src/wrappers/SimpleMockNumericWrapper" ) ; const wrappedContract = WrapperBuilder . wrap ( yourContract , ) . usingSimpleNumericMock ( { mockSignersCount : 10 , dataPoints : [ { dataFeedId : "ETH" , value : 1000 } ] , } ) ; await wrappedContract . yourMethod ( ) ; You can see more examples of mocking data here. Foundry ​ To use RedStone with Foundry in test context, we recommend using foundry vm.ffi function to generate mocked dataPackages. We have prepared repository showing how we can integrate foundry with redstone. consuming redstone payload in foundry contract generating mock redstone payload Manual payload ​ This approach is helpful if you need to pass the pricing data from one contract to another in your protocol. It's also a solution for a case, where your contracts are written in solidity in a version lower than 0.8.4 it could be problematic to extend from the RedstoneConsumerBase contract. In that case, we recommend to deploy a separate Extractor contract that will contain the verification logic: pragma solidity 0.8 .4 ; import "@redstone-finance/evm-connector/contracts/mocks/RedstoneConsumerNumericMock.sol" ; contract RedstoneExtractor is RedstoneConsumerNumericMock { function extractPrice ( bytes32 feedId , bytes calldata redstonePayload ) public view returns ( uint256 ) { return getOracleNumericValueFromTxMsg ( feedId ) ; } } and proxy the payload from your originating contract function getPriceFromRedstoneOracle ( bytes32 feedId , bytes calldata redstonePayload ) public view returns ( uint256 ) { return redstoneExtractor . extractPrice ( feedId , redstonePayload ) ; } The manual payload could be obtained using the following code. authenticatedGateways is required here too - see Authenticated gateways . const redstonePayload = await new DataServiceWrapper ( { dataServiceId : "redstone-primary-demo" , dataFeeds : [ "ETH" ] , authenticatedGateways : [ { url : "<your-proxy-url>" , apiKey : "" } ] , } ) . getRedstonePayloadForManualUsage ( yourContract ) ; // Interact with the contract (getting oracle value securely) const price = await yourContract . getPriceFromRedstoneOracle ( redstonePayload ) ; Working demo ​ You can see examples of the @redstone-finance/evm-connector usage in our dedicated repo with examples . RedStone SDK ​ Even though the most popular way of using RedStone data is to pass it on-chain one may want to consume it off-chain. For this scenario we created @redstone-finance/sdk . SDK functions such as requestDataPackages also require the authenticatedGateways parameter - see Authenticated gateways . ## /docs/stage1-market-data/bolt On this page RedStone Bolt is a real-time push oracle purpose-built for blockchains where block times are measured in milliseconds. Traditional price data architectures were designed when Ethereum blocks took 12 seconds to produce and prices got updated every few minutes. That design works on legacy chains but breaks on real-time ones. When a chain produces blocks faster than an oracle can deliver data, the oracle becomes the bottleneck. Liquidations trigger late, high-frequency strategies break, protocols cannot safely tighten risk parameters, and real-time applications become impossible to build safely. Bolt solves this at the architecture level. How RedStone Bolt Works ​ Bolt is built on two core design choices, with an optional third for integrations that demand the absolute minimum latency: 1. Direct CEX streaming ​ Instead of polling price aggregators, Bolt nodes monitor trade activity directly on major venues (Binance, Coinbase, OKX, Bitget, Kraken) and stream the results in real time. This eliminates the batching overhead that gives most oracles their latency floor. 2. Push model: no contract changes required ​ This is the critical differentiator. Every other high-speed oracle uses a pull model, which is incompatible with most existing DeFi smart contracts and requires audits and code rewrites to integrate. Bolt uses a push model, the same interface as any standard push feed. Protocols built on Aave, Compound, Morpho, Spark, Venus, Euler, Fluid, or any standard push interface integrate with zero code changes . Optional: Co-location with the sequencer ​ For integrations where every microsecond counts, RedStone can co-locate Bolt nodes in the same physical location as the chain's sequencer. Transmission delay drops to zero, the price data is already present when the block executes. This requires additional configuration work on RedStone's side and is evaluated on a case-by-case basis. RedStone has deployed this for selected chains in the past. Performance ​ Metric Bolt Standard Push Oracle Update interval <10ms 10 seconds – 24 hours Updates per second 400+ < 1 Model Push Push Contract compatibility Existing push contracts Existing push contracts Oracle colocation Yes, with sequencer (optional) No To put the speed difference in context: standard Ethereum push feeds deliver ETH/USD approximately 40–60 times in a 24-hour window. Bolt delivers over 400 updates per second, roughly 576,000× faster. Advanced: Custom Feed Types ​ Bolt's millisecond update cadence enables data primitives that are not possible with standard oracle architectures. For protocols that require it, RedStone can produce dedicated feeds alongside the standard price feed, including deterministic OHLC (Open/High/Low/Close) data constructed at the oracle layer as opposed to being reconstructed post-factum from snapshots. These feeds are cryptographically signed, encoded as standardized payloads, and streamed in real time, with all outputs persisted for historical access. This is particularly relevant for real-time trading applications where stale high/low values would create mispricing or execution risk. Custom feed types are available on request. Integration ​ Bolt uses the same interface as any RedStone Push feed. If Bolt is deployed on your chosen chain and your protocol already integrates a push oracle, no changes are required. → See the Push Model docs for the integration reference. Supported Chains ​ Bolt is currently live on MegaETH and Monad. RedStone is highly selective about chain eligibility for a Bolt integration. Operating an oracle at sub-10ms cadence leaves very little margin for error. If a chain experiences downtime, faulty RPCs, or has other reliability issues, the consequences for protocols depending on real-time price data are severe. A stale feed at this speed is a significant risk event. Before committing to a Bolt deployment, RedStone conducts deep technical due diligence on the chain, reviewing its infrastructure stability, sequencer architecture, historical uptime, and failure mode behavior. Many chains that request Bolt integrations do not meet the bar. This is by design. If you represent a chain and want to discuss its eligibility, contact RedStone . Get Access ​ Bolt is chain-facing infrastructure. RedStone works directly with chains and protocols to deploy and configure Bolt feeds for specific use cases. To discuss a Bolt integration, contact RedStone . ## /docs/stage1-market-data/live/overview On this page RedStone Live is an off-chain market data streaming service that delivers cryptographically verifiable price data via WebSocket. It is designed for protocols and applications that need real-time data before it touches a blockchain such as perpetual exchanges, centralized exchanges, options protocols, market makers, prediction markets, synthetic asset platforms, off-chain risk engines, and institutional trading systems. Unlike on-chain price feeds (push or pull), Live delivers data to your backend directly. Your system consumes it in real time and decides when and how to use it whether that's powering mark prices and funding rates or triggering liquidation logic. Who It's For ​ Perpetual exchanges are the primary use case. Perps require continuous pricing across asset classes that include equities, commodities, FX, and indices alongside crypto — assets synchronized with trading calendars, contract expiries, corporate actions, and complex sourcing requirements. Live is built to handle all of that. Both for DEXes and CEXes. Options protocols — RedStone Live provides institutional-grade options data on major US equities and commodities. Options data covers the pricing, volume, and open interest of derivative contracts. Live is uniquely positioned to power options protocols expanding into RWAs. Other use cases include synthetic spot token platforms that need 24/7 pricing for minting and redemption, off-chain risk management and liquidation engines, real-time analytics pipelines, and institutional portfolio and monitoring dashboards. Any use case requiring instant access to a broad spectrum of pricing data across jurisdictions and asset classes (for example, for the sake of spinning up new markets quickly) can benefit from RedStone Live integration. Asset Coverage ​ Live covers a broad range of asset classes. Coverage spans the classes below; specific tickers and licensing are confirmed during integration scoping, and new assets are added on request. Equities — US (large-cap and mid-cap) and non-US stocks (Japan, Taiwan, Europe, Hong Kong, Korea and others) Commodities — hard, soft, and metals Hard: oil, natural gas, uranium Soft: corn, soy, wheat, cattle Metals: gold, silver, copper, platinum, mining indices FX — major pairs and emerging market currencies (KRW, JPY, EUR, and more) Indices — the most popular global equity indices, with support for custom methodologies Crypto — top 20 assets by market cap Custom baskets — weighted composites of any combination of the above Browse the full list of tickers in the Assets Explorer . What Makes Live Different ​ Sourced from where your market makers hedge ​ Basis risk on a perp DEX is usually an oracle problem. If your market makers hedge on a specific venue and your oracle sources from a different one, the spread between those prices shows up as funding volatility, arbitrage exposure, or unexplained P&L noise. Live lets you configure feeds to source from the venue your market makers actually use, whether that's a TradFi futures exchange, a broker, an ATS, or a crypto venue. The data tracks where your market actually lives. Custom rollover methodology, built into the feed ​ For any asset with contract expiries (futures on commodities, equities, rates), rollovers are where naive oracles create the most damage. A rollover at the wrong time or using the wrong contract month generates temporary price dislocations that can trigger phantom liquidations or open arbitrage windows. RedStone builds the rollover methodology directly into the feed configuration. Options include front-month, second-month, volume-weighted, and open-interest-weighted rollovers. You define what makes sense for your protocol and market structure; we implement and maintain it. Your protocol never has to absorb rollover risk because an oracle treated a futures market like a spot market. 24/7 continuous coverage ​ TradFi markets close. Most oracle systems either freeze, degrade, or require manual intervention when they do. Live continues pricing from the most liquid available venue using a pre-configured off-hours methodology. No gaps, no scripts, no operational decisions left to your team. End-to-end integration ​ Other providers hand off a data stream and stop there. RedStone operates the full pipeline: relayer operation, data source sanitization, methodology configuration, uptime monitoring, and custom signing schemes. If something goes wrong upstream, we handle it. Your team builds the product; we handle the oracle infrastructure. Perpetuals: Specialized Integration ​ Perps have requirements that are meaningfully different from other oracle integrations, and RedStone treats them accordingly. Beyond data delivery, a production-ready perps oracle needs: Continuous 24/7 pricing — including synthetic prices during closed or thin-liquidity periods so the market stays functional at all hours Corruption-resistant aggregation — multi-source with filtering that rejects bad ticks, stale data, and manipulation attempts before they reach your mark price Smoothed mark price evolution — spot prices can move abruptly; a perps engine cannot. RedStone applies smoothing, clamps, and transition logic so sudden regime changes don't cascade into unnecessary liquidations Event-aware handling — stock splits, reverse splits, mergers, and tender offers all change the economic meaning of a price. RedStone detects and adjusts for these so your market continues functioning normally Redundant infrastructure — multiple relayers, redundant transmission paths, and robust key management so the oracle layer doesn't become the single point of failure for your protocol RedStone approaches perps integration as ongoing engineering collaboration, instead of a one-time product delivery. The oracle and the protocol are co-developed, tested, and maintained together. Get Access ​ Live is available via API key. To discuss an integration, including asset coverage, rollover methodology, sourcing configuration, and latency requirements, contact RedStone . → For technical integration details, see Integration . ## /docs/stage1-market-data/live/api-reference On this page Best suited for dApps that require low-latency data. Connecting WebSocket API ​ Open a WebSocket connection and include your API key in the HTTP upgrade request header: x-api-key: < your-api-key > Response Meaning HTTP 101 Connection accepted HTTP 401 or 403 Missing or invalid API key HTTP 429 Rate or connection limit reached (see Limits ) - back off and retry with jitter. Subscribing to feeds ​ After the connection is open, send a JSON text frame to subscribe or unsubscribe. Multiple items can be batched in a single message. { "op" : "subscribe" , "items" : [ { "feedId" : "XAU" , "type" : "price" , "dataServiceId" : "redstone-primary-prod" } ] } { "op" : "unsubscribe" , "items" : [ { "feedId" : "XAU" , "type" : "price" , "dataServiceId" : "redstone-primary-prod" } ] } { "op" : "subscribe" , "items" : [ { "feedId" : "XAU" , "type" : "redstonePackages" , "dataServiceId" : "redstone-primary-prod" } ] } { "op" : "subscribe" , "items" : [ { "feedId" : "XAU" , "type" : "passthrough" , "dataServiceId" : "redstone-primary-prod" } ] } Field Type Description feedId string Feed identifier, e.g. "XAU" , "BTC" type "price" | "redstonePackages" | "passthrough" Subscription channel (see below) dataServiceId string Data service identifier optional default is "redstone-primary-prod" Note: subscribe and unsubscribe must use the exact same type , dataServiceId , and feedId to address the correct channel. Unsubscribing from price does not affect an active redstonePackages subscription for the same feed. Message types ​ Note: The schemas below describe the minimum guaranteed fields. Additional fields may be present and should be ignored if not needed. price ​ Delivers one lightweight aggregated tick, the median from the quorum of signers. { "type": "price", "dataServiceId": "redstone-primary-prod", "dataPackageId": "ETH", "timestamp": 1712345678000, "value": 2543.12, } Field Type Description type "price" Discriminant field dataServiceId string Data service identifier dataPackageId string Feed identifier timestamp number Millisecond timestamp of the data round value number Median price across all merged signer payloads redstonePackages ​ Delivers the raw signed oracle packages from quorum of signers. Payloads in a single batch are guaranteed to contain packages from 3 unique Redstone nodes with the same timestamp. Whitelisted signer addresses: initial-state.json You can use this function SignedDataPackage.fromObj() from package to recover signer address. Most feeds have exactly 1 element in dataPoints . Only feeds prefixed with __ can contain multiple data points. Recommended algorithm for safe consumption: Filter out packages with non-whitelisted signers or invalid signatures. Check that the minimum signer count threshold is met. Calculate the median across the verified packages. { "type": "redstonePackages", "payloads": [ { "dataPackageId": "ETH", "timestampMilliseconds": 1712345678000, "dataPoints": [ { "dataFeedId": "ETH", "value": 2543.12, "decimals": 8, // optional }, ], "signature": "<base64>", }, // ... one entry per signer ], } Message fields: Field Type Required Description type "redstonePackages" Yes Discriminant field payloads SignedDataPackagePlainObj[] Yes One signed package per merged signer (minimum 1) SignedDataPackagePlainObj fields : Field Type Required Description dataPackageId string Yes Feed identifier timestampMilliseconds number Yes Millisecond timestamp of the data round dataPoints DataPoint[] Yes Data values from this signer (minimum 1) signature string Yes Base64-encoded signer signature DataPoint fields (each element of data
프로젝트로 돌아가기