0

Ethereum is quite different from bitcoin, and in my opinion better. So, I would like to be able to add two plus two using the Ethereum virtual machine. I don’t have any ether, and I’m just curious how to do it and how much money the calculation would cost and if this is feasible.

1 Answer 1

1
pragma solidity ^0.5.0;

contract TwoPlusTwo {

    /**
    name: adder()
    inputs: two unsigned (positive) integers, 256 bits each
    visibility: public (anyone can see and use this function to add two numbers
    pure: It does not change on-chain state and does not require network verification
    returns: returns an unsigned uint, 256 bits
    */


    function adder(uint x, uint y) public pure returns(uint) {
        return x+y;
    }
}

Load it in https://remix.ethereum.org to see it work.

Use the JavaScript VM blockchain emulator (for dev/test).

Deploy it. Notice that is assigned an address. That is the contract address. You can then play with the function.

There is no need to publish this useless experiment on the mainnet, so you don't need any ETH.

If you did want to publish it, then you would need some ethereum to pay for gas to cover the cost of deploying it to the network.

Hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.