Get Value from a read functions which needs an input

Hi guys I’m trying some vanilla js coding. So far I can get values from read functions which need no input (read-only).

But I’m having a hard time getting the read functions to work which need an input.

For example a simpel erc-20 balanceOf - which needs an address as input. Can anyone help me in the right direction… with a working example of the js?

Thanks in advance!!!

@cryptokid ?

You should find an example in documentation for executeFunction.

You can also use runContractFunction for that.

It should be easy, what did you try?

You will also find some examples on forum.

1 Like

Thanks so much!

Was looking through the post… just a little syntax error.
The missing part was giving the params the correct name: “account”

  const options = {
    chain: "bsc",
    address: "xxx",
    function_name: "balanceOf",
    abi: ABI,
    params: { 
      account: 'xxx'
    }
  };
  let balance = await Moralis.Web3API.native.runContractFunction(options);
  console.log(balance);
  }
2 Likes