- Solidity does not allow you to pull data from an external API source. Use an Oracle service to achieve this functionality.
- An oracle is an event listener that listens and responds to them by sending the results of a query back to the contract. In this way, contracts can interact with the external world.
- As an example, assume that we have a smart contract that uses an external data service to select a random number. Let's see how we can implement it using a custom Oracle service.
- Create a basic smart contract with a state variable to store the random number:
pragma solidity ^0.4.24;contract OracleRng { uint public random; ...}
- The Oracle service listens to the event logged in the contract and then uses the log details to ...