2

I have been trying to set up my dapp, and have not found any resource that explains it thoroughly. I want to connect my application to ethereum using Geth and web3. So far, my index.js file looks like this:

var Web3 = require('web3')

 if (typeof web3 !== 'undefined') {
   web3 = new Web3(web3.currentProvider)
 } else {
   web3 = new Web3(new 
   Web3.providers.HttpProvider('http://localhost:8545'))
 }

And I type:

geth --testnet --rpc

to initiate the node in my command line. I have an npm script that runs geth and compiles index.js at the same time. Is there something I am missing? I also have another question. What is the correct way to import web3 using ES6 modules (import ... from ...)?

TylerH
  • 20,799
  • 66
  • 75
  • 101
Nic Bonetto
  • 543
  • 1
  • 8
  • 20

1 Answers1

1

I recommend this command

geth --rpc --rpcaddr 0.0.0.0 --rpcport 8545 --rpccorsdomain "*" console

geth has many options so you should read geth docs.

clemens
  • 16,716
  • 11
  • 50
  • 65