arkeo 2 months ago

Error in web.min.js

I am not able to get the desired output. Nothing is being printed in the table…
The following is the error I am getting in the console, which I am not able to understand…
Uncaught (in promise) TypeError: r is not a function
    at web3.min.js:1
    at n.sendAsync (web3.min.js:1)
    at l.t [as getBlockNumber] (web3.min.js:1)
    at updateBlocks (index.html:26)
    at window.onload (index.html:21)
My index.html look like the following as it is in the video : 
<!DOCTYPE html>
<html lang="en" dir="ltr">
    <meta charset="utf-8">
    <title>Blockchain Explorer</title>
    <table id="blocks" width='100%'>


    <script src="./web3.min.js"></script>

      window.onload = function() {

      async function updateBlocks(){
        let web3 = new Web3(Web3.givenProvider);
        let latest = await web3.eth.getBlockNumber();

        for(var i=0; i<10; i++){
          let block = await web3.eth.getBlock(latest-i);

      function printBlock(block) {
        var table = document.getElementById('blocks');
        var row = table.insertRow(-1);
        var cell1 = row.insertCell(0);
        var cell1 = row.insertCell(1);
        var cell1 = row.insertCell(2);
        cell1.innerHTML = block.number;
        cell2.innerHTML = block.hash;
        cell2.innerHTML = block.timestamp;

  1. 2
    Jack Wu
    Jack Wu 2 months ago
    When you’re downloading the web3.min.js file from the github repo, please make sure under branches, you select tag and select the latest release (e.g. v1.0.0-beta.36). If you selected the “develop” branch, then you will get errors. Also make sure you have Metamask installed and you’re also running a local web server such as lite-server.

  2. 2
    arkeo 2 months ago
    Thanks a lot for the help!!!