Having issue while connecting front-end HTML to private blockchain in order to interact with the smart contract.
Step completed as below:
- created a smart contract and deployed in pvt blockchain.
npm install -g web3
- created HTML file and linked with below js file.
// Sample app.js file code
var Web3 = require('web3');
var web3 = new Web3();
if (typeof web3 !== 'undefined') {alert(" web3.currentProvider :: " + web3.currentProvider);
web3 = new Web3(web3.currentProvider);
} else {
// set the provider you want from Web3.providers
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
}
var abi= My-custom-ABI;
var ins=web3.eth.contract(abi);
var instance= ins.at("My-Contract-Address");
var accounts;
var account;
var account2;