javascript - Invalid JSON RPC response: undefined - Stack Overflow

I'm trying to create an Ethereum account through Node.js. This is my code:export async function cr

I'm trying to create an Ethereum account through Node.js. This is my code:

export async function createNewAccount() {
    var web3Instance =  new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
    return web3Instance.eth.accounts.create();
}

But I'm getting the following error (from 'create' function):

Invalid JSON RPC response: undefined

I have installed web3.js in my project.

What other step have I missed?

BTW opening the browser on address http://localhost:8545 returns 404. Is there anything I need to install in order to make it work? Is that the testrpc?

Notice that I want to work against the real blockchain, not a test one.

I'm trying to create an Ethereum account through Node.js. This is my code:

export async function createNewAccount() {
    var web3Instance =  new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
    return web3Instance.eth.accounts.create();
}

But I'm getting the following error (from 'create' function):

Invalid JSON RPC response: undefined

I have installed web3.js in my project.

What other step have I missed?

BTW opening the browser on address http://localhost:8545 returns 404. Is there anything I need to install in order to make it work? Is that the testrpc?

Notice that I want to work against the real blockchain, not a test one.

Share Improve this question asked Nov 9, 2017 at 9:07 AlonAlon 12k28 gold badges103 silver badges172 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4

Web3.js is only a javascript interface that can deal with a real node, in order to conduct RPC requests you must have an ethereum node running this can be either TestRPC , Parity , Geth. additionally, since you are pointing to localhost you will need to run it on your own

The easiest for you to test with will be testRPC install and run it will. By default give you 10 accounts. in order to create a new account with testRPC you will need to run it with --unlock option

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745276503a4620074.html

相关推荐

  • javascript - Invalid JSON RPC response: undefined - Stack Overflow

    I'm trying to create an Ethereum account through Node.js. This is my code:export async function cr

    8小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信