Moralis.transfer Sender Address not found [SOLVED]

Hi!
Iā€™m trying to send bnb from one wallet to another in testnet. I am connected to bsc chain Id 97 using the bsc testnet rpc of moralis speedy node.
Iā€™m getting an error ā€œSender Address not foundā€ after writing the following code:

const options = {type: "native", amount: Moralis.Units.ETH("0.1"), receiver: "receiver_address"}
await Moralis.transfer(options)

I tried using mainnet rpc from moralis and it worked fine. But it returns error as soon as I use the testnet rpc.
Any idea what might be wrong? Thank you :slight_smile:

What did you do to change from mainnet to testnet?
Are you authenticated when you execute this transfer?

Yes ser! Iā€™m authenticated. I just changed the rpc while going from mainnet to testnet.

Oh I think I might confuse you. So, iā€™ll explain it in details.

  1. Iā€™m authenticated,
  2. Iā€™m using chain id of 97 along with moralis bsc testnet as custom network in metamask,
  3. I have set provider to using moralis bsc testnet rpc.
  4. I canā€™t perform transfer nor any action while using testnet rpc as provider in web3. But it works fine if I set the provider to mainnet rpc.

This is what the code tries to do in Moralis SDK:

    const web3 = await MoralisWeb3.enable();
    const sender = await (await web3.eth.getAccounts())[0];
    if (!sender) throw new Error('Sender address not found');

It looks like it doesnā€™t find anything in web3.eth.getAccounts()[0]

Yeah. Itā€™s so weird. When Iā€™m connected to testnet rpc web3 provider I canā€™t seem to get any account doing

(await web3.eth.getAccounts())[0];

But it show all the accounts when Iā€™m connected to mainnet rpc as web3 provider.

But it works fine if I set the provider to mainnet rpc

Do you mean ā€œswitch network in metamaskā€?