Does Solidity have HTTP request function?
Asked Answered
K

1

11

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 )?

Keek answered 15/7, 2020 at 17:1 Comment(1)
Solidity cannot interact with external services. You'd need a Oracle for interacting with external API's. You could look into docs.provable.xyz/#ethereum-quick-startGeophilous
A
19

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

Ashia answered 20/7, 2020 at 21:55 Comment(1)
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 oraclesDomineer

© 2022 - 2024 — McMap. All rights reserved.