- class Oracle
Neo Oracle Service is an out-of-chain data access service built into Neo N3. It allows users to request the external data sources in smart contracts, and Oracle nodes designated by the committee will access the specified data source then pass the result in the callback function to continue executing the smart contract logic.
Check out Neo’s Documentation to learn more about Oracles.
- hash: UInt160
- classmethod request(url: str, request_filter: Optional[str], callback: str, user_data: Any, gas_for_response: int)
Requests an information from outside the blockchain.
This method just requests data from the oracle, it won’t return the result.
>>> Oracle.request('https://dora.coz.io/api/v1/neo3/testnet/asset/0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5', ... '', 'callback_name', None, 10 * 10 ** 8) None
url (str) – External url to retrieve the data
request_filter (str or None) –
Filter to the request.
See JSONPath format https://github.com/atifaziz/JSONPath
callback (str) –
Method name that will be as a callback.
This method must be public and implement the following interface:
(url: str, user_data: Any, code: int, result: bytes) -> None
user_data (Any) – Optional data. It’ll be returned as the same when the callback is called
gas_for_response (int) –
Amount of GAS needed to run the callback method.
It MUST NOT be specified as the user representation.
If it costs 1 gas, this value must be 1_00000000 (with the 8 decimals)
- classmethod get_price() int
Gets the price for an Oracle request.
>>> Oracle.get_price() 50000000
the price for an Oracle request
- class OracleResponseCode(value)
Represents the response code for the oracle request.
Indicates that the request has been successfully completed.
Indicates that the protocol of the request is not supported.
Indicates that the oracle nodes cannot reach a consensus on the result of the request.
Indicates that the requested Uri does not exist.
Indicates that the request was not completed within the specified time.
Indicates that there is no permission to request the resource.
Indicates that the data for the response is too large.
Indicates that the request failed due to insufficient balance.
Indicates that the content-type of the request is not supported.
Indicates that the request failed due to other errors.