Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Razor Network #21

Closed
Tracked by #13
manuelbarbas opened this issue Nov 15, 2023 · 0 comments
Closed
Tracked by #13

Razor Network #21

manuelbarbas opened this issue Nov 15, 2023 · 0 comments
Labels
documentation Improvements or additions to documentation

Comments

@manuelbarbas
Copy link
Collaborator

manuelbarbas commented Nov 15, 2023

Razor Network

Razor Network is a decentralized oracle network offering price-feed data to applications. This can be utilized in various actions throughout DeFi and other more general Web3 use cases. Razor is available on the Calypso, Nebula, Titan Mainnet, and Testnets.

Implementation Example

To consume the Razor Network price feeds, your contract should reference ITransparentForwarder. This is an interface that defines the external functions implemented by Data Feeds

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface ITransparentForwarder {
    /**
     * @dev using the hash of collection name, clients can query the result of that collection
     * @param _name bytes32 hash of the collection name
     * @return result of the collection and its power
     */
    function getResult(bytes32 _name) external payable returns (uint256, int8);
}

contract DataFeed {
    ITransparentForwarder public transparentForwarder;
    uint256 public latestResult;
    int8 public latestPower;

    constructor() {
        transparentForwarder = ITransparentForwarder(
            /* Transparent Forwarder contract address deployed on respective chains */
        );
    }

    /// @notice fetch collection result by name
    /// @param name bytes32 hash of the collection name
    /// @return result of the collection and its power
    /// @return power
    function getResult(bytes32 name) public payable returns (uint256, int8) {
        (uint256 result, int8 power) = transparentForwarder.getResult{
            value: msg.value
        }(name);
        latestResult = result;
        latestPower = power;
        return (result, power);
    }
}

For more information go to the Razor data feed documentation.

@manuelbarbas manuelbarbas added the documentation Improvements or additions to documentation label Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant