Giter Site home page Giter Site logo

unnamed-lab / 10-solidity-exercises-2023 Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 1.0 105 KB

Welcome to my latest project, where I've compiled a list of 10 Solidity smart contract exercises that you can try out to improve your skills in blockchain development. In this project, you'll find a variety of smart contract implementations, ranging from simple storage contracts to more complex systems.

JavaScript 9.58% Solidity 90.42%

10-solidity-exercises-2023's Introduction

10 Solidity Exercises For Beginners.

Welcome to my latest project, where I've compiled a list of 10 Solidity smart contract exercises that you can try out to improve your skills in blockchain development.

In this project, you'll find a variety of smart contract implementations, ranging from simple storage contracts to more complex systems like auctions, crowdfunding, and supply chain management. Each exercise is designed to challenge your understanding of Solidity and help you gain practical experience in building decentralized applications. Whether you're a beginner or an experienced developer, you're sure to find something that interests you in this collection.

So, what are you waiting for? Let's dive into the world of smart contracts and start building! ๐Ÿ’ป๐Ÿš€

Here are the exercises we would be working on:

  1. Create a simple smart contract that stores a string and allows other users to read it.
  2. Create a smart contract that allows users to vote on a proposal.
  3. Create a smart contract that implements a simple auction system.
  4. Create a smart contract that implements a basic crowdfunding system.
  5. Create a smart contract that implements a simple token system.
  6. Create a smart contract that implements a simple lottery system.
  7. Create a smart contract that implements a simple escrow system.
  8. Create a smart contract that allows users to buy and sell items using a cryptocurrency.
  9. Create a smart contract that implements a basic supply chain management system.
  10. Create a smart contract that implements a simple decentralized exchange.

Solidity contract file directories(../contracts):

  1. Create a simple smart contract that stores a string and allows other users to read it.
..\contracts\Messaging.sol
  1. Create a smart contract that allows users to vote on a proposal.
..\contracts\VotingPoll.sol
  1. Create a smart contract that implements a simple auction system.
..\contracts\Auction.sol
  1. Create a smart contract that implements a basic crowdfunding system.
..\contracts\Crowdfunding.sol
  1. Create a smart contract that implements a simple token system.
..\contracts\SimpleToken.sol
  1. Create a smart contract that implements a simple lottery system.
..\contracts\Lottery.sol
  1. Create a smart contract that implements a simple escrow system.
..\contracts\Escrow.sol
  1. Create a smart contract that allows users to buy and sell items using a cryptocurrency.
..\contracts\Marketplace.sol
  1. Create a smart contract that implements a basic supply chain management system.
..\contracts\SupplyChain.sol
  1. Create a smart contract that implements a simple decentralized exchange.
..\contracts\Exchange.sol

During this exercise, the Solidity compiler version used was the 0.8.18;

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;

The non reentrancy modifier was used throughout the exercise to ensure that on some given functions the contract doesn't call itself.

uint private constant NotEntered = 0;
uint private constant Entered = 1;
uint private _status;

...

modifier nonReentrancy() {
    require(_status != Entered, "Reentrancy call");
    _status = Entered;
    _;
    _status = NotEntered;
}

To give the contract deployer the power to run some particular functions, I added the onlyOwner modifier.

modifier onlyOwner() {
    require(msg.sender == owner, "Not creator of contract");
    _;
}

Added by default::: Try running some of the following tasks:

npx hardhat help
npx hardhat test
REPORT_GAS=true npx hardhat test
npx hardhat node
npx hardhat run scripts/deploy.js

10-solidity-exercises-2023's People

Contributors

unnamed-lab avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

jinfengpang

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.