I know I can send ether to another account using web3.eth.sendTransactions. I also want to get confirmation when a transaction has been successfully broadcasted to the ethereum network, or when an account received ether from another account.

How can I do this with web3?


This is what i did.

function watchBalance() {
  var coinbase = web3.eth.coinbase;
  var originalBalance = web3.eth.getBalance(coinbase).toNumber();
  web3.eth.filter('latest').watch(function(err, result) {
    var currentBalance = web3.eth.getBalance(coinbase).toNumber();
    document.getElementById("current").innerText = web3.fromWei(currentBalance, 'ether');

This will print the current balance of coinbase into a div

  • could you explan what does web3.eth.filter('latest').watch do?
    – Yangrui
    Aug 28 '16 at 3:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.