[Ethereum] Web3.js and local HTML UI


So my Mix-ide install seems irrevocably crashed and given that there's no other IDE with integrated UI, I'm forced to face the inevitable learning of authoring HTML UI without much of a web dev background. Though there's plenty of material out there about backend DAPP development, I find almost nil regarding front end DAPP UI development. I'd like to start learning how to integrate with Mist. But that aside….

I have the web3.js package in Node and I have web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545")); in my UI html.

Q. For the purposes of a local test chain, where am I suppose to store this page and what serves it to what URL?

Best Answer

So for serverless connection of an HTML front-end to a local node, I:

1) dropped web3.js into the DAPP's directory

2) in the HTML included:

<script type="text/javascript" src="web3.js"></script>
<script type='text/javascript'>
var Web3 = require('web3');

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"));

3) started geth with the --rpccorsdomain="*" switch to prevent Chrome from blocking the calls.

Related Topic