Ethereum Boilerplate Questions

I can appreciate that, good luck to you with your learning.

How come when on the /1inch page on the boilerplate, if I hit refresh or hit enter on the path in the address bar I get “chain null chain.jsx:91” in the console? and the tokenlist or modal window are not populated? seems to only happen to the first tab in the DEX component. or if I move the dex to the quickstart page, on first load the first tab “ethereum” is unpopulated aswell as it’s modal window.

if I add another tab infront of “ethereum” with some random content in it and make it the default showing tab, then click on the ethereum tab it populates fine.

I get “chain null chain.jsx:91” in the console

This is fine, this Chains component just logs chain from useChain() even before it has a valid value.

and the tokenlist or modal window are not populated? seems to only happen to the first tab in the DEX component

This is an issue with the useInchDex hook (hooks/useInchDex.js), what you can do is change the current useEffect at the top to:

const { Moralis, account, isInitialized } = useMoralis();

...

useEffect(() => {
  async function run() {
    await Moralis.initPlugins();
    Moralis.Plugins.oneInch
      .getSupportedTokens({ chain })
      .then((tokens) => setTokenlist(tokens.tokens));
  }

  if (isInitialized) run();
}, [isInitialized]);

Awesome thanks Glad! I just had to modify the dependency array a bit to get it working properly.

[Moralis, chain, isInitialized]

1 Like

why NFT Assets not appearing in react native application… after connected my metamask test network wallet in my application… its always loading only…

Hello can you post in this thread with answers to these questions - do you get any console errors and have you verified with the Moralis API that your wallet address has NFT results for the testnet that you’re using?

I have bbeen testing the eth-boilerplate for a cpl weeks now and so far I really like it. However, I recently upgraded the react-moralis packages to latest version and can no longer display chains or logged user account address on frontend.

Has anyone else had this problem? If i downgrade the network selector works. What changes do I need to make? Any help is greatly appreciated. Thank you. =)

Hi!

I have a problem calling contract functions from the browser using useWeb3Contract, essentailly the code doesnt break anything but does not run either when invoking through a button with an onClick:

export default function CreateMatch() {
    const { Moralis, isWeb3Enabled, chainId: chainIdHex } = useMoralis()
    const chainId = parseInt(chainIdHex)
    const universalContractAddress = chainId in contractAddresses ? contractAddresses[chainId][0] : null

    const eventOptions = {
        abi: abiEvent,
        contractAddress: universalContractAddress,
        functionName: "createMatch",
        params: {
            teamName1, teamName2, teamName3, eventDate, matchPlace, matchFinished, matchBets},
    };

    const { runContractFunction, isFetching, isLoading } =
        useWeb3Contract();
    const { runContractFunction: createMatch } = useWeb3Contract();
    return (
            <div>
                <button
                    onClick={() => runContractFunction({ params: eventOptions })}
                    disabled={isFetching}
                >
                    CreateMatch
                </button>
            </div>
    )
}

and the contract it is calling:


contract Event {
    uint256 public matchCount = 0;
    mapping(uint => Match) public matches;
    struct Match {
        uint256 matchId;
        string homeTeam;
        string awayTeam;
        string drawTeam;
        string matchDate;
        string place;
        bool finished;
        address[] userList;
    }
    function createMatch(
        string memory homeTeam,
        string memory awayTeam,
        string memory drawTeam,
        string memory matchDate,
        string memory place,
        bool finished,
        address[] memory userList
    ) public {
        matches[matchCount] = Match(
            matchCount,
            homeTeam,
            awayTeam,
            drawTeam,
            matchDate,
            place,
            finished,
            userList
        );
        matchCount++;
    }
}

Why is my code not opening up metamask to deduct the gas cost and run the contract function?

You may just have to keep using the older version or try different versions that don’t break things. That is strange though as a user (and myself) had a similar issue to yours with the dropdown chain selector but upgrading the react-moralis version fixed it.

The eventOptions should just be passed in as an object without params e.g. useWeb3Contract(eventOptions). You can check out the docs.

did exactly according to the documentation, still transaction was not tracking on front-end.
turned out that the parameters i was sending were not getting picked up by the call. thanks for you help

Yes, i have had similar issues with the chain selector as well. Intermittent issues displaying wallet address post-authentication. You can see what I am working on here - moralis rinkeby project on heroku

Are you able to share a repo? Everything seems fine with that deploy if I connect my wallet to it - wallet displays fine, chain selector works.

Hey, my Dapp is running but the swap isnt working. I can fetch the token symbols but when I press Swap nothing happens. Any Idea what the issue is ? Pictures are attached please have a look. Naga Swap - Dex

Do you have the latest version of the 1inch plugin installed? Error says address hasn’t been provided, have you made changes to the DEX/Swap component? Which chain is this for (your screenshot shows you’re not authenticated/not on Ethereum.

Yes I have 0.31 installed. I took out the nft stuff but didn’t temper with the swap component.

The latest version is 0.0.33, you can update it from your server > Plugins tab. If you still have issues you can share a repo of your project.

Don’t know what my issue is at this point. Is it because i"m using js with jsx or my dapp is not connected to moralis token_img won’t display
what I did I remove the head part of the index.html and used react.fragment i can’t get the tokens symbol icons to show. my website project is http://dessalines.io

This component uses 1inch plugin. Does your moralis server have 1inch plugin installed?

yes it’s installed but no tokens showing up. this reference to id="from_token_img should get the image from oneinch?