web3.eth.watch('pending').changed not being called?

ThePiachuThePiachu Member Posts: 15
edited June 2015 in Education
I'm currently trying to follow the tutorial for writing javascript for AlethZero client. I'm trying to display live data in the JavaScript API window. I drag and drop my test.html into it, the function

web3.eth.watch('pending').changed(function(){

gets called and data is populated. I mine a few blocks, and nothing changes. My code looks like:

<html>
<head>
  <title>JavaScript API</title>
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js">
  
<script type="text/javascript">
///First web3.eth.watch code to monitor coinbase
  

///Insert your contract address var here:

///Second web3.eth.watch code to monitor block number
  web3.eth.watch('pending').changed(function(){
  var coinbase = web3.eth.coinbase;
  document.getElementById('coinbase').innerText = coinbase;
  var balance = web3.eth.balanceAt(coinbase);
  document.getElementById('balance').innerText = balance;
  var blockNumber = web3.eth.number;
  document.getElementById('latestBlock').innerText = blockNumber;
  var hash = web3.eth.block(blockNumber).hash;
  document.getElementById('latestBlockHash').innerText = hash;
  var timeStamp = web3.eth.block(blockNumber).timestamp;
  document.getElementById('latestBlockTimestamp').innerText = Date(timeStamp);
  var contractString = JSON.stringify(web3.eth.storageAt(contractAddress))
  document.getElementById('contractString').innerText = contractString;
});

</script>

</head>

<body>

  <div class="header">
    <h3>JavaScript API</h3>
  </div>

  <div class="jumbotron">
    <h5>Coinbase Address: <strong id="coinbase"></strong></h5>
    <h5>Balance: <strong id="balance"></strong></h5>
    <h5>Latest Block Number: <strong id="latestBlock"></strong></h5>
    <h5>Latest Block Timestamp: <strong id="latestBlockTimestamp"></strong></h5>
    <h5>Latest Block Hash: <strong id="latestBlockHash"></strong></h5>
    <h5>Contract String: <strong id="contractString"></strong></h5>
    <h5>Favourite Python: <strong id="favouritePython"></strong></h5>
    <br>
  </div>

</body>

</html>

What am I doing wrong?
Post edited by StephanTual on

Comments

Sign In or Register to comment.