RizeLabs / Sample-Hardhat-Template

0 stars 0 forks source link

Creating fhevm js instance with chainid causes error #1

Closed Abhay-2811 closed 1 month ago

Abhay-2811 commented 2 months ago

With chain id

Code:

const { createInstance } = require("fhevmjs");

const createFhevmInstance = async () => {
  return createInstance({
    chainId: 9000,
    networkUrl: "https://rpc.encifher.io",
    gatewayUrl: "https://gateway.rpc.encifher.io",
  });
};
createFhevmInstance().then((instance) => {
  console.log(instance);
});

Error:

/Users/abhay/rize/encifher/signet-test-node/node_modules/fhevmjs/lib/node.cjs:179
        throw new Error('Impossible to fetch public key from network (wrong url?)');
              ^

Error: Impossible to fetch public key from network (wrong url?)
    at getPublicKeyFromNetwork (/Users/abhay/rize/encifher/signet-test-node/node_modules/fhevmjs/lib/node.cjs:179:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async createInstance (/Users/abhay/rize/encifher/signet-test-node/node_modules/fhevmjs/lib/node.cjs:2756:21)

Node.js v20.0.0

Without Chain id

Code:

const { createInstance } = require("fhevmjs");

const createFhevmInstance = async () => {
  return createInstance({
    networkUrl: "https://rpc.encifher.io",
    gatewayUrl: "https://gateway.rpc.encifher.io",
  });
};
createFhevmInstance().then((instance) => {
  console.log(instance);
});

Output:

{
  createEncryptedInput: [Function (anonymous)],
  generateKeypair: [Function: generateKeypair],
  createEIP712: [Function (anonymous)],
  reencrypt: [AsyncFunction (anonymous)],
  getPublicKey: [Function: getPublicKey]
}
nlok5923 commented 1 month ago

Sporadic error!