I'm total newbie. Let's assume I want to create a contract that sell BTC when price reach 20.000$ for example, how can I do that? How smart contract check the price? How many times? I don't understand how smart contract can see the price of BTC and how many times check it.

Thank you


In theory

  • Imagine some service, which imports data from the "world outside" to blockchain. This is called Oracle and you can read about it here.
  • Now, we can find (or build our own!) Oracle which will constantly monitor Bitcoin price.
  • When the desired price is reached your smart contract will create an event, which will be recognised outside the blockchain and the further actions will be made.

In addition, you might want to read: Watching Solidity Events (more practice, less theory).

  • Thank you very much Roman. So instead of an Oracle can I call an API from an Exchange (for example) or I MUST get data from an Oracle?
    – rod
    Dec 21 '17 at 20:31
  • @rod what API are you referencing to? In blockchains we call such services Oracles. Dec 21 '17 at 20:34
  • Ok thank you. But where Oracle Is run? It run directly inside blockchain or where? Thank you very much
    – rod
    Dec 21 '17 at 20:44
  • @rod I think How do oracle services work under the hood is the best short answer to your question. Dec 21 '17 at 20:49
  • Thank you Roman. You are very helpful. In some way, I permit a specified Oracle to send data to my contract, and then the contract check this data. Is this correct? I don't understand HOW an oracle is linked with a contract... I see that smartcontract.com has a chainlink system.
    – rod
    Dec 21 '17 at 20:58

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