Initialize Web3 instance without passing an initial provider.
I am trying to initialize Web3 in a TS project as follows:
javascript
const web3 = new Web3()
web3.setProvider(someProvider)
however the compiler outputs the following error:
An argument for 'provider' was not provided
Is this expected?
javascript
const web3 = new Web3()
web3.setProvider(someProvider)
An argument for 'provider' was not provided
Web3 1.0.0-beta.41
It looks like this is something that was introduced recently, [email protected] allows to initiate a Web3 instance without providing a provider.
Just for confirmation, should I consider this pattern no longer possible?
const web3 = new Web3()
web3.setProvider(someProvider)
const web3 = new Web3() is something that I came across quite a lot on available tutorials.
Also encountered this issue when updating dependencies. I am worried about that If this breaking change is intentional, web3 instances cannot even be initialized in browsers without a injected web3 provider and requires much code for pre-1.0.0-beta.37 Dapps to adapt to.
For a quick workaround, pass a dummy (but invalid) URI that would be recognized as an HTTP RPC endpoint: new Web3('http://dummy')
@wnz99
Thanks for submitting this issue I'll fix this on Monday. I'm currently sick in the bed.
sure, thank you.
@wnz99 or @andy0130tw can you explain me the exact use case for initiating a Web3 object without a provider?
I'm closing this issue because there was no answer from the creator.
Most helpful comment
It looks like this is something that was introduced recently,
[email protected]allows to initiate a Web3 instance without providing a provider.Just for confirmation, should I consider this pattern no longer possible?
const web3 = new Web3()is something that I came across quite a lot on available tutorials.