Encountering difficulties in connecting front-end HTML to a private blockchain for interacting with a smart contract.
Steps completed thus far:
- Created a smart contract and deployed it on the private blockchain.
npm install -g web3
- Developed an HTML file and connected it to the following JS file.
// Sample app.js code snippet
var Web3 = require('web3');
var web3 = new Web3();
if (typeof web3 !== 'undefined') {alert(" web3.currentProvider :: " + web3.currentProvider);
web3 = new Web3(web3.currentProvider);
} else {
// Choose the desired provider 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;