Web3 API invalid address code 141

I get the error “invalid address code 141” when trying to query data using the web3 api.

Log shows that I am passing in an address, what am I doing wrong here?

Moralis.Cloud.define("saveTokenMetaData", async request => {
  const token_address = request.params.token_address;
  if (!token_address) return;
  const TokenMetaData = Moralis.Object.extend("TokenMetaData");
  const query = new Moralis.Query(TokenMetaData);
  query.equalTo("token_address", token_address);
  const result = await query.find();

  if (result.length > 1) return;
  logger.info("MetaData not stored yet " + token_address)
  const metaDataResult = await Moralis.Web3API.token.getTokenMetadata({
    address: token_address,
    chain: "eth"

  if (!metaDataResult) return;
  const data = metaDataResult[0];
  const token = new TokenMetaData();

  token.set("token_address", data.address);
  token.set("name", data.name);
  token.set("symbol", data.symbol);
  token.set("thumbnail", data.thumbnail);
  token.set("decimals", data.decimals);
  token.set("validated", data.validated);

  token.save(null, { useMasterKey: true });
2022-03-27T17:08:53.712Z - Failed running cloud function saveTokenMetaData for user undefined with:
  Input: {"token_address":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"}
  Error: {"message":"Invalid address","code":141}

This should be addresses

const metaDataResult = await Moralis.Web3API.token.getTokenMetadata({
    addresses: token_address,
    chain: "eth"
1 Like

:eyeglasses: thank you for your quick response mate

1 Like