πRemix FHE Demo Local Deployment Tutorial- Contracts Explanation&Interaction
Last updated
Last updated
Explanation of Key Components
1. CombinedContract.sol Overview:
β’ This file contains utility contracts, libraries, and a core Oracle contract that facilitates request handling, encryption, and decryption operations using CapsulatedValue.
β’ Ownable Contracts: Ownable and Ownable2Step contracts provide ownership control, ensuring that only the owner can execute certain functions.
β’ Types and Operations: The Types and Opcode libraries define custom types and supported operations for fully homomorphic encryption (FHE) computations.
2. Example.sol Overview:
β’ Oracle Interaction: The Example contract interacts with the Oracle contract to perform secure computations. It uses the RequestBuilder library to create and send requests to the Oracle.
β’ Events: Various events, such as RequestSent, TargetUpdated, and DebugLog, are emitted to provide transparency in operations.
β’ Functions:
β’ createRandomTarget(): Generates a random target value using the Oracle.
β’ randomTargetCallback(): Handles the Oracleβs response and updates the target value.
β’ makeComputation(uint64 amount): Performs a computation on the target and an input amount, then sends a request to the Oracle.
β’ computationCallback(): Processes the result of the computation and updates the target.
Interacting with the Contracts
1. Generate a Random Target:
β’ After deploying Example.sol, use the createRandomTarget() function. This will generate a random target value using the Oracle.
β’ Check the Remix console for emitted events and debug logs.
2. Perform a Computation:
β’ Call makeComputation(uint64 amount) with a specific amount to add to the target.
β’ The Oracle will process the computation, and the result will be available in the computationCallback().
3. View Target Value:
β’ Use the getTarget() function to view the current target value.