I am developing a simple Voting dApp by following a tutorial. In this tutorial we are using npm install ethereumjs-testrpc web3
so that we can get the fake nodes of Ethereum.
For that i first created the object of web3 by using Web3 = require('web3')
command in the Node.js command prob. After using the command i should get all the attributes of Web3. But i am only getting [Function: Web3]
.
After that i am using web3 to connect to the localhot:8545 by using web3 = new Web3("http://localhost:8545")
in the Node.js command prob. To check that i am connected to localhost:8485 i am using web3.eth.getAccounts(console.log)
. I should get addresses as follows;
['0x9c02f5c68e02390a3ab81f63341edc1ba5dbb39e', '0x7d920be073e92a590dc47e4ccea2f28db3f218cc', '0xf8a9c7c65c4d1c0c21b06c06ee5da80bd8f074a9', '0x9d8ee8c3d4f8b1e08803da274bdaff80c2204fc6', '0x26bb5d139aa7bdb1380af0e1e8f98147ef4c406a', '0x622e557aad13c36459fac83240f25ae91882127c', '0xbf8b1630d5640e272f33653e83092ce33d302fd2', '0xe37a3157cb3081ea7a96ba9f9e942c72cf7ad87b', '0x175dae81345f36775db285d368f0b1d49f61b2f8', '0xc26bda5f3370bdd46e7c84bdb909aead4d8f35f3']
All i need is one of those addresses to proceed further. But i am getting an error which says that Connection refused or URL couldn’t be resolved as follows;
Promise { <pending>, domain: Domain { domain: null, _events: [Object: null prototype] { removeListener: [Function: updateExceptionCapture], newListener: [Function: updateExceptionCapture], error: [Function: debugDomainError] }, _eventsCount: 3, _maxListeners: undefined, members: [], [Symbol(kWeak)]: WeakReference {} } } > Error: Connection refused or URL couldn't be resolved: http://localhost:8545 at XMLHttpRequest.request.onreadystatechange (D:NotesBCSSemester 7FYPNew Onenode_modulesweb3-providersdistweb3-providers.cjs.js:759:22) at XMLHttpRequestEventTarget.dispatchEvent (D:NotesBCSSemester 7FYPNew Onenode_modulesxhr2-cookiesdistxml-http-request-event-target.js:34:22) at XMLHttpRequest._setReadyState (D:NotesBCSSemester 7FYPNew Onenode_modulesxhr2-cookiesdistxml-http-request.js:208:14) at XMLHttpRequest._onHttpRequestError (D:NotesBCSSemester 7FYPNew Onenode_modulesxhr2-cookiesdistxml-http-request.js:349:14) at ClientRequest.<anonymous> (D:NotesBCSSemester 7FYPNew Onenode_modulesxhr2-cookiesdistxml-http-request.js:252:61) at ClientRequest.emit (events.js:198:13) at ClientRequest.EventEmitter.emit (domain.js:448:20) at Socket.socketErrorListener (_http_client.js:392:9) at Socket.emit (events.js:198:13) at Socket.EventEmitter.emit (domain.js:448:20) null
I also check a relevant answer to my question in this stack exchange. But this answer is telling to use truffle instead of solving the above problem. And if comments of this answer are solving the above problem then they are perhaps solving it for actual web3 not for ethereumjs-testrpc web3.
I am using solidity and if you need the code i can edit my question.