Moralis.transfer Sender Address not found [SOLVED]

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”?