In short, the useApiContract
hook works good, when my React dapp is run on the localhost through yarn start
, but when the production build is uploaded to IPFS, it doesn’t.
Observed production behaviour:
- I call
useApiContract
hook, passingfuncitonName
,address
,abi
,chain
parameters. - I call the
runContractFunction
inside theuseEffect
hook, which is obtained through the step above. - Both
data
anderror
variables returned by theuseApiContact
hook are null. - Both
isFetching
andisLoading
variables are goingfalse
->true
->false
. - There is no request to the
runContractFunction
in devtools.
Expected production behaviour:
- I expect the hook to work without errors or at least return an error.
In production I see this:
Deployed version is available here https://ipfs.moralis.io:2053/ipfs/QmVzug46jSxrBYj8rRPKuscEpkjXkNJ9UJaWaLzow9hoAT/index.html
Observed localhost behaviour:
- Everything works. The
data
contains the result of the contract call, theerror
is null, the app requestsrunContractFunction
On the localhost i see this:
What exactly I am doing:
- The React dapp complete source code is here https://github.com/custom-app/DAO-Art.eth-access-token
- The
useApiContract
call is here https://github.com/custom-app/DAO-Art.eth-access-token/blob/89a0316284ec1072630aee12fbd235d43500a720/mint-landing/src/pages/main-page/triple-text.tsx#L34 cd mint-landing
yarn install
yarn prepare
-
yarn build
. Moralis app id and server url are passed throughcross-env
in the build command (look at the package.json). - Deploy to the IPFS. I use the same same credentials both to upload to IPFS and to build dapp. Paste the masterKey into the upload script https://github.com/custom-app/DAO-Art.eth-access-token/blob/89a0316284ec1072630aee12fbd235d43500a720/upload-moralis-ipfs/index.js#L8.
- Run the script
cd upload-moralis-ipfs && yarn install && node index.js
.
Please help me solve this issue or suggest, what am i doing wrong .