Ethereum React Native Boilerplate Questions

Hey @malik & @gen are there issue with the react native logins not showing up in the Moralis dashboard? I am trying to authentice sessions so I don’t have to login in each time. But the issue is that every time I login via MetaMask, the Session’s table is not populated with the new session for my emulated device. However, when I played around with the Connect to the SDK project, my login for both email and wallet logins show up. Thanks again!

Hi Sorry to bother you. please help me.
We use Moralis for our project. we tried this function(runContractFunction). It works for us on Javascript.
https://docs.moralis.io/moralis-server/web3-sdk/native

And then, we tried it on typescript, but it does not work. It seems the types of ABI is not defined.
It is difficult for us to define type of ABI in this moralis. please tell me the way or document to use runContractFunction on typescript.
We often use web3.js, ether.js and useDapps, but we want to use Moralis this time.

Best regards.

Hello.

I am using the visual studio code on windows 10

I am on the section > ( Boilerplate Quick Start Walkthrough)

I am trying to clone the boilerplate git but get the below error. Why is this?

Just a quick question. How easy is the boilerplate dex to add a small extra fee for your platform? I know this was possible when using the 1inch API but is it supported via the plugin?

You have to use the git command.

git clone ethereum-boilerplate/ethereum-react-native-boilerplate

I will investigate this and come to you. Sessions are handled a little differently on mobile because of local storage and wallet connect integration. Ideally, they should show up in the table. I will get back to you on this one.

@MarkyMarx Is this related to react native specifically? BEcause this thread revolves around only react native.

Hi I am trying to create a react-native app using Moralis. I am using just a standard iPhone emulator for testing purposes. When utilizing the WalletConnect it is properly displaying all the wallets you can sign in with however when I click on for example MetaMask it just opens safari and I cannot connect a wallet. My question is essentially how do you connect a wallet for testing purposes using an emulated iPhone?

Hello Malik,

Thanks for your response.
Here the adresse that I want to display all the NFT images : 0x0d8acbdd88ec12165611d016bbef96960db8d42c.
I guess i will have to call the opensea API to display the images.

We cannot connect with wallet apps on a device emulator since you don’t have these apps installed in the emulator. You can skip the login by providing the hardcoded address for development purposes by changing line 30 in the MoralisDappProvider.js file as such –

<MoralisDappContext.Provider
      value={{
        walletAddress: "0x71a11bc477048cca56d645ffc66ca762f62d1c3c",
        chainId: "0x1",
      }}>
      {children}
    </MoralisDappContext.Provider>
1 Like

Looks like there are many NFTs in the wallet. I tested a few with their metadata URL IPFS links and they seem to be working. Tested these-

https://ipfs.io/ipfs/QmNZDpkfZxmmocU7VfrebQS1Gx7TBtF6MFm7jgk73wqXNN
https://ipfs.io/ipfs/QmWD4RoZ6YsB8sCbmpj16sdEVQBY4KpC8URMwg6RPG6vTg\
https://ipfs.io/ipfs/QmNwd6Lqxz2R9tDmApVGW9K4cP6WPvLCucjGsghnkfkAmq/740.png

Also, since these questions are not specific to React native I would suggest you start a new thread to discuss this further.

I wanted to run the app using expo start command. When I scan the barcode it opens my expo app successfully but then it is just stuck at the ethereum logo screen like so. Does anyone know why this is happening/how to fix it to run the proper flow of the app?

Please do not use expo to run the app. Follow the instructions in the Quick start guide in github. We will soon be pushing a change where we get rid of expo completely because of its inconsistent behaviour.

How do you find the android folder from source code in android studio?

I see on android studio that we could open (new project), (VCS), or (open).

I see in the (open) option under my folder i made for this app there is an android option (with the android symbol).

Do we choose that?

Or do we choose the other android option (which does not have the android symbol/logo showing)
NOTE: i can only embedd one image at the moment so I cant show that picture yet)

If I am way off target then I am lost as to how to open an adrodi folder from source code in the android studio.

The getNFTsForContract (I modified the useNFTBalance hook because I just needed NFTs of a given contract, not all) is giving me an incorrect number of NFTs, with some repeated.
It was working fine a couple days ago but then started giving 3 when there were 2, and now I have 5 real NFTs, it gives me 8… What’s going on?

[
    {
        "token_address": "0xe10f3580f4c1b9f88a8fbbea562622f1cf255423",
        "token_id": "2",
        "block_number_minted": "15106120",
        "owner_of": "0x737bffc0e88285a87490f4f8124e5d32fbe6fd82",
        "block_number": "15106120",
        "amount": "1",
        "contract_type": "ERC721",
        "name": "MonsterWorldNFT",
        "symbol": "MWD-NFT",
        "token_uri": null,
        "metadata": null,
        "synced_at": null,
        "is_valid": 0,
        "syncing": 1,
        "frozen": 0
    },
    {
        "token_address": "0x5b2518f041319fda578417a278c1bffe56a19c67",
        "token_id": "1",
        "block_number_minted": "15042289",
        "owner_of": "0x737bffc0e88285a87490f4f8124e5d32fbe6fd82",
        "block_number": "15042289",
        "amount": "1",
        "contract_type": "ERC721",
        "name": "MonsterWorldNFT",
        "symbol": "MWD-NFT",
        "token_uri": null,
        "metadata": null,
        "synced_at": null,
        "is_valid": 0,
        "syncing": 1,
        "frozen": 0
    },
    {
        "token_address": "0x9de0f123e228276a9ee486847512fad0fd2727eb",
        "token_id": "0",
        "block_number_minted": "15015235",
        "owner_of": "0x737bffc0e88285a87490f4f8124e5d32fbe6fd82",
        "block_number": "15015235",
        "amount": "1",
        "contract_type": "ERC721",
        "name": "MonsterWorldNFT",
        "symbol": "MWD-NFT",
        "token_uri": null,
        "metadata": null,
        "synced_at": null,
        "is_valid": 0,
        "syncing": 1,
        "frozen": 0
    },
    {
        "token_address": "0xe10f3580f4c1b9f88a8fbbea562622f1cf255423",
        "token_id": "0",
        "block_number_minted": "15106092",
        "owner_of": "0x737bffc0e88285a87490f4f8124e5d32fbe6fd82",
        "block_number": "15106092",
        "amount": "1",
        "contract_type": "ERC721",
        "name": "MonsterWorldNFT",
        "symbol": "MWD-NFT",
        "token_uri": null,
        "metadata": null,
        "synced_at": null,
        "is_valid": 0,
        "syncing": 1,
        "frozen": 0
    },
    {
        "token_address": "0xe10f3580f4c1b9f88a8fbbea562622f1cf255423",
        "token_id": "4",
        "block_number_minted": "15106155",
        "owner_of": "0x737bffc0e88285a87490f4f8124e5d32fbe6fd82",
        "block_number": "15106155",
        "amount": "1",
        "contract_type": "ERC721",
        "name": "MonsterWorldNFT",
        "symbol": "MWD-NFT",
        "token_uri": null,
        "metadata": null,
        "synced_at": null,
        "is_valid": 0,
        "syncing": 1,
        "frozen": 0
    },
    {
        "token_address": "0xe10f3580f4c1b9f88a8fbbea562622f1cf255423",
        "token_id": "3",
        "block_number_minted": "15106145",
        "owner_of": "0x737bffc0e88285a87490f4f8124e5d32fbe6fd82",
        "block_number": "15106145",
        "amount": "1",
        "contract_type": "ERC721",
        "name": "MonsterWorldNFT",
        "symbol": "MWD-NFT",
        "token_uri": null,
        "metadata": null,
        "synced_at": null,
        "is_valid": 0,
        "syncing": 1,
        "frozen": 0
    },
    {
        "token_address": "0xe10f3580f4c1b9f88a8fbbea562622f1cf255423",
        "token_id": "1",
        "block_number_minted": "15106110",
        "owner_of": "0x737bffc0e88285a87490f4f8124e5d32fbe6fd82",
        "block_number": "15106110",
        "amount": "1",
        "contract_type": "ERC721",
        "name": "MonsterWorldNFT",
        "symbol": "MWD-NFT",
        "token_uri": null,
        "metadata": null,
        "synced_at": null,
        "is_valid": 0,
        "syncing": 1,
        "frozen": 0
    },
    {
        "token_address": "0x5b2518f041319fda578417a278c1bffe56a19c67",
        "token_id": "0",
        "block_number_minted": "15042287",
        "owner_of": "0x737bffc0e88285a87490f4f8124e5d32fbe6fd82",
        "block_number": "15042287",
        "amount": "1",
        "contract_type": "ERC721",
        "name": "MonsterWorldNFT",
        "symbol": "MWD-NFT",
        "token_uri": null,
        "metadata": null,
        "synced_at": null,
        "is_valid": 0,
        "syncing": 1,
        "frozen": 0
    }
]

The opened tabs at the top almost gave me an anxiety attack

1 Like

The folder structure that you showed above is right. The android folder from the source code is to be opened.

This thread is for React Native specific issues. Let’s start another thread to track this NFT issue and figure out what’s going on.

I solved it, it was something dumb: The component was calling a “NFTBalances”, with an s at the end (no idea where that hook came from, it’s not on the hooks folder), which used getNFTs, instead of NFTBalance, which was the one I intended (although it isn’t in the GitHub anymore, was it removed?).

Hey @malik not sure what changed, but now my user logins are appearing in the table. Thank you very much! And I saw that Moralis is going to phase out expo from the repo, why is that? I find expo extremely useful for deploying MVPs.

On a side note, is there an example on how to properly take care of user sessions on mobile? I know this is unrelated to react-native, but since I figure it has to do with hooks it was worth asking here.
This is what I am doing in LoginScreen.handleCryptoLogin():

    const currentUser = Moralis.User.current();
    if (currentUser) {
      const userSession = currentUser.getSessionToken();
      const query = new Moralis.Query(Moralis.Session);
      query.equalTo("sessionToken", userSession);
      query.find()
        .then( function (results) {
          console.log("User session authenticated with: ", results[0]);
          navigation.replace("DrawerNavigationRoutes");
        })
        .catch( (error) => {
          console.warn("error user sessions query: ", error);
        });
    } else {
      console.log("currentUser: ", currentUser);
    }

But after going to the Assets screen via DrawerNavigationRoutes, I get a bunch of error alerts. I am guessing it’s because I did not properly authenticate the current user and the hooks are missing information. I see that both the currentUser and the User object from the queried Session have the same objectId. Do I have to do something like Setting the Current User? Any help would be much appreciated, thanks again!

Thank you for the reply. So you are saying the source code is in that folder? I see a few options to choose from when i click that folder with the adroid symbol. Which one do I choose?