Getting Started

Introduction

APRO Data Pull is a Oracle Product based on the pull-model. The Pull model, where price data is fetched from APRO's decentralized network only when required, providing cost-effective, on-demand access to updates. This model reduces the need for continuous on-chain interactions, ensuring accuracy and minimizing costs.

You can use APRO Data Pull to connect your smart contracts to real-time asset pricing data. These data feeds aggregate information from many independent APRO node operators, allowing contracts to fetch data on-demand when needed.

How to Use Real-Time Data

Anyone can submit a report verification to the on-chain APRO contract, the report includes the price, timestamp, signatures. The price data contained in the report will be stored in the contract for future use when the report is verified successfully.

This guide explains how to use real-time APRO data in EVM contracts.

  1. Acquire report data (include price, timestamp, signatures) from our Live-Api service

Consensused price data is published via Live-Api Service. Please see the REST API & WebSocket Integration Guide for detailed instructions on fetching and decoding reports.

  1. Using the report data in the contract

Report data can be used in the following scenarios.

Scenario 1: Get the latest price of a price feed from the Live-Api server, verify and update the price in the on-chain contract, and then use the latest price in subsequent business logic. The price update logic and business logic can be processed in the same transaction.

Suitable for on-chain applications that always use the latest price data. Please refer to the function verifyAndReadLatestPrice.

Scenario 2: Get a specific timestamp price of a price feed from the Live-Api server, verify the price in the on-chain contract, and use this price in subsequent business logic.

Suitable for on-chain applications that need a specific timestamp price data. Please refer to the function verifyAndReadThePrice.

WARN: The validity period of report data is 24 hours, so some not-so-new report data can also be verified successfully. Please ensure that you do not mistake this price for the latest price.

Scenario 3: Get the latest price of a feed from the Live-Api server, verify the price in the on-chain contract.

This usage is similar to using the traditional push-model based oracle product. The price update logic and business logic are separated. Please refer to the function verifyReportWithWrapNativeToken or verifyReportWithNativeToken.

Scenario 4: Read only the latest price of a feed that has been verified in the on-chain contract.

The price read in this way may be not timely if no other users actively submit report verifications. Please refer to the function readPrice.

Here are some codes for your reference.

You can test the contract code by following these steps:

  1. Compile and deploy the DemoContract with the VerifierProxy contract address.

  2. Deposit some wrapped native token to the DemoContract.

  3. Use the full report obtained in the API& WebSocket Guide guide as the payload params and trigger the appropriate functions.