Realm Function error ethers.js and web3

Hi everyone, I’m trying to write a simple realm function where, using the ethers.js dependency, I get back the number of transactions in my ethereum wallet.

But I get an error when I try to use the function: toLowerCase() is not a function

Why? I leave you the code hoping to be able to solve …

exports = async function(arg){
  var ethers = require("ethers");
  
  const provider = 
new ethers.providers.JsonRpcProvider("https://goerli.infura.io/XXXXXXXXXXXXXXXXXXXX");
  const wallet = new ethers.Wallet("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", provider);
  
  const gasPrice = await provider.getGasPrice(); //THIS WORKS FINE
  console.log(gasPrice);
  
  const nonce = await wallet.getTransactionCount(); //THIS THROWS THE ERROR toLowerCase() is not a function
  console.log(nonce);
};

Hi @Filippo_Murolo ,

How do you upload the Ethar.js module ? Do you use external dependencies?

It looks as the source code of the Ethar JS is Type Script based:

I am not sure how it will all blend in a App Services dependency…

Have you searched the web if anyone did something like that?

PS. I think your best chance is to see what said on Ethersjs "toLowerCase is not a function" typeerror on MongoDB Realm Webhook · Issue #2238 · ethers-io/ethers.js · GitHub

Thanks
Pavel