BSC Node Connection problem

Hi, I am trying to follow this video https://www.youtube.com/watch?v=_vy5oIXg9uA
I copied and pasted the code exactly the same, I think. I’m trying to run the page in a browser (netbox and brave) and it doesn’t show me anything. Only a white background… I don’t know what I am doing wrong…
Also I was trying with tx and I had the same result…

TEST
 <script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/index.min.js"></script>
<p id="blockNumber"></p> 

<script>
     const NODE_URL = "https://speedy-nodes-nyc.moralis.io/f59be88c6be7a87eb3736faf/bsc/mainnet";
     let web3 = new Web3(new Web3.providers.HttpProvider(NODE_URL));

     web3.eth.getBlockNumber()
     .then(funtion(blockNumber) {
         document.getElementById("blockNumber").innerHTML = "Block number: " + block Number;
     }); 

</script>
1 Like

Hey @adikapusta8

You had a syntax mistake in code:

getBlockNumber = async () => {
        web3.eth.getBlockNumber().then((blockNumber) => {
          document.getElementById("blockNumber").innerHTML =
            "Block number: " + blockNumber;
        });
      };

And then you can getBlockNumber ()

Hope this will help :wink:

1 Like