7

I need someone who can explain to me, step by step, in simple terms how can I connect the ethereum wallet with the local blockchain. I found the following link: Connect Mist to ethereum-js testrpc

The problem is I'm still learning how to code and setting up test environments.So this is all new stuff to me.

Can somebody explain to me how and where do I have to put the following lines so that the Ethereum wallet connects with my local blockchain and not with the live testnet?!

web3.setProvider(new web3.providers.HttpProvider("http://localhost:8545"));

Some basic step by step instruction would be nice.

Thanks in regards

5 Answers 5

5

There's a very simple way to do this that doesn't involve messing with HTML files.

  1. Install testrpc, if you haven't already. Instructions are here.
  2. Start testrpc in a terminal. This should just work with testrpc, as long as it's installed.
  3. In a different terminal, start mist with Mist --rpc http://localhost:8545

It will warn you that you're connecting (unsafely) over RPC, which is fine, because it's a private testnet. If it worked you'll see in your wallet dapp that you're 1,000 ETH richer. :) It will also say, in red, that it's a private network. Enjoy!

11
  • Yes I have testrpc installed and it runs fine.I'm using Ubuntu as operating system.
    – Viktor
    Nov 18, 2016 at 9:01
  • Do I have to download the Ethereum wallet and let it sync before I can run it with your given command? Because it says the command couldn't be found.
    – Viktor
    Nov 18, 2016 at 9:13
  • And what about the other option with html? Do you know where I would have to those line? Is it in the wallet itself under development tools and Ethereum wallet? And where in that html code do I have to put those line. Sorry for my dumb questions but I'm not a coder and this is all pretty new to me.
    – Viktor
    Nov 18, 2016 at 9:14
  • Yes, you'll have to install Mist, which you can get here. You won't need to sync it, just have it installed. I'll add another answer for the HTML solution. Nov 18, 2016 at 13:31
  • 2
    For people on a Mac who can't get it working: ethereum.stackexchange.com/a/11765/5995
    – migu
    Feb 4, 2017 at 20:32
1

To connect to TestRPC using geth:

  1. Start TestRPC
  2. In another command window type: geth attach http://localhost:8545
0

Here's one method of getting web3 working in an HTML file.

  1. Get web3.js from here. web3.min.js will also work, but it'll have less detail for debugging.
  2. In the same directory as web3.js, create an HTML file including web3.js, and also set the provider.

Here's an example:

<html>
<script src="web3.js"></script>
<script>
var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
</script>
</html>
  1. Start testrpc in a terminal.
  2. Open that HTML file in any browser.
  3. In that one HTML file, you can now access web3. To test this, you can open the browser's console (it's CTRL-SHIFT-K in Firefox) and type web3.isConnected(). If it says true, you're good to go.

That's right, you don't actually need mist. In fact, I recommend using an ordinary browser such as Firefox so that you can use common debugging tools such as Firebug. Just for now, you can use the browser's console as a REPL (Read, Evaluate, Print Loop) (a.k.a. a command line) to mess around. If you include any javascript in this HTML file, it'll have access to web3.

The caveat with my example is that this will overwrite whatever web3 the browser already has. Here's the code for it to not do that (replace the contents of the second script tag):

if (typeof web3 !== 'undefined') {
  web3 = new Web3(web3.currentProvider);
} else {
  // set the provider you want from Web3.providers
  web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
}

But try the simpler code first, since I've found it's better to get something working first, then get it right.

Similarly, this is the simplest method, but there's much better methods of including javascript libraries. I personally use tools such as browserify and beefy to handle dependencies (such as web3.)

0

After installing ethrereumjs-testrpc, npm install -g ethereum-testrpc

  • Start testrpc, with testrpc command on terminal, as long as it's installed.
  • In another terminal, Start mist with mist --rpc
    http://localhost:8545.
0

If you are on Linux you can run below command to run Ethereum Wallet with testrpc/Private network

$ ethereumwallet --rpc http://localhost:8545

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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