[SOLVED] How to transfer eth from wallet address(create automatic by Moralis) to another wallet address?

Hi all,

When I login website via my Google account, Moralis will create 1 wallet address(call wallet A).
I can send eth to this wallet(A) successful.( I send from my another wallet from MetaMask and sign by MetaMask).

const {fetch, isFetching} = useWeb3Transfer({
amount: Moralis.Units.ETH(amount),
receiver: receiver,
type: ‘native’,
});

My problems: Now I want send from this wallet(A) to another wallet address.
I tried with code above and extension MetaMask open for sign. Whatttt ? How and Why to sign wallet address which create by Moralis when I login with google account with extension MetaMask on my local?

I very confuse here. By u know we can transfer eth from wallet address when we must have private key. In this case we have not private key, Moralis storage somewheres?

Question: How to send eth from this wallet address(A) to another wallet address?

Thanks for reading
P/S: Sorry my bad English

When I login website via my Google account, Moralis will create 1 wallet address

How is this wallet created? Moralis itself does not create nor manage wallets for you. Are you using a service like Web3Auth?

Otherwise you will need to use the wallet’s private key (directly in code with a library like ethers.js or imported into a wallet like MetaMask) to make transactions or transfers from it.

1 Like

Hi Glad,

Yes, i using Web3Auth with Moralis.
In this case how to solve my problem? I don’t have private key for wallet from Web3Auth.

You are using moralis-v1 Web3Auth?

Web3Auth creates and manages the wallet for you and you can’t get the private key. But if you login with Web3Auth, you can make transactions e.g. with Moralis.executeFunction and you don’t have to sign anything. How do you make transfers in your code?

If you reload the page (and don’t authenticate), you need to use Moralis.enableWeb3() with the same Web3Auth options you use in Moralis.authenticate() to ensure you’re using the Web3Auth web3 provider, not the default/injected one (from MetaMask extension).

I using Moralis-v1 Web3Auth.

Using useWeb3Transfer from Moralis for send eth:

const {fetch, isFetching} = useWeb3Transfer({
    amount: Moralis.Units.ETH(amount),
    receiver: receiver,
    type: 'native',
  });

This is code for login with Web3Auth:

await authenticate({
          provider: 'web3Auth',
          clientId: process.env.NEXT_PUBLIC_API_KEY_WEB3AUTH,
          chainId: Moralis.Chains.ETH_ROPSTEN,
          appLogo: process.env.NEXT_PUBLIC_URL + '/logo.png',
        });

can you share How to add option into Moralis.enableWeb3()? I just call Moralis.enableWeb3().

Thanks Glad

You just add the exact same options.

await enableWeb3({
          provider: 'web3Auth',
          clientId: process.env.NEXT_PUBLIC_API_KEY_WEB3AUTH,
          chainId: Moralis.Chains.ETH_ROPSTEN,
          appLogo: process.env.NEXT_PUBLIC_URL + '/logo.png',
        });
1 Like

Got it. Awesome Moralis . Thank you very much Glad :slight_smile: