0

My scenario is as follows:

I use a private Ethereum network such as ganache.

In a smart contract function, I need to call a web service and then continue processing based on it.

I don't have any idea.

can anyone show me a piece of code?

1 Answer 1

0

Blockchains can't interact with the outside world, as they are intentionally isolated and deterministic by nature, which means they cannot make API calls generate random numbers, or for any reason communicate with the outside world.

There comes Blockchain Oracle that solves that problem.

Blockchain Oracles are devices that connect our smart contracts with data and computation from the real world, such as pricing data on currencies, random number generators, and any other data we can think of.

We just have to get data from one of the trusted Blockchain Oracle devices.

Does it actually solve the problem? Are not we going back to a centralized system by getting data from these centralized devices?

The answer is YES. If we get the data from a centralized Oracle network no matter who is running that network, it will be centralized.

So what should we do?

Ans: The only option is that we should get the data from Blockchain Oracles that are running on a Decentralized network.

And here comes the best I know, Chainlink Blockchain Oracles Decentralized system.

When our smart contracts include data or computation from oracles, they are considered hybrid smart contracts, and many of the most successful decentralized applications include data from the external world.

You can visit it here to get more information: https://chain.link/

You will also find the solution for APIs here.

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.