Oracle 2.0 & Community's Feedback

Greetings Everyone,

Oracle 2.0 is aeternity hackathon project, an oracle service for Aeternity built on top of Aeternity Oracles & to be hosted on Say.network .

Oracle 2.0 or Say.network oracles uses different technologies to provide an additional layer of features on top of default Aeternity Oracles.

For the beginning:

  • Say Network Oracle Services Provides Audit Trail with the response of a query using TLS Notary Pagesigner Oracle system. More on this can be read here https://tlsnotary.org/wp/?p=27

  • Use of encrypted queries is now possible, You can request a response from a URL through an encrypted URL. That means your API key and Secret used to obtain the result will be processed securely on the blockchain and cannot be seen by any middlemen, You can encrypt the URL at Say network Oracles

  • Using Plain queries is also an option if you just want to get a response from one of the trusted node but doing this is also easier than before.

How to use SayAPI (Oracle 2.0)

Say API is a library provided by Say.network to easily integrate Oracle 2.0 in your smart contracts.

Say.aes contains many useful methodsfrom OracleConnector and OracleAddressResolver that allow users to easily Setup Oracle Service Type Call for a query Get the response, Like This:

include "./libs/Say.aes"
contract MyContract =
    record state = {
      query_id : bytes(32),
      answer: option(string)
     }

    stateful entrypoint init() = 
     Say.setOracle("oracle_plain")
     {query_id = #000000000000000000000000000000000000000000000000000000000000000,
      answer = None}

    payable stateful entrypoint query(args: string) : bytes(32) =
      require(Say.getBaseFee() =< Call.value, "Insufficient fee")
      let _id : bytes(32) = Say.query(args, Call.value)
      put(state{query_id=_id})
      _id
    
    stateful entrypoint getAnswer() : option(string) =
      Say.getAnswer(state.query_id)

    stateful entrypoint useAnswer() : option(string) =
      put(state{answer = Say.getAnswer(state.query_id)})
      state.answer
  • query(args: string) : Here in the args You pass the URL that provides a response in JSON format Like This: https://api.pro.coinbase.com/products/ETH-USD/ticker then to get to the depth of the JSON object, You need to specify the property price with a comma, So for
    https://api.pro.coinbase.com/products/ETH-USD/ticker,price You will get 3799.01 (currently as an answer)
  • getAnswer(): Reads for the Unique id stored in your contract state of a currently created query and prpvides answer from OracleConnector Contract (More on this later)

Currently Say API (Say.aes) Provide These Methods:

  • setOracle(oracle_id: string) : bool : It sets the oracle type of a consumer contract so that the query call from that contract can be handled appropriately.
    oracle_plain: Uses this type requires to sent query as plain URL and it provides results without any audit trial.
    oracle_proof: Uses this type provides an audit trail from TLS notary pagesigner oracle with the result after a comma for separation between result and proof in bytes.
    oracle_ukey: Uses this type requires users to encrypt their URL before querying it. It can be encrypted using http://ae.say.network/

  • getOracleAddress() : address : This method can be used to find the address of the oracle contract that registered the oracle .

  • getOracleId() : string : The method is use to find current type of oracle the calling contract is using, One of those oracle_plain, oracle_proof or oracle_ukey

  • canCallBack() : bool: This method is used to perform check-in the contract to make sure that some of the restricted methods can protected with this check which requires only to be called back by the node.

  • getBaseFee() : int : This method provides the current set base fee of the service that is required to perform the query.

  • getAnswer(query_id: bytes(32)) : option(string) : Using unique id in bytes 32 (returned when performed query), Users can be able to call the answer provided on their query.

  • query(args: string, value_received: int) : bytes(32) = This method is used to query the oracle with URL as string and Call.value as 2nd parameter (value_received that to be passed along the query of original Oracle Connector contract)

Workflow

Working of Say Network Oracle system can be visualized like this:

Future plans

Future of Say network oracle packs a lot of potential, This development tool can provide many unique and required features to the developer community.

  • Price Feed & Aggregations: The plans to provide price feeds using at least 10 different exchanges and provide basic aggregation method in say.aes and a method to do this automatically.
  • IPFS integration: To reduce the size of the payload (proof in bytes) ipfs hashes can be provided.
  • DAO: To part your results in the smart contract (Pricefeed, NFT creations, etc.) Let the community decide which urls use to get the results for this.
  • Countdown queries: If you want your results after a specific time, Then this category of oracles will be available in near future.
  • OnChain verfication: Proofs with ledger technology can be provided in the future to verify the results inside the smart contract.
  • Type conversion methods : Say.aes can provide possible explicit type conversions so users can use these methods to easily convert one type of variable to another one.
  • Decentralized Oracle System : Using multiple oracle contracts from community chosen nodes running with authenticated callback addresses to provide a consensus on the query result.

While these are noted & planned features, There are many new features that can be revealed by the community and can be discussed below.

You can learn more about this project at GitHub - VitalJeevanjot/oracle-service: Oracle service &
Oracle 2.0 built on top of Aeternity oracle service - YouTube
While the middleware is constantly developing, The backend of this project is currently offline.

Please let me know below if you have questions or feedback on this product.

5 Likes

Amazing! Could this potentially also enable non-developers to run oracles?

1 Like

Good question @erik.chain ,
Use of Say.aes library makes it easier for any developer/non-developer to make a query on the replaceable oracles that are already on top of Aeternity blockchain.

1 Like