Ethereum React Native Boilerplate Questions

oh wow! Many thanks! :clap:

1 Like

Hey,
I am using ethereum-react-native-boilerplate and I’m trying to execute a smart contract transaction using useWeb3Contract hook. Since there is no way to upgrade ‘react-moralis’ because my code will break Crypto authentication immediately I stayed at version 0.2.7 so authentication works fine via WalletConnect and MetaMask.
I integrated the needed functionality for the hook and it finally pops up my metamask wallet fine when invoking the live smart contract function on kovan network, however it does not pop up the window to sign the transaction when runContractFunction is invoked.
It pops up the wallet but the wallet doesn’t show anything. Please support me with this issue!

const { runContractFunction, contractResponse, error, isRunning, isLoading } = useWeb3Contract({
        abi: geoCoordinate.abi,
        contractAddress: "0xCA01EFc1a2E9FE009C0DEC4A2F774aa050fFd0D9",
        functionName: "storeGeoCoordinate",
        params: {
            lat: "40.730610",
            long: "-73.935242"
        },
      });
1 Like

Invoking with runContractFunction contract call through Web3Api works fine from my mobile (I get back the correct result values), but for transaction it does not do anything, although my contract, and function are fine, and can be invoked through metamask in remix.

const options = {
          chain: "kovan",
         address: "0xCA01EFc1a2E9FE009C0DEC4A2F774aa050fFd0D9",
         function_name: "getGeoCoordinates",
        abi: geoCoordinate.abi
      };

const result = await Moralis.Web3API.native.runContractFunction(options)

Please help me to resolve metamask pop up issue for transactions, I am not able to sign it

After cloning the Ethereum-react-native-boilerplate project I am facing an issue. In App everything is working fine but every time I open my app it requires me to authenticate
it’s not maintaining the session in app.below code is splash screen code which always go to Auth whenever I open my application.
AsyncStorage.getItem(“user_id”).then((value) =>
navigation.replace(value === null ? “Auth” : “DrawerNavigationRoutes”)
);
On the other hand, session is maintained in metamask

1 Like

@Raheel please try removing the splashscreen from <Stack.Screen/> as I remember adding it manually to Xcode and Android Studio before. I already made a PR for removing it but you can also try doing it on your end and let us know if it made any changes. Thanks!

problem is still after open app again isAuthenticated is also coming false.

2 Likes

Hi,
I am trying to use this boilerplate and Moralis helper hooks/component to connect to the binance smart chain testnet, when I use Moralis server bsc testnet login works fine but my balances are all zero. When I use the web3 library with a speedy node testnet bsc, everything works fine with the psuedo code below

 const testnet = 'https://speedy-nodes-nyc.moralis.io...';
    const walletAddress = 'SOMEBSCWALLEt';

    const web3 = new Web3(new Web3.providers.HttpProvider(testnet));
    web3.eth.getBalance(walletAddress).then((balance) => {
      setValue(web3.utils.fromWei(balance, 'ether'))
    }); 
    const contract = new web3.eth.Contract(minABI,tokenAddress);
    contract.methods.balanceOf(walletAddress).call().then((balance) => {
      setRunValue(web3.utils.fromWei(balance, 'ether'))
});

If I use the chain id I use for metamask - like 97 - I get invalid chainId. Is there anything I can configure to get it working? I find bsc cheaper to build and deploy on. I want my dApp users to pay little to no transaction fees.

Anyone have a solution for this? Perhaps we just need to cache the creds in async storage ourselves?

I had the wrong chainId - simply looked at bsc docs and found the hex version https://docs.binance.org/smart-chain/developer/rpc.html#testnetchainid-0x61-97-in-decimal

2 Likes

Hi everyone,

Has anyone updated latest version moralis and react-moralis?

can the react native boilerplate be like this , can it contain dex and flat
pls can you make the boilerplate like the browser own

i tried to do dex and flat but don’t now how

@fatih01 we are making efforts to upgrade all dependencies of this boilerplate including moralis and react-moralis. Will be posting and update once it’s ready :slight_smile:

1 Like

Is there anyone who was able to overcome the transaction sign - pop up issue already on mobile, using react-native boilerplate after successful crypto login?
I am trying to create a simple smart contract transaction that modifies the state: overrides string values and it is impossible to get walletconnect into action…
Metamask comes in without the transaction pop up, so I am not able to sign it on mobile.
I get the following error:
Failed to open url: https://metamask.app.link: Error - The request to open com.apple.mobilesafari failed
At this point I think I tried everything, even tried connecting through web3 instance directly, Moralis.executeFunction, as I am using the boilerplate version of react-moralis: 0.2.7.
Simple contract call works fine, but not the transaction that modifies the state.
I tried enableViaWalletConnect - my walletConnect connector is fine, and connected, returning the default account, but no transaction popup for a simple smart contract transaction.
I just cannot imagine how this thing pops up for signing the transaction when crypto authentication occurs…
If someone was able to get it work please help me out!

Hi, now opens wallet app but when I get back to the app it doesn’t seem to be connected! same connect to wallet screen.

@sandormaraczy can you paste a screenshot of your code here? Thanks!

@iPictorial can you send a screenshot of your code and a short recording of it’s behavior in the app? thanks!

Hi, thank you for looking into it.
Here is the code below I am using currently.
The contract is working fine when invoked through remix.
The “submitLocationData” is invoked on button press and opens MetaMask immediately on my mobile like by the crypto auth flow, but no transaction popup appears, just hangs there.

import { useWeb3Contract } from '../hooks/web3Contract/useWeb3Contract'
import { useMoralis } from 'react-moralis';
import { useWalletConnect } from '../WalletConnect';
import { enableViaWalletConnect } from '../Moralis/enableViaWalletConnect';

const geoCoordinate = {
"abi": [
    {
        "inputs": [],
        "name": "geoCoordinate",
        "outputs": [
            {
                "internalType": "string",
                "name": "latitude",
                "type": "string"
            },
            {
                "internalType": "string",
                "name": "longitude",
                "type": "string"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [],
        "name": "getGeoCoordinates",
        "outputs": [
            {
                "internalType": "string",
                "name": "",
                "type": "string"
            },
            {
                "internalType": "string",
                "name": "",
                "type": "string"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "string",
                "name": "lat",
                "type": "string"
            },
            {
                "internalType": "string",
                "name": "long",
                "type": "string"
            }
        ],
        "name": "storeGeoCoordinate",
        "outputs": [],
        "stateMutability": "nonpayable",
        "type": "function"
    }
]}

 const submitLocationData = async () => {
        // const web3 = await enableViaWalletConnect(connector)
       // await Moralis.enableWeb3({provider: 'walletconnect'})
        
        const sendOptions = {
            contractAddress: "0xCA01EFc1a2E9FE009C0DEC4A2F774aa050fFd0D9",
            functionName: "storeGeoCoordinate",
            abi: geoCoordinate.abi,
            params: {lat: "40.730610", long: "-73.935242"}
        };

        const transaction = await Moralis.executeFunction(sendOptions);
        transaction.on("transactionHash", (hash) => { console.log(hash) })

        //console.log("connector: " + connector.accounts)
        //web3.setProvider(connector)
        //console.log("provider: " + web3.givenProvider)
        //console.log("contract: " + contract)
        //const contract = new web3.eth.Contract(geoCoordinate.abi, "0xCA01EFc1a2E9FE009C0DEC4A2F774aa050fFd0D9")
        //const result = await contract.methods.storeGeoCoordinate('10', '20').send({from: connector.accounts[0]})
        //.on('receipt', () => {
        //    console.log("receipt!!")
        //})

Hi guys,

Moralis transfer doesn’t work
Sending ETH, Tokens and NFTs
myOptions {"amount": "5000000000000000", "receiver": "0xF37302Bd80fCF6CD38C715d7aDa579f8a5d75A27", "type": "native"}

Wallet opens but nothing happens.
I tested it on android.
Has anyone been able to do it before?

The same for me on mobile, on iOS, wallet opens, but no popup for the transaction to be signed, the only difference is that in my case it is a contract invocation.
I would also like to find out if this ever worked for someone on mobile!

@sandormaraczy @fatih01 I’m already looking into this issue with transactions popups. Thank you for bearing with us. :slight_smile:

2 Likes