# Using npmnpminstallfhevmjs# Using Yarnyarnaddfhevmjs# Using pnpmpnpmaddfhevmjs
fhevmjs uses ESM format for web version and commonjs for node version. You need to set the type to "commonjs" in your package.json to load the correct version of fhevmjs. If your node project use "type": "module", you can force the loading of the Node version by using import { createInstance } from 'fhevmjs/node';
Create an instance
const { createInstance,getPublicKeyCallParams } =require("fhevmjs");const { ethers,JsonRpcProvider } =require("ethers");constprovider=newJsonRpcProvider(`https://devnet.zama.ai/`);constcreateFhevmInstance=async () => {// 1. Get the chain idconstnetwork=awaitprovider.getNetwork();constchainId=+network.chainId.toString();// 2. Fetch the FHE public key from the blockchainconstret=awaitprovider.call(getPublicKeyCallParams());constdecoded=ethers.AbiCoder.defaultAbiCoder().decode(["bytes"], ret);constpublicKey= decoded[0];// 3. Create the instancereturncreateInstance({ chainId, publicKey });};createFhevmInstance().then((instance) => {console.log(instance);});