Files
Fuma Nama d6738a228e refactor(fhe): unify API - reveal() replaces getDecryptResult()
- Update to unified FHE decryption API
- Update dependencies to @luxfi/contracts
2025-12-31 21:11:39 -08:00

42 lines
1.3 KiB
TypeScript

import { task } from "hardhat/config";
import type { TaskArguments } from "hardhat/types";
import { ExampleToken } from "../../typechain-types";
task("task:mint")
.addParam("amount", "Amount to transfer (plaintext number)", "1")
.addOptionalParam("to", "Destination address")
.setAction(async function (taskArguments: TaskArguments, hre) {
const { luxfhe, ethers, deployments } = hre;
const [signer] = await ethers.getSigners();
let signerAddress = await signer.getAddress();
const amountToAdd = Number(taskArguments.amount);
let destinationAddress = taskArguments?.to || signerAddress;
const Counter = await deployments.get("ExampleToken");
console.log(
`Running mint(${amountToAdd}), targeting contract at: ${Counter.address}`,
);
console.log(`
Running with account ${signerAddress}
`)
const contract = await ethers.getContractAt("ExampleToken", Counter.address);
const encryptedAmount = await luxfhe.encrypt_uint32(amountToAdd);
let contractWithSigner = contract.connect(signer) as unknown as ExampleToken;
console.time("mintEncrypted");
try {
await contractWithSigner.mintEncrypted(destinationAddress, encryptedAmount);
} catch (e) {
console.log(`mint failed: ${e}`);
return;
}
console.timeEnd("mintEncrypted");
console.log(`Done mint`);
});