Skip to content

Instantly share code, notes, and snippets.

@ianmonkuk
Last active March 31, 2018 07:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ianmonkuk/bffc454d01ed681450b4a33fcf8362db to your computer and use it in GitHub Desktop.
Save ianmonkuk/bffc454d01ed681450b4a33fcf8362db to your computer and use it in GitHub Desktop.
<!doctype html>
<html lang="en">
<head>
<script type="text/javascript" src="./bower_components/web3/dist/web3.min.js"></script>
<script type="text/javascript" src="./bower_components/jquery/dist/jquery.js"></script>
<script type="text/javascript" src="./javascript/truffle-contract/dist/truffle-contract.js"></script>
<script>
window.onload = function() {
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"));
}
$.getJSON("./contracts/MetaCoin.json", function(MetaCoin_json) {
var MyContract = TruffleContract( MetaCoin_json );
MyContract.setProvider(new Web3.providers.HttpProvider("http://localhost:8545"));
MyContract.deployed().then(function(instance) {
return instance.getBalance.call(web3.eth.accounts[2]);
}).then( function(balance) {
document.body.innerHTML = document.body.innerHTML + " balance " + balance;
});
})
};
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment