Giter Site home page Giter Site logo

eitan-lev / depositcontract Goto Github PK

View Code? Open in Web Editor NEW
7.0 3.0 2.0 696 KB

Payment channels using Solidity and SGX. Truffle for tests and infrastructure

License: GNU General Public License v3.0

JavaScript 100.00%
solidity ethereum blockchain truffle smart-contracts payment-channels web3 web3-solidity

depositcontract's Introduction

Smart Contract for Payment Channels over Ethereum

  • Pull the repository and perform the installation steps. There is no need to do these steps more than once on each computer.
  • Do not save any private keys on this repository.
  • Enjoy!

Table of Contents

Background

Relying on the notion of the payment channels using Ethereum, this project implements the concept by incorperating SGX (or any equivalent third party abilities). As a result, allowing usage of payment channels over Ethereum while minimizing gas costs and transaction amounts on the Blockchain.

Installation Instructions

  1. Download the latest node.js from: https://nodejs.org/en/download/

  2. Git clone/ pull the project from our github repository.

  3. Use npm init in the root directory (/DepositContract)

  4. If using Windows- open a windows command line as administrator and run:

    1. npm install --global --production windows-build-tools
    2. If that doesn't work - you have to go to the course video, lecture 37 and follow the second option.
  5. Install a bunch of libraries: (If using Windows- open cmd as admin, if Linux- sudo before each one)

    1. npm install --save solc
    2. npm install --save mocha ganache-cli [email protected]
    3. npm install --save fs-extra
    4. npm install --save [email protected]
    5. npm i truffle If any of these commands doesn't execute successfully, look online for solutions.
  6. Install libraries used for development of front end (not sure if this is a must in order to see it):

    1. npm install --save semantic-ui-react
    2. npm install --save semantic-ui-css
    3. npm install --save next-routes

    Again, if any of that doesn't work - you should search for a solution.

Compilation and Deployment Instructions

For Node

If you wish to re-compile the contract (you don't have to do it, and it's better you don't do it unless you have a good reason):

  1. cd ..\ethereum
  2. node compile.js
  3. (verify you see all 3 .json files inside \ethereum\build)
  4. node deploy.js
  5. Save the addresses you get for the factory and for the SGX simulator.
  6. The factory address should be placed in \ethereum\factory.js at line 6.
  7. Note: Sometimes when you use node compile.js or deploy you get some weird error. in this case - open node.js terminal as administrator from windows search, close the code editor and run the command from the terminal you opened. It fixes it.

For Truffle

  1. cd to Truffle/contract directory.
  2. In the command line:
    1. Windows- mklink Deposit.sol ....\ethereum\contracts\Deposit.sol
    2. Linux- sudo ln -s Deposit.sol ../../ethereum/contact/Deposit.sol
  3. cd ..
  4. truffle compile
  5. truffle migrate

Testing

with Node

  1. cd back into root directory (not sure if this is a must) and run: npm run dev

with truffle

  1. cd to Truffle directory
  2. truffle test

Front End interaction:

Wait until the command line tells you that compilation was successful.

  1. cd back into root directory (not sure if this is a must).
  2. Open chrome (or any other browser with metamask) and enter localhost:3000

Maintainers

@eitanlev @amitw

License

Solidity is licensed under GNU General Public License v3.0

Example

In Development

Documentation

In Development

Development

In Development

depositcontract's People

Contributors

amit-weiss avatar eitan-lev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

depositcontract's Issues

Refreshing a channel show page disables initiator and coutnerpart abilities

Whenever you view a channel and look into its "show" page (that contains all the details about a channel) the called checks the address of the caller to see whether it is the initiator or the counterpart of the channel.
After this check, the buttons that appear correspond to the check result. After refreshing the page, this check is not performed again and the user will appear as "other" to the contract.
A possible reason for that is that the code for checking the user is located inside getInitialProps function.

Deleting a contract causes deletion of all contracts of said creator

When withdrawing both parties' funds, the factory.removeDeposit() is called, then delete deployedDeposits[(depositsCreators[msg.sender])] is done.
This deletes all the contracts belonging to sender, instead of just the specific one.
Tricky to fix- we work with an array, and don't want to leave an empty cell in the middle.

Require minimal fee as modifier

Currently minimal fee is enforced with require inside the method.
Use modifier costs instead, to match common code convention.
Implement in all relevant functions.

Re-routing user after a contract self destruct

After a channel is closed, we perform a self destruct to its contract. Due to that, we cannot re-route to the "show" page, since the contract no longer exists and it will show nothing.
This issue needs to be addressed, because we still want the user to view data for at least a little after.

Add ability to identify contracts by description

Is your feature request related to a problem? Please describe.
Currently, when we look at contracts we can only refer to them using their addresses.

Describe the solution you'd like
It would be more convenient if we could add a text to each contract, so when we look at our contracts we will see the description of it.

Describe alternatives you've considered
Another option is to add a field to the contract itself, that will be updated by initiator and will be managed on the blockchain. I find this idea not as good since it adds overhead of writing to the blockchain.

Additional context
I believe the description should be unique to each party, such that the initiator and the counterpart will be able to set different names.

Note 1: This text should not be kept on the blockchain.

Note 2: This issue was edited to fit the new "feature request" template.

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.