Files
zeekay 7b9c11df53 Update @luxfhe packages to latest versions
- @luxfhe/wasm: ^0.2.0
- @luxfhe/kms: ^0.2.0
- @luxfhe/relayer-sdk: ^0.6.0
- @luxfhe/mock-contracts: ^0.6.0
- Remove deprecated Zama dependencies
2026-01-02 10:49:22 -08:00

35 lines
1.2 KiB
TypeScript

import { Counter } from "../typechain-types";
import { task } from "hardhat/config";
import type { TaskArguments } from "hardhat/types";
task("task:addCount")
.addParam("amount", "Amount to add to the counter (plaintext number)", "1")
.setAction(async function (taskArguments: TaskArguments, hre) {
const { luxfhe, ethers, deployments } = hre;
const [signer] = await ethers.getSigners();
if ((await ethers.provider.getBalance(signer.address)).toString() === "0") {
await luxfhe.getFunds(signer.address);
}
const amountToAdd = Number(taskArguments.amount);
const Counter = await deployments.get("Counter");
console.log(`Running addCount(${amountToAdd}), targeting contract at: ${Counter.address}`);
const contract = await ethers.getContractAt("Counter", Counter.address);
const encryptedAmount = await luxfhe.encrypt_uint32(amountToAdd);
const contractWithSigner = contract.connect(signer) as unknown as Counter;
try {
// add() gets `bytes calldata encryptedValue`
// therefore we need to pass in the `data` property
await contractWithSigner.add(encryptedAmount);
} catch (e) {
console.log(`Failed to send add transaction: ${e}`);
return;
}
});