GithubHelp home page GithubHelp logo

eth-avax-project-1's Introduction

Simple Math Operations

This is a simple program that utilizes the 4 basic arithmetic operations while utilizing the 3 error handling statements.

Getting Started

Source Code Content

This contract contains the following components:

  1. Token Details:

    • The contract has a state variable to store the Ethereum address of the contract owner (owner).
    • It has 2 unsigned interger variables to store 2 numbers for the whole contract: num1 and num2.
  2. Constructor:

    • The constructor sets the owner to the Ethereum address of the account that deploys the contract.
  3. onlyOwner modifier:

    • This modifier is attached to the setVal function so that only the owner can use the function its attached to.
  4. setVal Function:

    • This function allows the contract owner to set the num1 and num2 variables.
    • It uses the require to check if the num1 value is greater than the num2 value.
  5. addVals Function:

    • The addVals function uses the assert statement to check both the numbers are not zero.
    • It returns the sum of the values of num1 and num2.
  6. subVals Function:

    • The subVals function uses the assert statement to check both the numbers are not zero.
    • It returns the difference of the values of num1 and num2.
  7. mulVals Function:

    • The mulVals function uses the assert statement to check both the numbers are not zero.
    • It returns the product of the values of num1 and num2.
  8. divVals Function:

    • The divVals function uses the assert statement to check both the numbers are not zero.
    • It returns the quotient of the values of num1 and num2.
  9. revertVals Function:

    • The revertVals function uses the assert statement to check if the product of two input numbers is greater than one of those numbers.

Executing the program

To run this program, you can use Remix, an online Solidity IDE. To get started, go to the Remix website at https://remix.ethereum.org/.

Once you are on the Remix website, create a new file by clicking on the "+" icon in the left-hand sidebar. Save the file with a .sol extension (e.g., Operations.sol). Copy and paste the code from here into the file:

To compile the code, click on the "Solidity Compiler" tab in the left-hand sidebar. Make sure the "Compiler" option is set to "0.8.0" (or another compatible version), and then click on the "Operations.sol" button.

Once the code is compiled, you can deploy the contract by clicking on the "Deploy & Run Transactions" tab in the left-hand sidebar. Select the "OpValCntrct" contract from the dropdown menu, and then click on the "Deploy" button.

Using the program

Once the contract is deployed, you can interact with it by calling the setVal function. Click on the OpValCntrct contract in the left-hand sidebar, enter your 2 numbers on the space on the right of the setVal function, and then click on the setVal function itself.

You can interact with the other functions provided that you have numbers in your num1 and num2 variables

Authors

KermitSudoku

eth-avax-project-1's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.