Ethereum React Native Boilerplate Questions

You choose have a table with all the transactions in real time for the addresses that you add to watch or for current users

@cryptokid


i want to send custom token my own to other address where do i add contractaddress ?

Hello, I am unable to even get the boiler plate running successfully.

I am on an Apple M1 machine, I followed all the pertinent steps in the Quickstart guide, and when I attempt to run “react-native run-ios”, I get quite a long error message several seconds into the build process.

The error message is probably too long to post, but the relevant part seems to be:
“fatal error: module map file ‘/Users//Library/Developer/Xcode/DerivedData/EthereumRNBoilerplate-dvlnkxkxpzvrurbrhzcwmgmmgmdb/Build/Products/Debug-iphonesimulator/lottie-ios/Lottie.modulemap’ not found”

react-native info:
System:
OS: macOS 12.2.1
CPU: (8) arm64 Apple M1
Memory: 94.56 MB / 8.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.13.1 - /usr/local/bin/node
Yarn: 1.22.17 - /usr/local/bin/yarn
npm: 8.1.2 - /usr/local/bin/npm
Watchman: Not Found
Managers:
CocoaPods: 1.11.2 - /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 15.4, macOS 12.3, tvOS 15.4, watchOS 8.5
Android SDK: Not Found
IDEs:
Android Studio: Not Found
Xcode: 13.3/13E113 - /usr/bin/xcodebuild
Languages:
Java: Not Found
Python: 3.8.8 - /opt/anaconda3/bin/python
npmPackages:
@react-native-community/cli: Not Found
react: ~17.0.2 => 17.0.2
react-native: ~0.63.3 => 0.63.4
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

Looking around, it seems like there are issues with Apple silicon & react-native that cause things resembling this. But any help would be much appreciated.

Hi, I am simply trying to request Moralis DB from my RN app, following this example.
So my App.tsx has

import { MoralisProvider } from "react-moralis";
import Moralis from "moralis/react-native";
import AsyncStorage from "@react-native-async-storage/async-storage";
Moralis.setAsyncStorage(AsyncStorage);

with

return (
      <SafeAreaProvider>
        <MoralisProvider
          serverUrl="https://xxxx/server"
          appId="xxx"
        >
          <Navigation colorScheme={colorScheme} />
          <StatusBar />
        </MoralisProvider>
      </SafeAreaProvider>
    );

and my component TrackListScreen has

import { useMoralis } from "react-moralis";

with the call

useEffect(() => {
    const EventsNFT = Moralis.Object.extend("EventsNFT");
    const query = new Moralis.Query(EventsNFT);
    query.equalTo("artist", "stormzy");
    const fetchData = async () => {
      const results = await query.find();
      console.log(`Successfully retrieved ${results.length} lines`);
      //setSoundsList(results)
    };
    fetchData().catch(console.error);
  }, []);

Unfortunately I get the below errors triggered in my useEffect() :frowning: any idea what I did wrong?

Can’t find variable: localStorage
at node_modules/moralis/lib/browser/ParseFileEncode.js:45:23 in encodeBase64
at 127.0.0.1:8081/index.bundle?platform=ios&dev=true&hot=false&minify=false:342307:56 in getItemAsync
at 127.0.0.1:8081/index.bundle?platform=ios&dev=true&hot=false&minify=false:328327:42 in currentInstallationId
at node_modules/moralis/lib/browser/RESTController.js:348:6 in request
at node_modules/moralis/lib/browser/ParseQuery.js:793:43 in first.then$argument_0
at components/TrackListScreen.js:69:28 in fetchData
at components/TrackListScreen.js:68:22 in fetchData
at components/TrackListScreen.js:75:13 in useEffect$argument_0

TypeError: undefined is not an object (evaluating ‘EventEmitter.prototype.addListener’)
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:104:6 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:172:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:6 in handleError
at node_modules/expo-dev-launcher/build/DevLauncherErrorManager.js:44:19 in errorHandler
at node_modules/expo-dev-launcher/build/DevLauncherErrorManager.js:49:24 in
at node_modules/expo-error-recovery/build/ErrorRecovery.fx.js:12:21 in ErrorUtils.setGlobalHandler$argument_0

thanks for your help!

it may be to address, you can also try to use Moralis.transfer: https://docs.moralis.io/moralis-server/sending-assets/transfer-tokens

Hi, I get this issue when I try to launch the app on the emulator, following the coinbase clone youtube tutorial. And I did check on that react-native-community folder, and it is missing clipboard. Where can I get this? Thanks!

Hello all,

how can I best display the value of a staking pool?
I have now built something very simple and get an error message
“Compiled with problems:
ERROR in ./src/components/StakeFarm100.jsx 22:6-20
export ‘default’ (imported as ‘useAPIContract’) was not found in ‘hooks/useAPIContract’ (possible exports: useAPIContract)”.

import React, { useState, useEffect } from "react";
import useAPIContract from "hooks/useAPIContract";

function StakeFarmV100() {
    let stakeFarmV100Address = 'CONTRACT DELETET FOR POSTING';
    let stakeFarmV100ABI = 'ABI DELETET FOR POSTING';
    const stakeFarmV100ABIJson = JSON.parse(stakeFarmV100ABI);

    const { runContractFunction, contractResponse, error, isLoading, isFetching } = useAPIContract({
        abi: stakeFarmV100ABIJson,
        address: stakeFarmV100Address,
        functionName: 'pool',
        //chain: 'BSC',
        params: {
        },
    });

    return (
        <div>
            {error && <ErrorMessage error={error} />}
            <button onClick={() => runContractFunction()} disabled={isLoading}>Fetch data</button>
            {contractResponse && JSON.stringify(contractResponse)}

        </div>
    );
}
export default StakeFarmV100;

Moralis.transfer is not opening confirm transaction popup

I’m also facing the same issue

I cloned the react native boilerplate and did yarn install/pod install successfully.
I installed the app on my Samsung S20 plus device, but I am getting an authentication error when press the “Crypto Wallet Login” button. It says "Authentication Error: You need to call Parse.initialize before using Parse."

I already have a Trust Wallet and Metamask app installed on my phone.
I have created a Moralis Testnet Server (I checked Ethereum Ropsten and Polygon) and is running. I have copied and pasted the Server Url and Application Id to my .env file.
I am not sure exactly why it’s failing to authenticate.
Has anyone encountered this issue and how it was fixed?
Thanks.

@adriancabal for Android, try to hard code appId and server url in Providers.tsx file:
serverUrl={"server url here"}
appId={"appId here"}


how to fix ?

1 Like

2 Likes

Hi, i even cannot come to this step, i got error before i go to this step, what should i do

Clone code then set App ID and server URL for moralis in providers file and run app then after click on crypto Wallet login button then get this error

Where can I find my marketplace smart contract address and ABI?

Thanks.

Same error as @Enkoff and @MiteshJabuani

How does one allow only a single network for connection? Say MATIC network for website only, and if user is on ETH then require the user to switch to MATIC.
The boilerplate has a built in chain switching option to allow the user to switch chains, but I cannot find anything that requires the user be on a certain network.
How could this be achieved?

You can basically call this to force user to switch to polygon

    if (chainIds?.[chainId] !== chain)
      return { isActive: false, text: `Switch to Polygonscan` };
1 Like

Great idea I’ll have to use it. Do you happen to know how to make a button that automatically adds or switches the user to the polygon network?
I belive logins are handled with this:

const App = ({ isServerInfo }) => {
  const { isWeb3Enabled, enableWeb3, isAuthenticated, isWeb3EnableLoading } =
    useMoralis();
  useEffect(() => {
    const connectorId = window.localStorage.getItem("connectorId");
    if (isAuthenticated && !isWeb3Enabled && !isWeb3EnableLoading)
      enableWeb3({ provider: connectorId });
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, [isAuthenticated, isWeb3Enabled]);
1 Like