Giter Site home page Giter Site logo

stow-smart-contracts's Introduction

Stow Smart Contracts NPM Package Build Status Coverage Status


⚠️ WIP

Smart Contracts for Stow

DEPLOYED CONTACTS

Overview

Stow Users

A contract that keeps a registry of registered users and their provenance.

Stow Records

A contract that keeps a registry of metadata of uploaded medical records, as well as the IRIS score of those records. The metadata makes records easily searchable.

Recieving Tokens when adding Stow records

When a person uploads data, 1 Finney STOW token is transferred from the Stow admin pool/acct to the user’s address. Currently no data validation needed.

1 Finney of STOW tokens per upload for now.

Stow Permissions

A contract that keeps a registry of permissions. Permissions include who can view what data, and where the permissioned copy is stored on IPFS.

Stow Overall Architecture

Stow architecture

Getting started

Prerequisites

  • Node.js
  • Node Package Manager

Clone the repository

$ git clone https://github.com/ConsenSys/Stow-Smart-Contracts.git

Install the dependencies

$ npm install

Deploying

npm run migrate

Testing

To run tests with coverage

npm run coverage

To run tests without coverage

  • First start testrpc with npm start
    • Alternatively you can run Ganache GUI at port 7545 with network id 5777
  • Run npm test

Video to Help You Get Started

Video to Get You Started with Stow Smart Contract

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

stow-smart-contracts's People

Contributors

anujshah108 avatar davidrhodus avatar godfreyhobbs avatar leeb2018 avatar libertylocked avatar maxblaushild avatar vrotmanh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stow-smart-contracts's Issues

Incorrect installation doc

installing smart contracts should be git clone xxx

npm install installs the dependencies, not the contracts. the contracts aren't even on npmjs

Solc warnings

Missing abi.encodePacked is causing the following warnings.


bytes32 prefixedHash = keccak256(prefix, message);
                       ^------------------------^contracts/LinniaRecords.sol:255:8: Warning: This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
return keccak256(dataHash, records[dataHash].metadataHash);
       ^-------------------------------------------------^
contracts/LinniaRecords.sol:283:24: Warning: This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
bytes32 metadataHash = keccak256(metadata);
                       ^-----------------^
contracts/LinniaRecords.sol:283:24: Warning: The provided argument of type string memory is not implicitly convertible to expected type bytes memory.
bytes32 metadataHash = keccak256(metadata);
                       ^-----------------^

Create a end-user facing demo decentralized application, dapp, on top of Linnia Smart Contract

Gitcoin Funding Amount: 0.7 ETH

Context

Linnia is a core component of the future of the web; Web 3.0. Linnia is a new Ethereum Blockchain protocol that brings the power of decentralization to your lifetime data. The Linnia protocol provides the foundation for secure decentralized applications in multiple spheres including the sphere of electronic healthcare records.

What

We would like to incentivize you, as a member of the Gitcoin/Bounties family, to create a new end-user facing demo decentralized application, the dapp, on top of Linnia Smart Contract. We will be awarding the best submission for this task a .7 ETH prize, assuming the below requirements are met.
The dapp must be in the spirit of the following two Linnia papers;

  1. https://github.com/ConsenSys/linnia-resources/blob/master/Technical-Whitepaper.md
  2. https://github.com/ConsenSys/linnia-resources/blob/master/Introducing%20Linnia.pdf

Note: Linnia is a WORK IN PROGRESS. The Linnia smart contracts are only a small subset of what is described in these papers.

Our Ideas

  1. Share the answer to riddles with friends via the smart contract permissions
  2. Upload and share data from a fitness tracker API such as the Fitbit API

Requirements

  1. You have read and understood the WIP nature expressed in the README.md
  2. Code must be in a public github repo
  3. Use the Linnia Smart Contracts for some non-trivial end-user facing functionality
  4. Consider use of encryption to keep data secret
  5. Be prepared to present your submission to the linnia team
  6. Be prepared for a review of your code by the linnia team
  7. Open source your solution
  8. Finally, use your imagination

Help create Linnia IRIS (InfoRmation Integrity Score) score algorithm

Context

Linnia is a core component of the future of the web; Web 3.0. Linnia is a new Ethereum Blockchain protocol that brings the power of decentralization to your lifetime data. The Linnia protocol provides the foundation for secure decentralized applications in multiple spheres including the sphere of electronic healthcare records.

What

We would like to incentivize you, as a member of the Gitcoin/Bounties family, to innovate and help create the Linnia IRIS score algorithm. The IRIS stands for InfoRmation Integrity Score. The Linnia IRIS score is a critical part of the linnia protocol. We will be awarding the submission for this task a .7 ETH bounty, assuming the below requirements are met.
The proposed Linnia IRIS score algorithm must be in the spirit of the following two Linnia papers;

  1. https://github.com/ConsenSys/linnia-resources/blob/master/Technical-Whitepaper.md
  2. https://github.com/ConsenSys/linnia-resources/blob/master/Introducing%20Linnia.pdf

In particular, the following section describes the IRIS score:

  1. https://github.com/ConsenSys/linnia-resources/blob/master/Technical-Whitepaper.md#6-quality-scoring-with-iris

Note: Linnia is a WORK IN PROGRESS. The Linnia smart contracts are only a small subset of what is described in these papers.

Our Ideas

  1. IRIS score should increase as the number of attestations increase
  2. IRIS score may consider the following:
    1. Attestations
    2. Provenance
    3. Metadata including keywords
    4. User Roles
  3. IRIS score of zero indicates junk or garbage data
  4. IRIS score must reflect a real-world value

Requirements

  1. You have read and understood the WIP nature expressed in the README.md
  2. It must be impossible to game the IRIS score algorithm
  3. IRIS score algorithm must work end-to-end
  4. Must NOT be limited to the medical
  5. Your ideas must be submitted as Documentation and Code in a fork of this repo
  6. Consider the use of encryption to keep data secure. The computation must not leak or reveal any information related to the nature of the underlying encrypted data
  7. Provide two or three real-world non-trivial end-user facing use cases for your IRIS score algorithm
  8. Be prepared to present your submission to the Linnia team and the Linnia community
  9. Be prepared for a review of your code by the Linnia team and the Linnia community
  10. Finally, use your imagination

Linnia*.sol: Invoking events without "emit" prefix is deprecated

In the latest truffle (v4.1.5) // MacOS 10.13 , node v8.9.1

$ truffle compile
Compiling ./contracts/LinniaHub.sol...
Compiling ./contracts/LinniaPermissions.sol...
Compiling ./contracts/LinniaRecords.sol...
Compiling ./contracts/LinniaRoles.sol...
Compiling node_modules/zeppelin-solidity/contracts/math/SafeMath.sol...
Compiling node_modules/zeppelin-solidity/contracts/ownership/Ownable.sol...

Compilation warnings encountered:

node_modules/zeppelin-solidity/contracts/ownership/Ownable.sol:38:5: Warning: Invoking events without "emit" prefix is deprecated.
    OwnershipTransferred(owner, newOwner);
    ^-----------------------------------^
,Linnia-Smart-Contracts/contracts/LinniaRoles.sol:44:9: Warning: Invoking events without "emit" prefix is deprecated.
        LogPatientRegistered(msg.sender);
        ^------------------------------^
,Linnia-Smart-Contracts/contracts/LinniaRoles.sol:56:9: Warning: Invoking events without "emit" prefix is deprecated.
        LogProviderRegistered(user);
        ^-------------------------^
,Linnia-Smart-Contracts/contracts/LinniaRoles.sol:67:9: Warning: Invoking events without "emit" prefix is deprecated.
        LogProviderRemoved(user);
        ^----------------------^
,Linnia-Smart-Contracts/contracts/LinniaRecords.sol:183:9: Warning: Invoking events without "emit" prefix is deprecated.
        LogRecordAdded(fileHash, patient);
        ^-------------------------------^
,Linnia-Smart-Contracts/contracts/LinniaRecords.sol:205:9: Warning: Invoking events without "emit" prefix is deprecated.
        LogRecordSigAdded(fileHash, provider, record.irisScore);
        ^-----------------------------------------------------^
,Linnia-Smart-Contracts/contracts/LinniaPermissions.sol:57:9: Warning: Invoking events without "emit" prefix is deprecated.
        LogAccessGranted(msg.sender, viewer, fileHash);
        ^--------------------------------------------^
,Linnia-Smart-Contracts/contracts/LinniaPermissions.sol:77:9: Warning: Invoking events without "emit" prefix is deprecated.
        LogAccessRevoked(msg.sender, viewer, fileHash);
        ^--------------------------------------------^
,Linnia-Smart-Contracts/contracts/LinniaHub.sol:29:9: Warning: Invoking events without "emit" prefix is deprecated.
        LogRolesContractSet(prev, _rolesContract);
        ^---------------------------------------^
,Linnia-Smart-Contracts/contracts/LinniaHub.sol:40:9: Warning: Invoking events without "emit" prefix is deprecated.
        LogRecordsContractSet(prev, _recordsContract);
        ^-------------------------------------------^
,Linnia-Smart-Contracts/contracts/LinniaHub.sol:51:9: Warning: Invoking events without "emit" prefix is deprecated.
        LogPermissionsContractSet(prev, _permissionsContract);
        ^---------------------------------------------------^

Deprecation Warning in Test

The following test has a deprecation warning:

recover
   ✓ should recover the signer address if sig is valid (130ms)

(node:5241) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.

openzepplin ctr warnings

openzepplin code has these warnings.

openzeppelin-solidity/contracts/ownership/Ownable.sol:20:3: Warning: Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
  function Ownable() public {
  ^ (Relevant source part starts here and spans across multiple lines).

Linnia Smart Contracts Security Bounties

The scope of this bounty is for bugs in the Linnia Smart Contracts, whose severity is judged by the OWASP model:
OWASP model

Payouts will be as follows:

Critical: .2 ETH
High: .15 ETH
Medium: .05 ETH
Low: .02 ETH
Note: At discretion of Linnia team.

Payouts will be made to the first individuals who report bugs, and exploits will be ineligible for payouts if they've already been used on the deployed contracts.

Non-security critical severity issues (style issues, gas optimizations, storage optimizations) are not eligible for this bounty.

Determinations of eligibility and all terms related to this award are at the sole and final discretion of the Linnia team.

Hashes in data URIs are being stored as hex encoded strings

Hash like 0x59742369c54039d5611d84452aa6c31b72da336b76ed4029b12c3dc5479836ba is stored as a literal string that starts with 0x, 66 bytes in total. inb4 they are 32 bytes

Also is 0x a legal data URI? Or 0x000000000000000000000000000000000000000000000000000000000000

Installation fails

after cloning this project I run npm install from the cloned directory

$ npm i
> @linniaprotocol/[email protected] prepare /Users/harrymoreno/programming/cryptocurrency/Linnia-Smart-Contracts
> truffle migrate

Could not connect to your Ethereum client. Please check that your Ethereum client:
    - is running
    - is accepting RPC connections (i.e., "--rpc" option is used in geth)
    - is accessible over the network
    - is properly configured in your Truffle configuration file (truffle.js)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @linniaprotocol/[email protected] prepare: `truffle migrate`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @linniaprotocol/[email protected] prepare script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/harrymoreno/.npm/_logs/2018-09-13T20_39_38_472Z-debug.log

Decentralized policy-based permissions bounty

Context

Linnia is a core component of the future of the web; Web 3.0. Linnia is a new Ethereum Blockchain protocol that brings the power of decentralization to your lifetime data. The Linnia protocol provides the foundation for secure decentralized applications in multiple spheres including the sphere of electronic healthcare records.

What

We would like to incentivize you, as a member of the Gitcoin/Bounties family, to innovate and help create precise sharing permissions through decentralized policy-based permissions. The current contract, LinniaPermissions.sol, only supports (True|False) permissions. We want your help to improve this. We are expecting the improvements in the code plus an explanation document.
Decentralized policy-based permissions is a critical part of the linnia protocol. We will be awarding the submission for this task a .7 ETH bounty, assuming the below requirements are met.
The proposed Linnia policy-based permissions algorithm must be in the spirit of the following two Linnia papers;

  1. https://github.com/ConsenSys/linnia-resources/blob/master/Technical-Whitepaper.md
  2. https://github.com/ConsenSys/linnia-resources/blob/master/Introducing%20Linnia.pdf

Note: Linnia is a WORK IN PROGRESS. The Linnia smart contracts are only a small subset of what is described in these papers.

Our Ideas

  1. Policy-based permissions could include time-limited sharing
  2. Policy-based permissions could include geography limited sharing
  3. Policy-based permissions may consider data governance rules such as HIPAA or GDPR
  4. Policy-based permissions may include at rest and in-flight restrictions

Requirements

  1. You have read and understood the WIP nature expressed in the README.md
  2. The algorithm must:
    1. Leverage the power of decentralization
    2. Encompass the consumer incentives of the Linnia data marketplace
    3. Allow trustless interaction
    4. Be usable and easy to understand
  3. It must be impossible for any party to game policy-based permissions
  4. The various parties involved in policy-based permissions include the following;
    1. Individual peers
    2. Social groups or communities
    3. Connected devices (e.g. IoT, Bluetooth)
    4. Central authorities hosted on digital platforms (i.e. apps)
    5. Central authorities hosted on physical platforms using IT (i.e. doctors, government)
    6. AI and Machine learning platforms with or without blind computation capabilities
    7. Decentralized applications
  5. The person owning the data must remain 100% in control at all times
    policy-based permissions algorithm must be end-to-end
  6. Must NOT be limited to the medical
  7. Your ideas must be submitted as Documentation and Code in a fork of this repo
  8. Consider use of encryption to keep data secure. The computation must not leak or reveal any information related to the nature of the underlying encrypted data
  9. Provide two or three real-world non-trivial end-user facing use cases for your policy-based permissions algorithm
  10. Be prepared to present your submission to the Linnia team and the Linnia community
  11. Be prepared for a review of your code by the Linnia team and the Linnia community
  12. Finally, use your imagination and have fun

Improve readme.md

Our readme.md can be improved with more details and maybe screen shots.

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.