mirror of
https://github.com/luxfhe/example-fhe-voting.git
synced 2026-10-30 18:13:24 +00:00
25 lines
615 B
TypeScript
25 lines
615 B
TypeScript
import { fhe } from "@luxfhe/sdk/node";
|
|
import { HardhatRuntimeEnvironment } from "hardhat/types/runtime";
|
|
|
|
import { waitForBlock } from "./block";
|
|
|
|
export interface FheContract {
|
|
initialized: boolean;
|
|
}
|
|
|
|
export async function createFheInstance(hre: HardhatRuntimeEnvironment, contractAddress: string): Promise<FheContract> {
|
|
const { ethers } = hre;
|
|
|
|
// workaround for call not working the first time on a fresh chain
|
|
try {
|
|
await ethers.provider.getBlockNumber();
|
|
} catch (_) {
|
|
await waitForBlock(hre);
|
|
}
|
|
|
|
// Initialize the FHE SDK
|
|
await fhe.initialize();
|
|
|
|
return { initialized: true };
|
|
}
|