Giter VIP home page Giter VIP logo

paymentchain2.0's Introduction

Multi Address Payment System

Nicolas BERNARD

Presentation

Imagine a website that sell articles and wants to allow its clients to pay with ETH providing one account to each of them. The Master smart-contract can create new child accounts so the clients send ETH to them. Then the Master contract withdraw the funds of the children and can transfer it to its owner. Having one account for each client makes it easier to manage the incoming payments. Each payment is received on a different account that can be linked to a client.

How it works

Below, some details about how the smart-contracts works.

  • In order to generate one address per client, we use a Master smart-contract that deploy a child smart-contract on the ChildFactory.sol model.
  • The Master smart-contract is the owner of every child contract and is the only one that can execute the withdrawal function of the child.
  • The child contracts also have an event that is send every time the contract receive or transfer some ETH so the webpage can automatically update the amount of the different accounts.
  • The fallback function allows the contract to receive some ETH directly, sending a transaction to its address.

Run the app

  • Step1 - ​ First you need to install Truffle (version > 5.0.0, [email protected] at this time) npm install -g truffle

  • Step2 - Install the node modules running npm install

With Ganache:

  • Step3 - ​ Install and run ganache-cli --mnemonic xxxx (specify your Metamask mnemonic).

  • Step4 - ​ Migrate the contracts on your Ganache network running truffle migrate --network ganache

With Ropsten:

  • Step3 - ​ Specify your Metamask mnemonic in truffle.js file.

  • Step4 - ​ Migrate the contracts on Ropsten network running truffle migrate --network ropsten

Run the server:

  • Step5 - ​ Run npm run dev and go to localhost:8080

  • Step6 - Configure your Metamask wallet on the right network: localhost:8545 (Ganache) or Ropsten.

  • Step7 - You can also run the contracts tests: truffle test

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.