Describe the bug
When calling window.ethereum.send('eth_requestAccounts') it throws MetaMask - RPC Error: The method undefined does not exist/is not available. I can only reproduce this on localhost.
To Reproduce
I can only reproduce this locally at this time
Expected behavior
I would expect this not to throw that error message
Browser details (please complete the following information):
If I change it to .send({method: 'eth_requestAccounts', params: []}) the issue goes away
Same:
OS: OS X
Browser: Chrome
MetaMask Version: 7.7.1
but changing it to
.send({method: 'eth_requestAccounts', params: []})
Just gave me:
actions.js:60 Uncaught (in promise) TypeError: Cannot read property 'then' of undefined
at actions.js:60
at new Promise (<anonymous>)
at _callee2$ (actions.js:52)
at tryCatch (runtime.js:62)
at Generator.invoke [as _invoke] (runtime.js:296)
at Generator.prototype.<computed> [as next] (runtime.js:114)
at asyncGeneratorStep (asyncToGenerator.js:5)
at _next (asyncToGenerator.js:27)
.......
Show 107 more frames
2inpage.js:1 Uncaught TypeError: e is not a function
at inpage.js:1
at inpage.js:1
at i (inpage.js:1)
at inpage.js:1
at inpage.js:1
at c (inpage.js:1)
at inpage.js:1
at We (inpage.js:1)
at Object.<anonymous> (inpage.js:1)
at e.exports._runReturnHandlersUp (inpage.js:1)
Had the same following the Medium post
Same issue as Ramarti. I find it quite scary that the suggested method is not working and the breaking update is coming Q1 2020.
I encounter the same error.
I bring web3 version 1.2.1 and initialize it with the MetaMask provider.
window.localWeb3 = new Web3( window.ethereum)
If I don't override the web3 version that is injected by Metamask this error does not occur and the
localWeb3.currentProvider.send('eth_requestAccounts').then( ()=>{...})
works properly.
I order to avoid this issue I fallback to
localWeb3.currentProvider.enable()
for establishing wallet connection and i use the
localWeb3.eth.getAccounts()
in order to retrieve the accounts.
On its own the
localWeb3.eth.getAccounts()
doesn't show the MetaMask popup promt for establishing wallet connection, that is why is use enable(). However this method is documented as "to be deprecated"and so I too am confused on how to implement dependent connection to MetaMask in my app and be ready for future releases.
OS: Windows 10
Browser: Chrome
MetaMask Version: 7.7.1
Hi all, I'm here to clarify the current situation:
TLDR:
ethereum.send(methodName) is not available yet, and won't be until early 2020.sendAsync() method is not going to change or break, so using it is one safe way to avoid these issues.ethereum.enable() as a promise-returning alternative to eth_requestAccounts today.First of all, I'm very sorry for the confusion. "Breaking changes" are some of the worst things we ever have to subject developers to, and rolling them out is always a delicate thing, and we had some communication issues with this one, where we announced the changes before developers actually had a migration path to build on.
The new syntax send(methodName, params) which will return a promise, is not yet available in production. This is a part of the EIP 1193 specification that we do not yet support, so for now your best path is to continue using the good old workhorse ethereum.sendAsync(options, callback), which is not going to be broken by any of the coming changes. The changes are exclusively breaking a few old synchronous methods, and also adding a new syntax for returning promises from a pure send() call.
We started rolling out the breaking change in November, but we found some usability issues with some of the changes, which we decided to roll back and fix before publishing it again.
You can read more about the state of the related branch here.
Sorry again for the confusion, for now the proper way to call requestAccounts is:
ethereum.sendAsync({ method: 'requestAccounts' }, function (err, result) { /** Handle result **/ });
You can also call ethereum.enable() for the same result, which _does_ return a promise, even today.
Most helpful comment
Hi all, I'm here to clarify the current situation:
TLDR:
ethereum.send(methodName)is not available yet, and won't be until early 2020.sendAsync()method is not going to change or break, so using it is one safe way to avoid these issues.ethereum.enable()as a promise-returning alternative toeth_requestAccountstoday.First of all, I'm very sorry for the confusion. "Breaking changes" are some of the worst things we ever have to subject developers to, and rolling them out is always a delicate thing, and we had some communication issues with this one, where we announced the changes before developers actually had a migration path to build on.
The new syntax
send(methodName, params)which will return a promise, is not yet available in production. This is a part of the EIP 1193 specification that we do not yet support, so for now your best path is to continue using the good old workhorseethereum.sendAsync(options, callback), which is not going to be broken by any of the coming changes. The changes are exclusively breaking a few old synchronous methods, and also adding a new syntax for returning promises from a puresend()call.We started rolling out the breaking change in November, but we found some usability issues with some of the changes, which we decided to roll back and fix before publishing it again.
You can read more about the state of the related branch here.
Sorry again for the confusion, for now the proper way to call
requestAccountsis:ethereum.sendAsync({ method: 'requestAccounts' }, function (err, result) { /** Handle result **/ });You can also call
ethereum.enable()for the same result, which _does_ return a promise, even today.