Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- eth.syncing
- window.addEventListener('load', function () {
- if (typeof web3 !== 'undefined') {
- console.log('Web3 Detected! ' + web3.currentProvider.constructor.name)
- window.web3 = new Web3(web3.currentProvider);
- } else {
- console.log('No Web3 Detected... using HTTP Provider')
- window.web3 = new Web3(new Web3.providers.HttpProvider("https://mainnet.infura.io/noapikey"));
- }
- })
- function getBalance() {
- var address, wei, balance
- address = document.getElementById("address").value
- try {
- web3.eth.getBalance(address, function (error, wei) {
- if (!error) {
- var balance = web3.fromWei(wei, 'ether');
- document.getElementById("output").innerHTML = balance + " ETH";
- }
- });
- } catch (err) {
- document.getElementById("output").innerHTML = err;
- }
- }
Add Comment
Please, Sign In to add comment