I have the following error with the release 1.2.10, an error that does not happen in my case with the 1.2.9.
It happens with the call to web3.eth.getCoinbase
Print the user address
Print the error
App = {
web3Provider: null, // Web3 provider
url: 'http://localhost:9545', // Url for web3
account: '0x0', // current ehtereum account
init: function() {
return App.initWeb3();
},
initWeb3: function() {
if(typeof web3 != 'undefined') {
App.web3Provider = window.ethereum;
web3 = new Web3(App.web3Provider);
try {
ethereum.enable().then(async() => { console.log("DApp connected"); });
}
catch(error) { console.log(error); }
}else {
App.web3Provider = new Web3.providers.HttpProvider(App.url);
web3 = new Web3(App.web3Provider);
}
return App.initContract();
},
initContract: function() {
//Here the error happens
web3.eth.getCoinbase(async function(err, account) {
if(err == null) {
App.account = account
console.log(App.account)
}else{
console.log(err) //Here the error print
}
});
}
}
App.init()
Error: Invalid JSON RPC response: "0xf23a36f9de265fa19c60c9d59488b893474a1571"
at Object.InvalidResponse (unpkg.com/web3@latest/dist/webpack:/packages/web3-core-helpers/src/errors.js:45)
at apply (unpkg.com/web3@latest/dist/webpack:/packages/web3-core-requestmanager/src/index.js:176)
at apply (unpkg.com/web3@latest/dist/webpack:/node_modules/node-libs-browser/node_modules/util/util.js:689)
at b.run (unpkg.com/web3@latest/dist/webpack:/node_modules/process/browser.js:153)
at p (unpkg.com/web3@latest/dist/webpack:/node_modules/process/browser.js:123)
I have the same issue
window.web3` = new Web3(window.ethereum);
window.web3.eth.getAccounts()
.then(console.log)
.catch(console.log)
Logs
Error: Invalid JSON RPC response: ["0xTheActualAddressHere"]
at Object.InvalidResponse (errors.js:45)
at onResult (index.js:176)
at cb (util.js:689)
at Item.push../node_modules/process/browser.js.Item.run (browser.js:153)
at drainQueue (browser.js:123)
Environment:
web3.js 1.2.10
tested on Chrome
hey @ferru97 @jfdelgad thanks for reporting and really sorry about this, I mistakenly though the new Provider.request returns a jsonrpc response object but in fact it returns just the inner result. I opened #3647 to fix and will prepare to push out a v1.2.11 release shortly with the fix.
hey @ferru97 @jfdelgad, v1.2.11 is released now if you could give it another try and let me know if it works for you! thanks again.
hi @ryanio thanks for the fast fix, now it works perfectly!
Thanks for the quick response, all is good now!