💻Sybil: data feeds

We understand that getting started with a new platform can seem daunting. Let's break it down step-by-step, using practical code examples to illustrate how you can integrate Orally into your project.

Fetching Price Feeds with Sybil

First, you'll need to fetch real-time price feeds using Sybil's HTTP gateway from your front-end. Here's a sample TypeScript fetch call to retrieve the ICP/USD price pair data:

const fetchData = async () => {
  const response = await fetch("https://wth3l-tiaaa-aaaap-aa5uq-cai.icp0.io/get_asset_data_with_proof?pair_id=ICP/USD");
  const data = await response.json();
  console.log(data);
}

fetchData();

This will return a response like this:

{
    "symbol": "ICP/USD",
    "rate": 4902941764,
    "timestamp": 1685442778,
    "decimals": 9,
    "signature": "5d4368547f194ff784d904cc9052108894044bba7588d2447bd13f070128ef6d690e12094b5e3c6c304187587cd6ff8b4d35dfc3ea4b7165f79d2e881b446dd31c"
}

Developers can then take this data and attach it to a transaction going to their dApp's smart contract.

Attaching Price Feed Data to Transaction

Here's an example of how you can attach the response data to a transaction:

const Web3 = require('web3');
const web3 = new Web3("YOUR_RPC_URL");

const myContract = new web3.eth.Contract(abi, contractAddress);

const transaction = myContract.methods.executeTransaction(
    data.symbol,
    data.rate,
    data.decimals,
    data.timestamp,
    data.signature
);

// Sign and send the transaction...

Verifying Price Feeds with the Orally Verifier Contract

Once you've fetched the price feed data and attached it to a transaction, the next step is to verify the data using the Orally Verifier Contract.

You should first import the IOrallyVerifierOracle interface into your Solidity smart contract.

Then, in your contract method, call the verifyUnpacked function from the Orally Verifier contract to verify the data:

import "path-to/IOrallyVerifierOracle.sol";

contract MyContract {
    IOrallyVerifierOracle public orallyVerifier;

    constructor(address _orallyVerifierAddress) {
        orallyVerifier = IOrallyVerifierOracle(_orallyVerifierAddress);
    }

    function executeTransaction(
        string memory _pairId,
        uint256 _price,
        uint256 _decimals,
        uint256 _timestamp,
        bytes memory _signature
    ) public {
        require(
            orallyVerifier.verifyUnpacked(_pairId, _price, _decimals, _timestamp, _signature),
            "Data verification failed"
        );

        // Execute your business logic here...
    }
}

Here is a list of the Orally Verifier contract addresses on different chains:

ChainContract Address

Ethereum

0x7b348835A12aaE1fDA26E2Ce8CB9746fcf865b18

Linea

0x45f61bAD7e29a6FB9ec307daD7B895e63Db1940B

Aurora

0x45f61bAD7e29a6FB9ec307daD7B895e63Db1940B

Arbitrum

0x096eb773BE73CEDed425029Dc43EC0890DB72507

zkSync

0xeC853A8dab05306e61E58fcc155bB98207eD078B

Manta Pacific Network

0x7b348835A12aaE1fDA26E2Ce8CB9746fcf865b18

Congratulations! You have now successfully fetched and verified a price feed using Orally's Sybil. From here, you can extend the functionality of your smart contract by adding additional logic after the data verification step.

Creating a Custom Pair

Orally's Sybil not only provides existing price feeds but also allows you to create your custom price feed pair. The process is straightforward and user-friendly:

  1. Navigate to the Front-End App: Visit the Orally front-end app at Sybil dApp.

  2. Initiate the Custom Pair Creation Flow: On the main page, locate and click the button to initiate the custom pair creation flow. This will open a modal where you will input details about your custom pair.

  3. Input Pair Details: In the modal, provide the necessary details for your custom pair. These will include the symbol name, the frequency of updates, and the endpoints from which to fetch the price feed for your token. Ensure that these details are accurate, as they will directly influence the behavior and accuracy of your custom pair's price feed.

  4. Authenticate with SIWE: After inputting the necessary details, authenticate yourself using SIWE (Signing with Ethereum). This is a necessary step for security and accountability reasons.

  5. Top Up Balance: After authentication, top up the balance with the specified token. This balance is necessary to cover the execution costs associated with your custom pair's price feed.

  6. Run Your Custom Pair: With all the previous steps complete, you can now run your custom pair. Congratulations, you now have your own token price feed!

By following these steps, you can create a custom price feed pair for any token of your choice. The power of Orally's Sybil truly shines in its versatility and adaptability, making it a highly valuable tool for all developers in the blockchain space.

Last updated