Giter Site home page Giter Site logo

eth-proof-intermediate's Introduction

Smart Contract for Handling Errors

This is a Smart Contract written in Solidity which has three differerent functions which handle error using require(), revert() and assert() functions

Requirements to run the program

Solidity ^0.8.18 and Remix IDE

Functions of the Contract

The errorHandling smart contract has the following functions present

testAsert(address _z)

  • It demonstrates the usage of assert function
  • It takes an address _z as the parameter
  • It tests if the global variable msg.sender is equal to the address__z
  • If it is true it then returns the address _z

testRevert(uint _x)

  • It demonstrates the usage of revert function
  • It takes an unsigned integer _x as the parameter
  • It checks if the value of _x is greater than 10
  • If it is trueit goes ahead and returns the value of _x
  • If it is false it reverts the function with the statement 'enter a value greater than 10'

testRequire(uint numerator, uint denominator)

  • It demonstrates the usage of require function
  • It takes two unsigned integers numerator and denominator as the parameter
  • It requires the denominator to not be equal to 0
  • If it is equal to 0 then it returns an error with the message 'Denominator cannot be zero'
  • If it is not equal to 0 then it returns the quotient numerator/denominator

Installation

copy the entire code on the Remix IDE on your browser or desktop application and after compiling it deploy the program. Interact using the given parameters and see the functionality of the error handling.

License

The program uses an MIT License

Video Walkthrough

video

eth-proof-intermediate's People

Contributors

555aaditya avatar

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.