9

I am making a project using Ethereum.

In this project , I am making a contract called "A".

When I send a message to "A", I want "A" to make a web request.

Is it possible that Solidity requests using http (method GET/POST )?

문효범
  • 93
  • 1
  • 4
  • [How to create a Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) – Jorengarenar Jul 15 '20 at 21:54
  • 1
    Solidity cannot interact with external services. You'd need a Oracle for interacting with external API's. You could look into https://docs.provable.xyz/#ethereum-quick-start – Stephen S Jul 16 '20 at 07:42

1 Answers1

16

Ethereum blockchain cannot interact with outside world, otherwise it would no longer be deterministic and 10,000s of Ethereum nodes getting different HTTP return values could not reach a consensus on a blockchain state.

The only way to input outside world data to Ethereum is to have an Ethereum account that pushes data to the blockchain. This kind of setups are called oracles.

  • Oracle is a server-side worker process

  • Oracle does HTTP GET/POST

  • Oracle writes the data to a smart contract using a normal Ethereum smart contract transaction

Patrick Collins
  • 5,621
  • 3
  • 26
  • 64
Mikko Ohtamaa
  • 82,057
  • 50
  • 264
  • 435
  • 3
    Bonus info: Oracles are utilized for other consensus purposes. For example a random value. Blockchain nodes cannot randomly generate the same value, let alone doing it again any time they need to validate the data later on. Also, randomization can be predictable and is you have access to hardware, manipulatable. So they use trusted oracles – toraman Dec 08 '21 at 19:36