Search code examples
javascriptweb3js

Web3js Javascript Returned error: execution reverted


I have my own BSC node running for scraping data, sometimes there is a token that does not have the standard token info functions like name, symbol, totalSupply and decimals and my scraper will throw a error "Returned error: execution reverted". now I can't find a way to prevent from stopping the scraper if I get this error. I just want the scraper to ignore that token if it gets the error.


Solution

  • For anyone who is interested. basically this is a double but I can not delete my question.

    What I did to solve my problem is

    await contract.methods.totalSupply().call().catch((err) => {
     return;
    });
    

    web3js can have a catch() to catch the errors.