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.

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay