Giter VIP home page Giter VIP logo

funds-exercise's Introduction

Funds

Funds.sol is a smart contract that aims to present some features of the Solidity language in the context of a university exercise. The current implementation is partial and does not fully reflect the requirements defined below, but it is enough to reach the learning objectives.

Definition of the contract in English

A group of friends wants to deposit funds in a safe place and guarantee that the funds cannot be withdrawn until at least 2 of the friends authorise the transaction. When at least 2 of the friends have signed a designated contract, the funds can be withdrawn by any of the friends.

How can we solve this problem using traditional techniques?

Solving the problem with a Solidity smart contract

  1. Open Remix IDE;
  2. Create a new file Funds.sol and paste into it the script contained in this repository;
  3. Compile Funds.sol;
  4. Deploy Funds.sol;
  5. Deposit funds (for example, 1 Ether) into the smart contract by invoking the fallback function;
  6. Try to withdraw (withdrawFunds ()) the smart contract funds. It will not be possible since nobody signed the contract;
  7. Sign (writeSignature()) the contract at least 2 times using distinct addresses and by providing names;
  8. Withdraw (withdrawFunds()) the funds from the smart contract using one of the addresses used for signatures;

Now try using the Ropsten public test network (team up with someone else)!

  1. Install Metamask and follow the wizard;
  2. Connect to the Ropsten network;
  3. Withdraw funds for free from the Ropsten faucet;
  4. As a Remix IDE environment select Injected Web3, so as to interact with Ropsten;
  5. (Only one of you) deploy Funds.sol;
  6. (The other person) invoke (at address) Funds.sol from the other instance of Remix IDE using the smart contract address;
  7. Deposit funds (for example, 1 Ether) into the smart contract by invoking the fallback function;
  8. Sign (writeSignature()) the contract at least 2 times using distinct addresses and by providing names;
  9. Withdraw (withdrawFunds()) the funds from the smart contract using one of the addresses used for signatures;

Note that in this case the signatures and the names will be written permanently on the Ropsten public test network. Students may use also Etherscan to interact with the the smart contract.

Optional part (working on your own)

  1. Modify the code to require sending a positive amount of Ether to the contract to sign it (replace line 24 of the code with the code below);
 function writeSignature(string memory _name) public payable isOwner(false, "An address can be used only once to sign the contract.") {
  require(msg.value > 0, "A positive amount of Ether is required to sing the contract.");
  1. Repeat the process from step 3, taking into consideration the new rule;

funds-exercise's People

Contributors

lorenzogentile404 avatar

Forkers

holyxhellx

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.