Solidity Assignment 1

Published by Mario Oettler on

Now, it is your turn. Write your own smart contract.

a) The function calculate should take two parameters a and b of type uint256. It should return the result of a + b. The function can have the state modifier pure. Test the contract.

b) If the contract from a) works, change it according to the following requirements:

  • A user has to pay a small fee to be allowed to use the function calculate.
  • During deployment, the user can specify the fee.

c) Extend the contract from above according to the following requirements.

  • The user that deployed the contract should be able to withdraw the fees.
  • It should be possible to specify the amount to be withdrawn. Code this into a function named withdraw.

d) For convenience, add a function that returns the balance of the contract. Call this function getBalance.

Categories:

if()