Metamask id not showing confirm dialog

I’m facing an issue with transferring NFT in moralis. I’m using react native the issue is after the ‘transfer’ function call, It is redirecting me to metamask app , then It has to show confirm screen. But It is not showing me.

I use this method https://docs.moralis.io/moralis-dapp/sending-assets/transfer-nfts.

The console is not showing any error regarding the issue.

The error from useWeb3Transfer hook is stored in the error variable. You can try to console.log this error using a useEffect and check if any error is generated during the transfer.

const { error } = useWeb3Transfer

useEffect(() => {
    if (error) {
      console.log(error);
    }
  }, [error]);

there is no console error. I checked already.

const {fetch, error, isFetching} = useWeb3Transfer({ amount: Moralis.Units.Token(0.002, 18), receiver: "0x2F7a5fbD37952885A7fD4D97CffA8CBCCaF2F27C", type: 'erc20', contractAddress: '0x1E324300330135117154f3FbC30419ea87A07E45', });

no error and isFetching returns true.

This is the sample code for transferring NFT’s.
Type should be erc721 and you need to remove the amount and add tokenId parameter. And make sure the wallet is connected to the correct network.

const { fetch, error, isFetching } = useWeb3Transfer({
    type: "erc721",
    receiver: "0x..",
    contractAddress: "0x..",
    tokenId: xxx,
  });

Check docs for more: https://docs.moralis.io/moralis-dapp/sending-assets/transfer-nfts

I’m already trying this method and I’m in polygon Mumbai testnet but there is the same issue. I tried for erc20, erc721 and they are same issue there.

Can I set network on moralis app too or it can fetch from wallet.

Are you able to successfully call the fetch() function?
It should throw some error if it fails.

useWeb3Transfer function uses the network selected in the wallet. If you want to change the network from app you can use switchNetwork function.
const { switchNetwork } = useChain();

I am getting undefined when try to get chain id web3.givenProvider?.chainId

I’m not able to get chain Id.

function MoralisDappProvider({children}) {
  const {web3, Moralis, user} = useMoralis();
  const [walletAddress, setWalletAddress] = useState();
  const [chainId, setChainId] = useState();
  useEffect(() => {
    Moralis.onChainChanged(function (chain) {
      setChainId(chain);
    });

    // Moralis.onAccountChanged(function (address) {
    //   setWalletAddress(address[0]);
    // });

    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, []);

  useEffect(() => {
    console.log('chain id',web3?.providers?.chainId)
    setChainId(web3.givenProvider?.chainId)
  });
  useMemo(
    () =>
      setWalletAddress(
        web3.givenProvider?.selectedAddress || user?.get('ethAddress'),
      ),
    [web3, user],
  );

  return (
    // USE THIS TO SKIP LOGIN THROUGH WALLET (FOR DEVELOPMENT PURPOSES)
    // <MoralisDappContext.Provider
    //   value={{
    //     walletAddress: '0x29684Ca7D10F82b9dC7E5a447e33e7A99e10813F',
    //     chainId: '0x1',
    //   }}>
    //   {children}
    // </MoralisDappContext.Provider>

    //USE THIS DURING PRODUCTION
    <MoralisDappContext.Provider value={{walletAddress, chainId: '0x1'}}>
      {children}
    </MoralisDappContext.Provider>
  );
}

function useMoralisDapp() {
  const context = React.useContext(MoralisDappContext);
  if (context === undefined) {
    throw new Error('useMoralisDapp must be used within a MoralisDappProvider');
  }
  return context;
}

export {MoralisDappProvider, useMoralisDapp};

Github: https://github.com/ethereum-boilerplate/ethereum-react-native-boilerplate/blob/main/frontend/providers/MoralisDappProvider/MoralisDappProvider.js

how can I get the chain id?

Is this solved? I guess you got the answer in discord.