let’s say a contract wants to execute on knowledge contained outside the blockchain (e.g. whats the price of gold, what was the avg windspeed in NYC, how many people moved to portland in the last week) — what are common ways a contract might acquire this sort of information?
2 Answers
The common pattern is called an oracle.
Ethereum contracts cannot communicate directly with the outside world, so they must rely on the outside world pushing information into the network.
You have 2 choices:
Use an oracle: Services like Oraclize are formal implementations where you pay to poke their services for oracle data that they provide.
Write an oracle: If the data you require is not already oracle-ized, but you have the savvy to do so, you can write your own external service that periodically pokes data into your own oracle contract. Then your application contract just requests it when it needs it.
-
1You beat me to the answer! kudos. Just to add some little value. For example, you can get data from wolfram alpha with oraclize. ex: docs.oraclize.it/#datasources-wolframalpha– hhhCommented Jan 24, 2017 at 15:24
-
If you wanted to get some details outside of blockchain. so you need to use oracle service like https://chain.link/data-feeds. or if you wanted to get info inside of blockchain so might be oracle of this blockchain is available. you can also write your own oracle. most used case oracle is price oracle.