In the following section, an example will be presented that will make use of web3.js to allow interaction with the contracts via a web page served over a simple HTTP web server. This can be achieved by following these steps:
- First, create a directory named /simplecontract/app, the home directory. This is the directory under your user on Linux. This can be any directory, but in this example home directory is used.
- Then, create a file named app.js, as shown here:
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")); } web3.eth.defaultAccount = web3.eth.accounts[0]; ...