Hello Everyone,
I would like to announce the launch of Oracle 2.0 Oracle Service by Say.network
The oracle service makes it easier to fetch API data in your smart contracts passed in a specific format. Starting with oracle_plain
module, Say network is live on Aeternity Mainnet and ready to take your requests for 0.1 AE for each oracle_plain call.
The backend is running on a specialized pod deployed on Okteto Cloud to send back data with minimal performance loss when processing your requests.
Try your first request : Quick Start - Say Network
Use oracle_plain as your request type and if you are using AE studio, You can use merged contract (With API and Your Contract) like:
include "String.aes"
contract interface OracleConnector =
entrypoint getAnswer : (bytes(32)) => option(string)
payable entrypoint query : (string) => bytes(32)
entrypoint canCallBack: () => bool
entrypoint getBaseFee: () => int
contract interface OraclesManager =
entrypoint getAddress : (string) => address
entrypoint setContractOracle : (string) => bool
entrypoint getContractOracle : (address) => string
entrypoint getListOfOracles : () => list(string)
namespace Say =
record setup = {
oracle_address: OraclesManager,
oracle_connector: OracleConnector
}
// Must run this to select oracle at init
public function setOracle(oracle_id: string) : bool =
let _oracle_address : OraclesManager = ct_utMHaqF7wtV6fHFkGC8MiJ3zQeCwsviUayRTrpHTCAGMat6GU
_oracle_address.setContractOracle(oracle_id)
public function getOracleId() : string =
let _oracle_address : OraclesManager = ct_utMHaqF7wtV6fHFkGC8MiJ3zQeCwsviUayRTrpHTCAGMat6GU
_oracle_address.getContractOracle(Call.caller)
public function set() : setup =
let _oracle_address : OraclesManager = ct_utMHaqF7wtV6fHFkGC8MiJ3zQeCwsviUayRTrpHTCAGMat6GU
let _oracle_connector : OracleConnector = Address.to_contract(_oracle_address.getAddress(getOracleId()))
{oracle_address = _oracle_address, oracle_connector = _oracle_connector}
public function getOracleAddress() : address =
set().oracle_address.getAddress(getOracleId())
public function canCallBack() : bool =
set().oracle_connector.canCallBack()
public function getBaseFee() : int =
set().oracle_connector.getBaseFee()
public function getAnswer(query_id: bytes(32)) : option(string) =
set().oracle_connector.getAnswer(query_id)
stateful function query(args: string, value_received: int) : bytes(32) =
set().oracle_connector.query(args, value = value_received)
public function availableOracles() : list(string) =
set().oracle_address.getListOfOracles()
main contract MyContract =
record state = {
query_id : bytes(32),
answer: option(string)
}
stateful entrypoint init() =
Say.setOracle("oracle_plain")
{query_id = #000000000000000000000000000000000000000000000000000000000000000,
answer = None}
public entrypoint plus() : address =
Say.getOracleAddress()
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
public entrypoint getAnswer() : option(string) =
Say.getAnswer(state.query_id)
stateful entrypoint useAnswer() : option(string) =
put(state{answer = Say.getAnswer(state.query_id)})
state.answer
Keep track of this forum post, I will keep it updated with new module releases on Mainnet.
Let me know your feedback or if you encounter an issue.