I’m currently working on a web extension where I need to access the fhevmInstance. However, I’m encountering an error while calling the initFhevm() function. Below are the error logs I’m facing:
Error Logs
Primary Error Log
Copy code
index.html:6896 TypeError#1: Cannot read properties of undefined (reading 'instantiate')
Stack Trace
Copy code
at B (eval at <anonymous> (eval at makeEvaluate (chrome-extension://ljfoeinjpaedjfecbmggjgodbgkmjkjk/snaps/index.html:6368:27)), <anonymous>:1:253033)
at _Q (eval at <anonymous> (eval at makeEvaluate (chrome-extension://ljfoeinjpaedjfecbmggjgodbgkmjkjk/snaps/index.html:6368:27)), <anonymous>:1:253359)
at AE (eval at <anonymous> (eval at makeEvaluate (chrome-extension://ljfoeinjpaedjfecbmggjgodbgkmjkjk/snaps/index.html:6368:27)), <anonymous>:1:253457)
at Q (eval at <anonymous> (eval at makeEvaluate (chrome-extension://ljfoeinjpaedjfecbmggjgodbgkmjkjk/snaps/index.html:6368:27)), <anonymous>:1:3500910)
at E (eval at <anonymous> (eval at makeEvaluate (chrome-extension://ljfoeinjpaedjfecbmggjgodbgkmjkjk/snaps/index.html:6368:27)), <anonymous>:1:3501017)
at gE (eval at <anonymous> (eval at makeEvaluate (chrome-extension://ljfoeinjpaedjfecbmggjgodbgkmjkjk/snaps/index.html:6368:27)), <anonymous>:1:3501215)
at chrome-extension://ljfoeinjpaedjfecbmggjgodbgkmjkjk/snaps/bundle.js:9:46693
at l.executeInSnapContext (chrome-extension://ljfoeinjpaedjfecbmggjgodbgkmjkjk/snaps/bundle.js:9:51180)
at chrome-extension://ljfoeinjpaedjfecbmggjgodbgkmjkjk/snaps/bundle.js:9:46665
at Object.snapRpc (chrome-extension://ljfoeinjpaedjfecbmggjgodbgkmjkjk/snaps/bundle.js:9:51887)
Using fhevmjs in an extension will be very tricky because fhevmjs is using WASM and webworkers. I don’t think it will be doable out of the box, especially if you’re using Metamask snaps. You can try to use our bundled version which is working totally fine in a website and maybe could work in a extension Build a web application | fhEVM
I noticed that. Now, I tried using the bundled version of fhevmjs, but it’s still not creating any instance. The createInstance method doesn’t seem to return a valid object, and no errors are being thrown, making it challenging to debug.