0

I am getting the following error trying to run the code below. I can not figure out how to resolve it?

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

var web3 = new Web3();
web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'));

var ens = new ENS(web3)

var registrar = new Registrar(web3, ens, 'eth', 7,
  function (err, txid) {
    console.log(txid);
  }
);

registrar.getEntry('insurance', function (err, result) {
  console.log(result);
});


TypeError: Cannot read property 'entries' of undefined
at Registrar.getEntry (/home/jordan/work/ens-test/node_modules/eth-registrar-ens/lib/index.js:236:20)
at /home/jordan/work/ens-test/app.js:30:12
at Layer.handle [as handle_request] (/home/jordan/work/ens-test/node_modules/express/lib/router/layer.js:95:5)
at next (/home/jordan/work/ens-test/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/home/jordan/work/ens-test/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/home/jordan/work/ens-test/node_modules/express/lib/router/layer.js:95:5)
at /home/jordan/work/ens-test/node_modules/express/lib/router/index.js:281:22
at Function.process_params (/home/jordan/work/ens-test/node_modules/express/lib/router/index.js:335:12)
at next (/home/jordan/work/ens-test/node_modules/express/lib/router/index.js:275:10)
at expressInit (/home/jordan/work/ens-test/node_modules/express/lib/middleware/init.js:40:5)
0

Install :

npm install eth-registrar-ens

Example usage:

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

var web3 = new Web3();
web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'));

var ens = new ENS(web3)

var registrar = new Registrar(web3, ens, 'eth', 7,
  function (err, txid) {
    console.log(txid);
  }
);

All methods in this module which use web3 to communicate with an ethereum node support the same optionally-asynchronous pattern as web3. When a callback is provided, the function returns nothing, but instead calls the callback with (err, result) when the operation completes.

Synchronous calls are useful for talking to a contract in the REPL, but dapp developers should use only asynchronous calls in order to support light clients like Metamask.

Functions that create transactions also accept an optional options object. This object has the same parameters as web3's transaction object.

and This help link

Thanks

4
  • Thats the exact code that I am using, I just cant figure out why I am getting the error.
    – Jordan
    Feb 26 '18 at 16:55
  • Please last help link following and try it thanks @jordan Feb 27 '18 at 3:33
  • That link is the tutorial I was following. That doesn't help with the error I was recieving.
    – Jordan
    Feb 28 '18 at 18:48
  • thanks, i read over the asynchronous part for web3, I added the getEntries function inside if the registrar callback and it worked
    – Jordan
    Feb 28 '18 at 22:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.