I used following javascript
const provider = new JsonRpcProvider(`https://testnet.inco.org`);
const FHE_LIB_ADDRESS = "0x000000000000000000000000000000000000005d";
const network = await provider.getNetwork();
const chainId = +network.chainId.toString();
const ret = await provider.call({
to: FHE_LIB_ADDRESS,
data: "0xd9d47bb001",
});
const decoded = AbiCoder.defaultAbiCoder().decode(["bytes"], ret);
const publicKey = decoded[0];
instance = await createInstance({ chainId, publicKey });
console.log("FHE instance created", instance);
const encryptedVoteFor00001111 = instance.encrypt8(15);
and get the error:
RuntimeError: unreachable
at null.<anonymous> (wasm://wasm/002d022a:1:590648)
at null.<anonymous> (wasm://wasm/002d022a:1:672482)
at null.<anonymous> (wasm://wasm/002d022a:1:654419)
at null.<anonymous> (wasm://wasm/002d022a:1:294611)
at Function.encrypt_with_compact_public_key (node_modules/node-tfhe/tfhe.js:4006:18)
at encrypt8 (node_modules/fhevmjs/lib/node.cjs:63:50)
at Object.encrypt8 (node_modules/fhevmjs/lib/node.cjs:193:36)
at Context.<anonymous> (test/keynsianBeautyContest_test.js:39:49)
at processImmediate (node:internal/timers:478:21)
Hello,
If you use the INCO’s testnet, you need to use the prerelease of fhevmjs. INCO’s network use the one of our prerelease which is only compatible with fhevmjs v0.4.0-3 Release v0.4.0-3 · zama-ai/fhevmjs · GitHub
Also, for your contract, you need to use fhevm v0.4.0-0 explicitly.
To install these packages:
In your web/node project:
npm install fhevmjs@0.4.0-3
In your hardhat project:
npm install fhevm@0.4.0-0
Note: INCO’s network is probably not compatible with latest prerelease of fhevm AND fhevmjs. Try to keep on the version mentioned above.
Note2: We plan to release everything at the end of the month, and INCO’s will probably also update their testnet during this period.
1 Like
Thanks, now it works. curious why specifically targeting fhevmjs@0.4.0-3
, it’s understandable that fhevmjs is not backward compatible, could you please tell me for any reason why it’s not forward compatible?
Our previous stack relied on tfhe-rs 0.4.x while our newer stack relies on the latest version, 0.5.x. It’s possible to migrate data from 0.4.x to 0.5.x (as mentioned here https://docs.zama.ai/tfhe-rs/how-to/migrate_data) but you can’t load a public key issued by tfhe-rs 0.4.x into a tfhe-rs 0.5.x instance.
In addition, for my test script
before(async () => {
const provider = new JsonRpcProvider(`https://testnet.inco.org`);
const FHE_LIB_ADDRESS = "0x000000000000000000000000000000000000005d";
const network = await provider.getNetwork();
const chainId = +network.chainId.toString();
const ret = await provider.call({
to: FHE_LIB_ADDRESS,
data: "0xd9d47bb001",
});
const decoded = AbiCoder.defaultAbiCoder().decode(["bytes"], ret);
const publicKey = decoded[0];
instance = await createInstance({ chainId, publicKey });
console.log("FHE instance created", instance);
keynesianBeautyContest = await KeynsianBeautyContest.new({ from: deployer });
//keynesianBeautyContest = await KeynsianBeautyContest.at('0x22cEe6ffECE58f7DE72B424Ac7e1453796dc33F4'); // Passed CONTRACT ADDRESS
console.log("KeynesianBeautyContest deployed at", keynesianBeautyContest.address);
});
If I use fhevm@0.4.0-0
, the contract deployment will timeout, but if I use fhevm@0.3.0
, everything works fine, the reason why I find out this is because when I depploy contract on remix, the deployment is fine, and remix is referencing fhevm@0.3.0
.
I keep this record for those who get confused in the future.
Hi there, im using Inco testnet too but im encountering this problem:
./node_modules/fhevmjs/lib/web.js:7344:0
Module not found: Can't resolve 'tfhe_bg.wasm'
https://nextjs.org/docs/messages/module-not-found
Import trace for requested module:
./src/utils/fhevm.js
./pages/join/[id].tsx
Although I tried updating the webpack:
const path = require('path');
module.exports = {
// entry: './src/index.js',
// output: {
// filename: 'main.js',
// path: path.resolve(__dirname, 'dist'),
// },
// module: {
// rules: [
// {
// test: /\.tsx?$/,
// use: 'ts-loader',
// exclude: /node_modules/,
// },
// ],
// },
resolve: {
// extensions: ['.tsx', '.ts', '.js'],
fallback: {
'tfhe_bg.wasm': require.resolve('tfhe/tfhe_bg.wasm'),
},
},
};
i still has the error though… any ideas about how to solve it?
the tech stack im using is nextjs w/ node v18.12.1