Reference Error


while generating new address:

var address = new Address.fromString(‘mwkXG8NnB2snbqWTcpNiK6qqGHm1LebHDc’);

I get an error:

ReferenceError: Address is not defined
at Object. (/home/predix/.npm-global/lib/node_modules/bitcore-node/lib/cli/kartiki.js:7:21)
at Module._compile (module.js:570:32)
at Object.Module._extensions…js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3

And also ,
while creating private key,

var privateKey = PrivateKey.fromWIF(‘cPBn5A4ikZvBTQ8D7NnvHZYCAxzDZ5Z2TSGW2LkyPiLxqYaJPBW4’);

I get such error::

ReferenceError: PrivateKey is not defined

Why is this so?Where I’m getting wrong or missing something?
Please help ,I’m new to all this stuff.

(FedFranz) #2

As the error says, Address and PrivateKey are not defined.
If you import bitcore-lib like this:
const bitcore = require('bitcore-lib')
than you should use

If you want to use PrivateKey directly you should define it at the beginning as:
const PrivateKey = require('bitcore-lib').PrivateKey

I strongly advise you to learn some Javascript basics before going on.