PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, September 25, 2022

[FIXED] Which provider should I choose ? Web3Provider ? InfuraProvider ? JsonRPCProvider?

 September 25, 2022     blockchain, ethereum, ethers.js, web3js     No comments   

Issue

I have a question : which provider should I choose for interacting with a contract on the mainnet and why ?

It seems like Web3Provider is easier to use, are there any drawbacks ?

Thank you for your answers.


Solution

To interact with the ethereum blockchain, you need to connect to a node. Most people don't bother setting up a node themselves so they connect to a third party node. In ethers.js a provider is basically your connection to the node. The type of provider you should use depends where your node is hosted.

If you are in a browser the most common way to connect to a node is to use the provider given by the browser extension MetaMask. The ethers documentation explains very simply how to connect to ethereum using MetaMask with the Web3Provider.

If you are using ethers elsewhere, it's more than likely that you will use the JsonRPCProvider. To use it, you only need the url given by the node provider. The docs have also explains clearly how to use the JsonRPCProvider.If you are looking for a free option to get started, I suggest you take a look at Infura.



Answered By - Xavier Hamel
Answer Checked By - Pedro (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing