import { Encryptable, assertCorrectEncryptedItemInput } from '@cofhe/sdk';
import { parseAbi } from 'viem';
import { sepolia } from 'viem/chains';
const encryptedCounterAbi = parseAbi([
'function setCount((uint256 ctHash, uint8 securityZone, uint8 utype, bytes signature) _inCount)',
]);
// 1) Encrypt right before sending the transaction
const [inCount] = await cofheClient
.encryptInputs([Encryptable.uint32(42n)])
.execute();
assertCorrectEncryptedItemInput(inCount);
// 2) Pass the encrypted struct as the InE* argument
const hash = await walletClient.writeContract({
chain: sepolia,
account,
address: encryptedCounterAddress,
abi: encryptedCounterAbi,
functionName: 'setCount',
args: [inCount],
});
await publicClient.waitForTransactionReceipt({ hash });