I am approaching blockchain and smart contracts for the first time and I have trouble understanding some concepts. I read this article https://medium.com/decentlabs/building-your-first-ethereum-oracle-1ab4cccf0b31 and I have a question about Logging server.

  • My smart contract needs data outside the blockchain, so my contract sends a request to an oracle smart contract.
  • The oracle contract emit an event to catch the attention of the oracle service provider.
  • The oracle's backend retrieves that information from external sources and sends a transaction to the oracle contract with the requested information.

After reading the article I guessed that the oracle contract logs events to a logging events server. Does my smart contract need to get the information from this server? If so, how? How does the interaction between the two contracts take place? Is the interaction asynchronous?

2 Answers 2


If you want to get off-chain data through the API calls, the only way would be to use blockchain oracles. Chainlink is a good option to start with it.

Oracle does not emit anything. Emit is a contract member in the sense will be triggered when a certain function executed. You can use it to get updates about your contract on your front-end application as well.

Here is the how-to get data using HTTP GET request.

Once the oracle reads your API request, it will send the function back to your smart contract. This way, you don't need to request any more data from oracle. Chainlink also provides a video explanations if you prefer to watch. Here is a youtube link

  • thank you for your answer I have to draw a decision making architecture based on smart contracts. I have to manage hotel reservations based on the weather. The logic of confirming or canceling reservations is encapsulated in the smart contract and the weather information is provided by the oracle. So after the oracle has collected the weather data it sends the information directly to my smart contract? and the oracle smart contract? sorry for my english
    – Mario Roma
    Commented Nov 30, 2020 at 2:53
  • Yes, you can define a variable to hold the degree of the city that you want. Your GET API request will be processed by oracle. Once the data is ready, a function in your contract will be triggered (again video explains) and your data will be updated.
    – Emrah
    Commented Nov 30, 2020 at 3:00
  • my colleague told me i have to use ethereum and web3j. is it the same?
    – Mario Roma
    Commented Nov 30, 2020 at 9:26
  • Building your own oracle infrastructure can be really tough. As @Emrah suggests, there are frameworks already in place like Chainlink so you don't have to build your own. Commented Nov 30, 2020 at 11:33

Does my smart contract need to get the information from this server? If so, how?

In Ethereum, logs are stored "next" to the blockchain. They are not apart of consensus, however they are verified as part of the transaction receipt hashes and are stored inside the blocks. This logging allows oracle services to read these logs and look for instructions in the logs.

How does the interaction between the two contracts take place?

The Chainlink runlog initiator is a perfect example of this and does what you're suggesting. It reads off the ETH logs looking for the instructions for when to perform and what actions to perform.

You can learn more about logging and working with blockchains in the ETH pub/sub documentation.

Is the interaction asynchronous?

Yes. An oracle service will read the log and instructions in 1 block, process it, make whatever API calls it needs, and then in a later block make a transaction back on-chain.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.