Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

New ENS fails with Cannot read property 'sendPayload' of undefined #326

Open
novakov-alexey-zz opened this issue Mar 28, 2019 · 5 comments

Comments

@novakov-alexey-zz
Copy link
Contributor

I am trying to run a sample code to create ENS instance in my console and then to resolve some name. But it fails just on ENS creation.

Versions:

  • Truffle v5.0.9 (core: 5.0.9)
  • Node v11.12.0
  • web3.version '1.0.0-beta.37'

I am using Geth with Rinkeby network.

truffle(rinkeby)> var ENS = require('ethereum-ens');
undefined
truffle(rinkeby)> var Web3 = require('web3');
undefined
truffle(rinkeby)> var provider = new Web3.providers.HttpProvider();
undefined
truffle(rinkeby)> var ens = new ENS(provider);
Thrown:
/Users/aa/dev/git/blockchain/isaqb-eth-solidity/node_modules/web3-providers/dist/web3-providers.cjs.js:49
      if (provider.sendPayload && provider.subscribe) {
                   ^

TypeError: Cannot read property 'sendPayload' of undefined
@makoto
Copy link
Member

makoto commented Mar 30, 2019

Hi, can you upgrade to the latest ethereum-ens (ver 0.7.6) and try again?

@novakov-alexey-zz
Copy link
Contributor Author

Hi @makoto, this issue seems to be gone with latest version, but I have another problem:

var ENS = require('ethereum-ens');
    var Web3 = require('web3');

    var provider = new Web3.providers.HttpProvider("http://localhost:8545");
    var ens = new ENS(provider);

    ens.resolver('alexeyn.test').addr().then(function(addr) { console.log(addr) });

Thrown:
evalmachine.<anonymous>:0
ens.resolver('alexeyn.test').addr().then(function(addr) { console.log(addr) });
                             ^

TypeError: ens.resolver(...).addr is not a function

Is it something known?
So far I can't reach any success with ens js library, always some miss match :-(

@makoto
Copy link
Member

makoto commented Apr 9, 2019

@novakov-alexey sorry for taking ages to respond. Can you try with 0.7.7?

I think what was happening was it was picking up whatever the web3 version you have locally and ENS is not compatible with the later version of Web3.

So my fix is to fix web3 version to the known working version.

https://github.com/ensdomains/ensjs/compare/fix-web3js-version?expand=1

I created the following truffle script and run on the project where later version of web3 (1.0.0-beta.52) is installed and looks working fine.

ENS = require('makoto-ethereum-ens');
name = 'alexeyn.test'
module.exports = async function(callback) {
// Connect to infura using HDWalletProvider
// https://medium.com/coinmonks/deploy-your-smart-contract-directly-from-truffle-with-infura-ba1e1f1d40c2   
    let provider = web3.currentProvider
    let ens = new ENS(provider)
    console.log('owner', await ens.owner(name))
    console.log('address', await ens.resolver(name).addr())
    callback()
}

@novakov-alexey-zz
Copy link
Contributor Author

Hi @makoto, sorry for even longer delay in response. I have tried my script with new ENS version. However, it still fails somewhere between Node and my local Geth client:

╰─ node                                                                                                                                                                                         17.29   ✔   09:44    13.05.19  
> var Web3 = require('web3');
undefined
> var ENS = require('ethereum-ens');

undefined
> name = 'alexeyn.test'
'alexeyn.test'
> 
> async function test(callback) {
...     let provider = new Web3.providers.HttpProvider("http://localhost:8545")
...     let ens = new ENS(provider)
...     console.log('owner', await ens.owner(name))
...     console.log('address', await ens.resolver(name).addr())
...     callback()
... }
undefined
> 
> test();
Promise { <pending> }
> (node:72086) UnhandledPromiseRejectionWarning: Error: Node error: {"code":-32700,"message":"json: cannot unmarshal object into Go struct field jsonRequest.method of type string"}

Perhaps, I need to update Geth or so.

@Arachnid
Copy link
Member

This looks like the same issue with web3 issuing broken RPC requests.

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

No branches or pull requests

3 participants