#Frontend gives errors "can't resolve encoding"

1 messages · Page 1 of 1 (latest)

tulip saddle
#

I have a simple circuit and frontend - mostly just followed tutorials.
In the frontend I try to launch a local blockchain (is it even ok to launch one in the frontend?) just to test things fast, deploy my contract and use it. This is my code:

      const local = Mina.LocalBlockchain({ proofsEnabled: false });
      Mina.setActiveInstance(local);
      let zkAppPrivateKey = PrivateKey.random();
      let zkAppAddress = zkAppPrivateKey.toPublicKey();
      zkAppInstance = new AgeCheck(zkAppAddress);

If the last line is enabled, I get error in the frontend Module not found: Can't resolve 'encoding' in '/home/laurip/src/zk-agecheck/circuits/node_modules/node-fetch/lib'. The circuit works ok in unit tests. Any ideas what could be wrong? I use package o1js version 0.13.1 .

gray raven
#

Hi, what part of your app is failing, the one at the frontend I assume yeah?

gray raven
#

zkAppInstance = new AgeCheck(zkAppAddress); this line is the cause yeah?

tulip saddle
#

yes

peak dagger
#

This does not seem to be closely related to O1js. Also, deploying to berkeley doesn't seem to be related as LocalBlockchain is used here.

I suppose something as simple as npm i -D encoding not going to help? 😄

worthy flare
#

it looks like node-fetch is being used directly, rather than the browser native fetch. this could be an issue with using the node o1js build, not the web build. idk where this happens in your stack. Also it could be a missing node-fetch/fetch polyfill in your build setup, as your build target might not support fetch natively

tulip saddle
#

Hmm npm i -D encoding maybe fixed something, at least it doesn't crash so fast.. now it's just waiting forever. I guess I'll need to move the blockchain instantiation outside the browser and try again

cyan plaza
#

local blockchain should work in the browser

#

o1js doesn't use node-fetch directly internally, just isomorphic-fetch

worthy flare
tulip saddle
#

hmm, interesting. then I'll debug a bit more why it's hanging