This project is a Solidity smart contract for calculating the area of triangles, rectangles, and squares. The contract is designed to run on the Ethereum blockchain and has been deployed on the Sepolia testnet.
- Project Overview
- Features
- Prerequisites
- Setup and Installation
- Deployment
- Testing
- Usage
- Contributing
- License
The GeometryCalculator
contract provides functions to calculate the area of three basic shapes:
- Triangle: Calculates the area given the base and height.
- Rectangle: Calculates the area given the length and width.
- Square: Calculates the area given the length of one side.
This project uses the Solidity programming language and is developed using the Hardhat framework. The contract has been deployed to the Sepolia testnet using Alchemy.
- Triangle Area Calculation: Given a base and a height, the contract calculates the area of a triangle.
- Rectangle Area Calculation: Given the length and width, the contract calculates the area of a rectangle.
- Square Area Calculation: Given the length of one side, the contract calculates the area of a square.
- Error Handling: Ensures that the input values are greater than zero.
To work with this project, you need to have the following installed:
-
Clone the repository:
git clone https://github.com/DonGuillotine/geometry-calculator.git cd geometry-calculator
-
Install dependencies:
npm install
-
Set up environment variables:
- Create a
.env
file in the root directory and add the following variables:ALCHEMY_API_URL=https://eth-sepolia.alchemyapi.io/v2/YOUR_ALCHEMY_API_KEY PRIVATE_KEY=YOUR_METAMASK_PRIVATE_KEY ETHERSCAN_API_KEY=YOUR_ETHERSCAN_API_KEY
- Replace
YOUR_ALCHEMY_API_KEY
,YOUR_METAMASK_PRIVATE_KEY
andETHERSCAN_API_KEY
with your actual Alchemy API key, MetaMask private key and Etherscan API Key.
- Create a
To deploy the contract to the Sepolia testnet:
-
Compile the contract:
npx hardhat compile
-
Deploy the contract:
npx hardhat run scripts/deploy.js --network sepolia
-
After deployment, the contract address will be displayed in the console.
To run tests for the contract:
-
Run the tests:
npx hardhat test
-
Review the output to ensure all tests pass.
You can interact with the deployed contract using the Hardhat console, Remix IDE, or by building a front-end dApp.
Contributions are welcome! Please fork this repository and submit a pull request with your changes. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License. See the LICENSE file for details.