mirror of
https://github.com/luxfhe/example-dapps.git
synced 2026-10-30 18:13:32 +00:00
A rebrand renamed third-party names it did not own. @luxfhe-fhe/relayer-sdk and @luxfhe-fhe/oracle-solidity were never published, and @fhevm/solidity ships config/ZamaConfig.sol, not LuxConfig.sol, so nothing installed and no contract compiled. The overrides now say what the lockfile already resolved (@zama-fhe/relayer-sdk ^0.3.0-8, @zama-fhe/oracle-solidity ^0.2.0), and the relayer bundle loads from cdn.zama.org, the host that serves it. Co-authored-by: Hanzo Dev <[email protected]>
47 lines
1.9 KiB
Solidity
47 lines
1.9 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity ^0.8.24;
|
|
|
|
import {FHE, euint32, externalEuint32} from "@fhevm/solidity/lib/FHE.sol";
|
|
import {ZamaEthereumConfig} from "@fhevm/solidity/config/ZamaConfig.sol";
|
|
|
|
/// @title A simple FHE counter contract
|
|
/// @author fhevm-hardhat-template
|
|
/// @notice A very basic example contract showing how to work with encrypted data using FHEVM.
|
|
contract FHECounter is ZamaEthereumConfig {
|
|
euint32 private _count;
|
|
|
|
/// @notice Returns the current count
|
|
/// @return The current encrypted count
|
|
function getCount() external view returns (euint32) {
|
|
return _count;
|
|
}
|
|
|
|
/// @notice Increments the counter by a specified encrypted value.
|
|
/// @param inputEuint32 the encrypted input value
|
|
/// @param inputProof the input proof
|
|
/// @dev This example omits overflow/underflow checks for simplicity and readability.
|
|
/// In a production contract, proper range checks should be implemented.
|
|
function increment(externalEuint32 inputEuint32, bytes calldata inputProof) external {
|
|
euint32 encryptedEuint32 = FHE.fromExternal(inputEuint32, inputProof);
|
|
|
|
_count = FHE.add(_count, encryptedEuint32);
|
|
|
|
FHE.allowThis(_count);
|
|
FHE.allow(_count, msg.sender);
|
|
}
|
|
|
|
/// @notice Decrements the counter by a specified encrypted value.
|
|
/// @param inputEuint32 the encrypted input value
|
|
/// @param inputProof the input proof
|
|
/// @dev This example omits overflow/underflow checks for simplicity and readability.
|
|
/// In a production contract, proper range checks should be implemented.
|
|
function decrement(externalEuint32 inputEuint32, bytes calldata inputProof) external {
|
|
euint32 encryptedEuint32 = FHE.fromExternal(inputEuint32, inputProof);
|
|
|
|
_count = FHE.sub(_count, encryptedEuint32);
|
|
|
|
FHE.allowThis(_count);
|
|
FHE.allow(_count, msg.sender);
|
|
}
|
|
}
|