8

The below given code is from the a tutorial given here at one of the tutorials on Truffle

// Set the provider for our contract
App.contracts.Adoption.setProvider(App.web3Provider);

I see we set up a Web3 provider for the contract.

What basically are providers? What do they do?

4 Answers 4

1

web3 is a client to connect to the blockchain. But

1- you need to tell web3 which blockchain you are connecting to.

2- After you are connected to the specified blockchain, you need to send messages or data to the web3

those 2 tasks are done by a provider.

6

A provider links to a running node. For instance parity or geth.

A node has the ability to view and interact with the blockchain.

1
  • This seems to me as the most accurate answer Commented Nov 23, 2022 at 11:58
6

https://api.myetherapi.com/eth is a provider. Web3 provider is a website running geth or parity node which talks to Ethereum network.

2
  • 1
    Link is broken...
    – whamsicore
    Commented May 19, 2021 at 22:37
  • Looks like they have taken down the whole website. Commented Jul 27, 2022 at 6:46
-1

Initial guess is that this is a web3.js Strategy Pattern to allow an underlying protocol e.g. https to provide access to a node. I will confirm later.

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.