Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: ethers.getDefaultProvider is not a function #560

Closed
thecircleoflifefree opened this issue Jul 18, 2019 · 2 comments
Closed

TypeError: ethers.getDefaultProvider is not a function #560

thecircleoflifefree opened this issue Jul 18, 2019 · 2 comments

Comments

@thecircleoflifefree
Copy link

Steps to recreate issue:

First deploy ethers:

$ ethers-deploy serve
Serving content from file:///home/delta/Documents/blockgeeks/myfirstEtherio
Listening on port: 8080
Local Application Test URL:
mainnet: http://ethers.io/#!/app-link-insecure/localhost:8080/
ropsten: http://ropsten.ethers.io/#!/app-link-insecure/localhost:8080/
rinkeby: http://rinkeby.ethers.io/#!/app-link-insecure/localhost:8080/
kovan: http://kovan.ethers.io/#!/app-link-insecure/localhost:8080/
OK: / => ./index.html (1251 bytes) #this appears after opening web page

I do not use the links above as those do not work, instead open FF wit:
https://ropsten.ethers.io/#!/app-link-insecure/127.0.0.1:8080/

block .number and others do not show, instead a blank page appears.

js code snippet:

<script src="https://cdn.ethers.io/scripts/ethers-app-v0.4.min.js" charset="utf-8" type="text/javascript"> </script> <script> var provider = ethers.getDefaultProvider('ropsten'); console.log(provider); some code... <script> ``` This is what the browser console shows: [Ethers Container] Found Fragment URL: http://127.0.0.1:8080/" ropsten.ethers.io:186:847 [Ethers Container] Connected Provider: network=ropsten, chainId=3 ropsten.ethers.io:186:847 [Ethers Container] Initial Account: null ropsten.ethers.io:186:847 [Ethers Container] Ready ropsten.ethers.io:186:847 unreachable code after return statement ropsten.ethers.io:184:250325 Object { https: true, httpsAutoUpgrade: true, privacyScore: 2, entitiesBlocked: Object, entitiesNotBlocked: Object, scores: null } background.js:20780:25 tab.status: complete. site took 0.694 seconds to load. background.js:19350:13 The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol. ropsten.ethers.io "[Ethers Container] Loaded: http://127.0.0.1:8080/" ropsten.ethers.io:186:847 [Ethers Client Library] Connected to Ethers Wallet Container: network=testnet ethers-app- v0.4.min.js:1:798 [Ethers Client Library] Ready ethers-app-v0.4.min.js:1:798 TypeError: ethers.getDefaultProvider is not a function 127.0.0.1:8080:23:20 ``` I checked the documentation: [api-providers](https://docs.ethers.io/ethers.js/html/api-providers.html?highlight=getdefaultprovider) and see that the example uses let instead of var. I'm a bit new and might be overlooking something, any guidance is welcome. Cheers!
@ricmoo
Copy link
Member

ricmoo commented Jul 18, 2019

Wow. I had no idea anyone still used ethers.space (the system ethers-deploy uses). I am planning to get more up on how to use meeseeks-app, which is far more scalable, requires less trust and is easier to use, once I get time to make a few small changes and get the docs updated.

I think ethers-deploy is also still based on the v3 branch of ethers. In v3, it was ethers.providers.getDefaultProvider(), but in v4 and in the v5-beta (available now using ethers@next in npm) it was moved to ethers.getDefaultProvider().

I can take a deeper look into this over the next few days though, and get an idea of how to beat migrate ethers.space to https://meeseeks.app.

@thecircleoflifefree
Copy link
Author

thecircleoflifefree commented Jul 18, 2019

I'm using it due to an online paid course, which now based on your statement seems to be highly deprecated :) ... don't worry too much, and thanks for your quick reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants