The Calculadora smart contract provides basic arithmetic operations directly on the Ethereum blockchain. This contract allows users to add, subtract, multiply, divide, and calculate percentages securely and transparently.
Designed in Solidity 0.8.24, it includes built-in checks to prevent invalid operations and ensures smooth execution.
โ๏ธ Supports basic mathematical operations:
- โ Addition
- โ Subtraction
- โ๏ธ Multiplication
- โ Division
- ๐ Percentage Calculation
โ๏ธ Implements modifiers to ensure:
- Only positive numbers are used in operations
- The first number is greater than or equal to the second in subtraction and division
โ๏ธ Emits events for key operations (Addition, Subtraction, Multiplication)
โ๏ธ Uses internal and private functions for optimized logic execution
โ
Remix IDE (Remix Ethereum)
โ
Solidity 0.8.24 compiler
- Open Remix IDE (Remix Ethereum)
- Create a new Solidity file
- Click on File Explorers > "Create New File"
- Name it Calculadora.sol
- Copy & Paste the contract code into the file
- Select Solidity Compiler
- Navigate to the "Solidity Compiler" tab
- Choose 0.8.24 as the compiler version
- Click Compile Calculadora.sol
- Deploy the Contract
- Go to the "Deploy & Run Transactions" tab
- Select a test network (e.g., Remix VM (Cancun))
- Click ๐ Deploy
Once deployed, test the functions. Here you have some examples:
- Call addition(num1, num2)
- Check the emitted event Addition(result)
- Confirm that the
resultvariable updates correctly
- Call multiplier(num1, num2)
- Check the emitted event Multiplier(result)
- Ensure the
resultupdates correctly
- Call division(num1, num2) (num1 must be โฅ num2)
- Ensure the
resultupdates correctly
This project is licensed under LGPL-3.0-only