diff --git a/.gitignore b/.gitignore index c770d8d..6aeb24d 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,5 @@ docs/ # Dotenv file .env +# Ignore report.md report.md \ No newline at end of file diff --git a/README.md b/README.md index 07a157b..7955e20 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -### `ElectionOracle` Contract - README +### `ElectionOracle` Contract --- @@ -80,7 +80,6 @@ Example constructor call: ```solidity address oracle = 0x123456789abcdef0123456789abcdef012345678; uint256 minTimestamp = 1730965200; // November 7, 2024, 00:00:00 EST -ElectionOracle oracleContract = new ElectionOracle(oracle, minTimestamp); ``` --- @@ -265,39 +264,3 @@ contract ElectionConsumer { } } ``` - -### Key Features of the Example Contract: - -- **`retrieveFinalResult`**: Fetches the raw election result. -- **`getReadableResult`**: Maps the `ElectionResult` enum to a readable string (e.g., "Trump", "Harris"). - -### Deployment Instructions: - -- Deploy `ElectionOracle` on your network with your chosen oracle and timestamp. -- Use the deployed `ElectionOracle` contract address in your consumer contract when deploying `ElectionConsumer`. - -```solidity -ElectionConsumer consumer = new ElectionConsumer(oracleAddress); -``` - ---- - -## Conclusion - -The `ElectionOracle` contract securely manages and finalizes election results, with strict access control using roles managed by the contract owner. The usage of the contract is transparent, with event emissions and role checks ensuring a robust mechanism for managing election results on the blockchain. - -The provided example consumer contract demonstrates a straightforward way to interface with `ElectionOracle`, making it easy for other contracts to consume and interpret finalized election outcomes. - -Explanation -Enum in the Interface: -The enum ElectionResult is now included in the IElectionOracle interface, which allows any contract implementing or interacting with this interface to understand the possible outcome values. -Usage of Enum: -Methods like retrieveFinalResult and getReadableResult in the ElectionConsumer contract use the ElectionResult enum to fetch and process the result. -Key Points for External Interaction -When you interact with the ElectionOracle contract from another contract (like ElectionConsumer), having the enum defined in the interface ensures that the contract knows about all possible election outcomes. -This approach also avoids any potential issues related to passing integers around without clearly defined meaning, enhancing both security and code clarity. -Deploying and Using the Contracts -Deploy the ElectionOracle contract with the constructor parameters (oracle address and \_minEndOfElectionTimestamp). -Deploy the ElectionConsumer contract using the address of the deployed ElectionOracle contract. -Interact with ElectionConsumer functions to retrieve the results based on the election outcome. -This method provides a clean, maintainable, and secure way to handle the election results, making your smart contracts modular and easy to interact with.