AnyOracle is an Oracle protocol built with Cartesi Coprocessor. With AnyOracle, you can ask for any cryptocurrency rate from Coingecko using the economic security from EigenLayer thanks for Cartesi Coprocessor.
With AnyOracle, you just need to query a specific pair (for example: bitcoin to usd, or ethereum to eur), without depending of many smart contracts, just one.
You can use AnyOracle in your dApps with some few steps.
For execution from the dApp, the following attributes must be sent as information in the request:
- "type" (string): For now, just "crypto", and soon, other types, such as commodities, fiat, stocks, and more.
- "currency_name" (string): The name of the currency you want to get the rates, for example, "bitcoin", "ethereum", and "xrpl". In this context, it needs to be the name, not the ticker, according to Coingecko.
- "to_currency" (string): The currency you want to use for the conversion, for example "USD", "EUR", and more.
Example:
{
"type": "crypto",
"currency_name": "bitcoin",
"to_currency": "usd"
}
- Any user or smart contract can query for a pair (according to Coingecko rules, for example, cryptocurrencies do not use the ticker, but the name, like bitcoin instead of btc). For this, the getRate() function is called specifying the base asset and the quote asset.
- The function's response can return a structure, which incorporates, in addition to the assets, the value field (the value of the pair), and the block number in which the value was created/updated.
- If there is no value or it is old (many blocks old), the user/smart contract/dApp can call the runExecution function, which in turn will call the dApp to execute the pair calculation using the Coingecko API.
- If a value is successfully obtained, this value is sent to the contract for storage.
- The user can now query the value again and should get the latest available value.
- Install all the dependencies and apps from Cartesi Coprocessor: https://docs.mugen.builders/cartesi-co-processor-tutorial/installation
- Get a free API Key from Congecko.
- Update the environment in the docker file for the dApp with the API key.
- Deploy the project in devnet, testnet or mainnet using Cartesi Coprocessor CLI
- Smart contract: It contains the base contract to call and receive information from the dApp and Coprocessor.
- dApp: It is the backend with the logic, calling the coingeko API and using Cartesi and Docker.