Ethereum Boilerplate Questions

i want to use moralis-sdk on react-native. But it always give me below error:
TypeError: Cannot read properties of undefined (reading ‘useMoralis’)

You can find my code below:
import { useMoralis } from “react-moralis”;


const { isWeb3Enabled, enableWeb3, isAuthenticated, isWeb3EnableLoading, web3, user, chainId } = useMoralis();
let web3Provider;
if (!isWeb3Enabled) {
web3Provider = await enableWeb3();
const web3Js = new Web3(web3Provider);
}

I have the same error, trying to understand why I get it…

    setIsPending(true);
    const txStatus = await Moralis.transfer(options);
    console.log(txStatus)

    txStatus
      .on("transactionHash", (hash) => {
        openNotification({
          message: "🔊 New Transaction",
          description: `${hash}`,
        });
        console.log("🔊 New Transaction", hash);
      })
      .on("receipt", (receipt) => {
        openNotification({
          message: "📃 New Receipt",
          description: `${receipt.transactionHash}`,
        });
        console.log("🔊 New Receipt: ", receipt);
        setIsPending(false);
      })
      .on("error", (error) => {
        openNotification({
          message: "📃 Error",
          description: `${error.message}`,
        });
        console.error(error);
        setIsPending(false);
      });
  }

Moralis - 1.3.2
React-Moralis - 1.3.1
Server Version - 0.0.347

Hi,

I’m also following the boilerplate for a standard javascript app and when I try to log in/out the user I have an error : “TypeError: e is not a function”. It seems to come from jquery but I don’t understand why I have this while it’s working fine with react.

Anyone face this problem ?

Hello , i am getting this error:

Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:67:19)
at Object.createHash (node:crypto:130:10)
at module.exports (C:\DEV\ethereum-boilerplate\node_modules\webpack\lib\util\createHash.js:135:53)
at NormalModule._initBuildHash (C:\DEV\ethereum-boilerplate\node_modules\webpack\lib\NormalModule.js:417:16)
at handleParseError (C:\DEV\ethereum-boilerplate\node_modules\webpack\lib\NormalModule.js:471:10)
at C:\DEV\ethereum-boilerplate\node_modules\webpack\lib\NormalModule.js:503:5
at C:\DEV\ethereum-boilerplate\node_modules\webpack\lib\NormalModule.js:358:12
at C:\DEV\ethereum-boilerplate\node_modules\loader-runner\lib\LoaderRunner.js:373:3
at iterateNormalLoaders (C:\DEV\ethereum-boilerplate\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
at iterateNormalLoaders (C:\DEV\ethereum-boilerplate\node_modules\loader-runner\lib\LoaderRunner.js:221:10)
C:\DEV\ethereum-boilerplate\node_modules\react-scripts\scripts\start.js:19
throw err;
^

Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:67:19)
at Object.createHash (node:crypto:130:10)
at module.exports (C:\DEV\ethereum-boilerplate\node_modules\webpack\lib\util\createHash.js:135:53)
at NormalModule._initBuildHash (C:\DEV\ethereum-boilerplate\node_modules\webpack\lib\NormalModule.js:417:16)
at C:\DEV\ethereum-boilerplate\node_modules\webpack\lib\NormalModule.js:452:10
at C:\DEV\ethereum-boilerplate\node_modules\webpack\lib\NormalModule.js:323:13
at C:\DEV\ethereum-boilerplate\node_modules\loader-runner\lib\LoaderRunner.js:367:11
at C:\DEV\ethereum-boilerplate\node_modules\loader-runner\lib\LoaderRunner.js:233:18
at context.callback (C:\DEV\ethereum-boilerplate\node_modules\loader-runner\lib\LoaderRunner.js:111:13)
at C:\DEV\ethereum-boilerplate\node_modules\react-scripts\node_modules\babel-loader\lib\index.js:59:103 {
opensslErrorStack: [ ‘error:03000086:digital envelope routines::initialization error’ ],
library: ‘digital envelope routines’,
reason: ‘unsupported’,
code: ‘ERR_OSSL_EVP_UNSUPPORTED’
}

Node.js v17.2.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

for yarn start .

hey, when do you get this error ? is it when you do yarn or when you try to start it ?
and if it is when you try to. do yarn , try it with node v16.13.0

1 Like

See my post in Ethereum React Native Boilerplate Questions

Repeated here:

I found another solution, given in StackOverflow :

I added the following to node_modules\react-scripts\config\webpack.config.js
(i did at line 77…)

const crypto = require("crypto");
const crypto_orig_createHash = crypto.createHash;
crypto.createHash = algorithm => crypto_orig_createHash(algorithm == "md4" ? "sha256" : algorithm);

and then “yarn start” runs without problems

1 Like

https://ethereum-boilerplate.github.io/ethereum-boilerplate/nftBalance I am following this tutorial on youtube https://www.youtube.com/watch?v=WZWCzsB1xUE
However, I can’t seem to find the link to where he got the smartcontract used in the tutorial.
He said he’d drop the link in the description section but didn’t.

Thank you very much for your reply. I have changed the node version and this time it opened the page but it still doesn’t show the platform and it gives me this errors , maybe its something basic but I am really new to this and I appreciate the hellp.

src\hooks\useIPFS.js
Line 1:31: Delete prettier/prettier
Line 2:33: Delete prettier/prettier
Line 3:54: Delete prettier/prettier
Line 4:68: Delete prettier/prettier
Line 5:5: Delete prettier/prettier
Line 6:1: Delete prettier/prettier
Line 7:26: Delete prettier/prettier
Line 8:3: Delete prettier/prettier

src\hooks\useInchDex.js
Line 1:45: Delete prettier/prettier
Line 2:44: Delete prettier/prettier
Line 3:1: Delete prettier/prettier
Line 4:32: Delete prettier/prettier
Line 5:45: Delete prettier/prettier
Line 6:48: Delete prettier/prettier
Line 7:1: Delete prettier/prettier
Line 8:20: Delete prettier/prettier
Line 9:57: Delete prettier/prettier
Line 10:28: Delete prettier/prettier
Line 11:37: Delete prettier/prettier
Line 12:54: Delete prettier/prettier
Line 13:41: Delete prettier/prettier
Line 14:1: Delete prettier/prettier
Line 15:37: Delete prettier/prettier
Line 16:42: Delete prettier/prettier
Line 17:80: Delete prettier/prettier
Line 18:80: Delete prettier/prettier
Line 19:79: Delete prettier/prettier
Line 20:35: Delete prettier/prettier
Line 21:27: Delete prettier/prettier
Line 22:35: Delete prettier/prettier
Line 23:20: Delete prettier/prettier
Line 24:8: Delete prettier/prettier
Line 25:1: Delete prettier/prettier
Line 26:35: Delete prettier/prettier
Line 27:53: Delete prettier/prettier
Line 28:40: Delete prettier/prettier
Line 29:18: Delete prettier/prettier
Line 30:26: Delete prettier/prettier
Line 31:18: Delete prettier/prettier
Line 32:78: Delete prettier/prettier
Line 33:36: Delete prettier/prettier
Line 34:24: Delete prettier/prettier
Line 35:69: Delete prettier/prettier
Line 36:77: Delete prettier/prettier
Line 37:55: Delete prettier/prettier
Line 38:18: Delete prettier/prettier

Thank you.

Try yarn format :raised_hands:

It finally worked thist time :))

but i still can`t see the platform.

Hi

I am doing the JS-DEX course and I installed the boinerplate for my first test project I want to build a react DEX with Wallet using the poilerplate.

I have created a react create app and I just want to copy over the DEX & Wallet from the boilerplate.

Please can someone help understand which files I need to copy over and where so I can give it a go sorry I’m a total newbie.

Hi, I was getting the following errors fresh out of the box after setting up.

Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.
    at AssetSelector

and

Uncaught Error: invalid BigNumber value (argument="value", value=undefined, code=INVALID_ARGUMENT, version=bignumber/5.5.0)

Both only happen in the Wallet component (no errors if I disable wallet component) and only show up when I’ve connected using Metamask (on test networks). Browser window goes blank during such times.

Any help would be appreciated, thanks.

1 Like

what do you mean cedro more details

Were you able to figure something out?
I’ve got the same error.

Dear Ivan, Good morning and with hope you are well i thought to reach you and the team with an open and candid comment, and with hope that you might be able to assist me in addressing something I find rather troubling.

First I want to tell you that for me you personally have been a great inspiration and one of the very first reasons I have ever even stepped foot inside the development space - in defi and in learning everything I possibly could about crypto and block chain in general.

For me, I have followed many of your courses, and watched almost every video youve ever created, yes, needless to say, im a pretty big fan.

To the question I had, I wanted to ask for some help, my latest project involves the Ethereum boilerplate Moralis has developed and i cannot tell you how excited I was to find this among the great tools your team is developing. I jumped straight away into it…

The implementation was straightforward and easily built as really just a few lines of code in visual studio and wala… just like you always said, in just a few lines of code… you too can be a rockstar :).

What I am hoping to find out, if it is at all possible that you guys can offer some simple insight… even the git repository describes the new updated version of the boilerplate, feat. Easy add custom tokens… and to wit there is even a code blurb given on the read me description of the few lines of code you need to implement, in adding your own custom token to the Dex…

Options:

chain (optional): network. Available: Ethereum (“eth”), Binance Smart Chain (“bsc”), Polygon (“polygon”)
customTokens (optional): object with custom tokens. You can see the example below.
<DEX chain="eth" />
// Adding custom tokens

const customTokens = {
  "0x2180F5cC1ddf117640963AE91868948bd3EF6838": {
    address: "0x2180F5cC1ddf117640963AE91868948bd3EF6838",
    decimals: 9,
    logoURI:
      "https://assets.coingecko.com/coins/images/20985/small/_VoQPDDs_400x400.jpg?1638168643",
    name: "AscensionArcade",
    symbol: "AAT",
  },
};

<DEX chain="eth" customTokens={customTokens} />;

However what isnt clear is where is this code supposed to be added, i have read and re read almost every forum thread asking this question and it seems to never be answered, simply left in the hands of a couple of frankenstein hackers who are throwing out all sorts of incomplete and half answers and explanations that have no direction, where in the end only petering off to two guys who seem to have figured it out 90 percent and talking to themselves and about how great they are… but share no solution and leave the question without an answer.

My question is only the product is presented as Feat: Easily add your own custom token, yet there is no explanation on how… and no one seems to answer when asked…

In the end im basically begging for a simple answer as it would be of great help to know whether or not what im trying to achieve is even feasible with the Dex in the boilerplate.

It already misses the most important features a dex would want, ie a search bar to enter a token address and find the token, nor does it allow to set slippage, and in the end… seems that its not easy at all to do what it was supposed to be easy to do to begin with - in adding your custom token to the Dex… In my case im trying to add a newly deployed BSC Token - to the token list - either hard coded to the top or to show up in the list at all… I can already see it when searching for it using the 1inch swap on their site, so it is discoverable and pulls up when searched there, im hoping that i can do something remotely close to it on the dex in this boilerplate.

Please help me guys… I already am a customer and have a moralis server plan and am looking to simply complete this build. I would be honored and thankful for any reply you might offer. With many thanks in advance. and kind regards. Deus.

when i try to list an item on ropsten and mumbai,the approval works fine but the final listing doesnt work,the error message i get in my metamask is that ‘this contract doesnt support this transaction insight at this time’
Also,my moralis dashboard synced to listen to the contract isnt listening to it.
what could be the problem.aside from the moralis dapp provider page,is there any other place i need to paste the contract adress in theboilerplate

@Yomoo is it possible that you might direct me to an answer regarding how to add my token to the ethereum boiler plate dex list of supported tokens. Nay help you can provide that will resolve this based on your most recent git for the boilerplate would be highly appreciated.

Hi there,

Can any one help me with this error, or at least guide me where to look?
Thanks.

1 Like

I updated react, react-moralis and moralis trying to solve a 401 error while fetching NFTs, and I ended up with this:

TypeError: Moralis.onAccountsChanged is not a function
(anonymous function)
src/providers/MoralisDappProvider/MoralisDappProvider.js:14
  11 |   setChainId(chain);
  12 | });
  13 | 
> 14 | Moralis.onAccountsChanged(function (address) {
     | ^  15 |   setWalletAddress(address[0]);
  16 | });
  17 | // eslint-disable-next-line react-hooks/exhaustive-deps

TypeError: Moralis.onAccountsChanged is not a function
(anonymous function)
src/providers/MoralisDappProvider/MoralisDappProvider.js:14
  11 |   setChainId(chain);
  12 | });
  13 | 
> 14 | Moralis.onAccountsChanged(function (address) {
     | ^  15 |   setWalletAddress(address[0]);
  16 | });
  17 | // eslint-disable-next-line react-hooks/exhaustive-deps

Console logs:

./node_modules/magic-sdk/dist/es/index.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
./node_modules/magic-sdk/dist/es/index.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
./node_modules/moralis/lib/browser/Web3Connector/Web3AuthConnector.js
Module not found: Can’t resolve ‘@web3auth/web3auth’ in ‘/home/lautaro/nft/ethereum-boilerplate/node_modules/moralis/lib/browser/Web3Connector’

The post which explains how to solve it isn’t clear about what to do.

I also had an issue with the Wallet. It would crash on me after navigating from one page to another. I looked into it and in my case my native balance and my ERC-20 balance was zero for the wallet I was authenticated with.
So I opened up the AssetSelector to see whether I could edit it.
I added the || 0 as a workaround, seemed to work in my case.

{parseFloat(
Moralis?.Units?.FromWei(item.balance || 0, item.decimals),
)?.toFixed(6)}
1 Like