Giter Site home page Giter Site logo

final-project-hav-noms's Introduction

P2P Token Exchange

A simple Peer 2 Peer Token exchange where;

  • sellers create a trade listing, depositing their ERC20 tokens to trade into the contract.
  • buyers pay ETH for the tokens and both actors are paid their coins.

This project focuses on the best patterns and practices implementation from the Consensys academy bootcamp. A lot of focus of the solution is the incorporation of important ethereum design patterns, protection mechanisms and the stretch goals that would be used in a real world decentralized solution. The project evaluation checklist provided below lists the completed tasks.

User Journey

  • Navigate to the REACT Dapp on IPFS https://ipfs.io/ipfs/QmdXFKKok8i3E26V7mW7ZPPxqDzvMAjXywTwf8Rk8JT9fu
  • See a list of available trades or
  • Create a trade listing and deposit your ERC20 Tokens escrowed in the contract
  • Buyers can select a trade to fulfil and send ETH to the contract and will be send your tokens, you will be sent the ETH
  • Withdraw your trade listing and have your tokens returned to you

DApp ui

Setup

Requirements:

  • Truffle
  • Node Package Manager (npm)
  • Ganache CLI
  • MetaMask

Steps:

Run Tests

  1. Clone the repo and cd into the folder
  2. Install all the dependencies for the Truffle environment (Zeppelin library, ethers.js for the tests...etc).
    $ npm install
    
  3. Start a local blockchain with Ganache. Make sure it is set on port 8545 and set the block gas limit to 8,000,000 becuase the exchange contract is too big to deploy
    $ ganache-cli -p 8545 -l 8000000
    
  4. Run truffle test

You should see

tests

Run the DAPP

Steps:

  1. From ganache, grab the private key of the first account and add it to metamask private keys

  2. Connect Metamask to localhost MM

  3. in MetaMask add the private key of the first account in ganache MM

  4. Run

    $ truffle migrate
    
  5. Grab the ShartCoin address from ganache SHT

  6. and add the custom token to metamask. SHT

  7. You should see you have 100B SHT SHT

  8. Go the client directory and install all the app dependencies.

    $ cd client
    $ npm install
    
  9. As this app is using ether.js the Contract constructor will need the contract address. You will need to update the address in App.js. Update SMART_CONTRACT_ADDR to point to your local deployed address contract address

    const SMART_CONTRACT_ADDR_ROPSTEN = "0xf371b912b26d3c9220e4e7cbc312591e6074721a";
    const SMART_CONTRACT_ADDR_LOCAL = "";
    const SMART_CONTRACT_ENS = "p2ptokenexchange.eth";
    
    // Set this const to your chosen ENV
    const SMART_CONTRACT_ADDR = SMART_CONTRACT_ADDR_ROPSTEN;
    
  10. Start the React app.

    $ npm run start
    
  11. Alternatively you can test the app with the ropsten deployed addresses

Ropsten:

Rinkeby:

  • I did not deploy to rinkeby as ENS is not available on Rikeby only Ropsten

Deployed versions of the dApp

Ropsten: https://p2ptokenexchange-ropsten.netlify.com

To test the ROPSTEN connected DAPP you can buy the existing SHT coin tokens for ROPSTEN ETH and then sell them back to the exchange to create a listing. Or send any ERC20 on ROPSTEN to create a listing. Or ping me with your MM wallet address and I'll send you some SHT.

IPFS: https://ipfs.io/ipfs/QmdXFKKok8i3E26V7mW7ZPPxqDzvMAjXywTwf8Rk8JT9fu

Developer Bootcamp Final Project Evaluation Checklist

  • A README.md that explains the project
  • What does it do?
  • How to set it up.
  • How to run a local development server.
  • It should be a Truffle project.
  • All contracts should be in a contracts directory.
  • truffle compile should successfully compile contracts.
  • Migration contract and migration scripts should work.
  • truffle migrate should successfully migrate contracts to a locally running ganache-cli test blockchain on port 8454.
  • All tests should be in a tests directory.
  • truffle test should migrate contracts and run the tests.
  • Smart contract code should be commented according to the specs in the documentation.
  • Create at least 5 tests for each smart contract.
  • Write a sentence or two explaining what the tests are covering, and explain why those tests were written.
  • A development server to serve the front-end interface of the application.
  • A document design_pattern_decisions.md that explains the design patterns chosen.
  • A document avoiding_common_attacks.md that explains what measures were taken to ensure that the contracts are not susceptible to common attacks.
  • Implement/use a library or an EthPM package.

Project Requirements

User Interface

  • Run the dapp on a development server locally for testing and grading.
    • Testing on Ropsten; (I chose ropsten instead of rinkeby becuase there is no ENS on rinkeby)
  • You should be able to visit a URL (can be localhost) and interact with the application
  • Display the current account;
  • Sign transactions using MetaMask;
  • Reflect updates to the contract state

Testing

  • Write 5 tests for each contract you wrote in Javascript;
  • Tests are properly structured (ie sets up context, executes a call on the function to be tested, and verifies the result is correct)
  • Explain why you wrote those tests in code comments;
  • Tests provide adequate coverage for the contracts
  • All Tests pass with truffle test.

Design Patterns

  • Implement a circuit breaker (emergency stop) pattern.
  • What other design patterns have you used / not used?
    • Why did you choose the patterns that you did?

Security Tools / Common Attacks

  • Explain what measures you have taken to ensure that your contracts are not susceptible to common attacks.

Use a Library or Extend a Contract

  • At least one of the project contracts includes an import from a library/contract or an ethPM package.

Deployment

Additional

Stretch

ENS Auction ENS Config ENS Address Set

final-project-hav-noms's People

Contributors

hav-noms avatar

Watchers

 avatar

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.