DEV Community

Ahmad Raza Khokhar
Ahmad Raza Khokhar

Posted on

Basic Solidity Smart Contract

This is a contract for making a basic calculator with solidity.

//SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

contract calculator {
    uint256 result;
    //addition
    function add(uint128 num) public {
        result += num;
    }
    //substraction
    function substract(uint128 num) public {
        result -= num;
    }
    //multiplication
    function multiplication(uint128 num) public {
        result *= num;
    }
    //showing the out put 
    function output() public view  returns (uint256){
        return result;
    } 
}
Enter fullscreen mode Exit fullscreen mode

How to deploy this contract?

To deploy this contract to blockchain, you must make a test network in Remix IDE (an online ethereum code editor and compiler) named as sepolia faucet and grab some test coins from their respective site. Secondly, put the inject provider such as Meta-Mask at the top by simply copying the wallet address.
Now hit the deploy button in Remix:

Image description

Now just test your deployment buttons and we are good to go!

If you enjoyed the article, and if this was helpful then just leave a like below.
Regards,
Ahmad Raza Khokhar.

Top comments (0)