web3.js is the thing that you need. It's quite simple to design web-interface that interacts with your contract using web3. You have to do the necessary installions/ imports that you can see from their github repo.
Here is a simple API written in node that checks balace of a erc-20 standard token.
var web3 = require('web3');
var options = {
host: ' http://localhost:8545',
ipc : true,
personal: true,
admin: false,
debug: false
};
var contractABI= /*abi of contract */
var contractAddress = /* address of contract */
exports.checkCoinBalance = function(req, res) {
var accountAddr = req.body.accountAddress;
if(isAddress(accountAddr)==false){
console.log("This address is not valid");
return res.json({"success":"false","data":[{"message":"Inavlid address"}]});
}
var coinBalance=contract.balanceOf(accountAddr).toNumber();
console.log(coinBalance);
return res.json({"success":"true","data":[{balance: coinBalance}]});
//return "success";
}
I hope this makes things easy to understand. I have designed web-interface for interacting with my erc-20 standard token. You can have a look at full source code prashantprabhakar/ethereum-web-wallet. Hope this helps.
Edited:
Front-end Code Code:
$scope.checkCoinBalance = function(accountAddr) {
var data = JSON.stringify({
accountAddress: accountAddr
});
var config = {
headers: {
'Content-Type': 'application/json'
}
};
$http.post('http://localhost:7000/eth/checkCoinBalance', data, config)
.then(function successCallback(resp) {
if (resp.data.success == 'true') {
console.log(resp.data.data[0].balance);
$scope.coinBalance = resp.data.data[0].balance;
}
},
function failureCallback() {
console.log('failure');
});
}
You can call this checkCoinBalance()
on a button click or so.
getAddr
function with "owner" as an argument of the function which is defined asAddrName
.