lesyk / CustomerConsentWallet

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CustomerConsentWallet

###Install & Run

  1. cd wallet
  2. yarn install
  3. bower install
  4. ember s

Contracts

Contracts source code is located in contracts/

The Consents contract is the one currently used. It can be used as a 'singleton' contract that contains state on all consents. The following function can be called on the contract:

  • function requestConsent(address customer, address data_owner, uint id) Called by the data requester. Assumes the consent id parameter is globally unique.
  • function updateConsent(address data_owner, address data_requester, uint id, State state) returns (bool) Called by customer. State should be 1 or 3 for for given/rejected (currently not enforced).
  • function requestData(address customer, address data_owner, uint id) Called by data requester.
  • function provideData(address customer, address data_requester, uint id, bytes payload) Called by data owner.

All function calls generates an event (which can be used to check the return value of the function call).

Parties that call a contract function, must have enough ether to pay for the transaction.

Due to the global nature of the contract and to Solidity/Ethereum VM limitations, reading data from the contract is somewhat convoluted currently. A customer's contracts can be retrieved by:

  • function customerConsents(address customer) returns the number of consents for the customer
  • Look up in the public accessible customer_mapping with customer address and index (0 - number of consents) returns the indices (one for each lookup) in the public accessible consents array
  • A consent can be retrieved from the consents array using an index

An example can be seen in wallet/app/routes/consents.js.

The contract can be removed by calling the kill() function, which can only be called by the account that deployed the contract.

https://ethereum.github.io/browser-solidity can be used to experiment with, develop and debug the contract.

##Create consent

  1. Create two accounts: for data owner and data requestor (both should have some money on them).
  2. cd dataowner
  3. make
  4. node index.js datao@example.com password 0x9a804CF13E3defb1043D2B81BE95D14C787c94Dc
  5. cd datarequestor
  6. make
  7. node index.js datar@example.com password 0xA04A6A76F1E23D80E075f490a2E23daACB65d0A9 person@gmail.com datao@example.com
  8. Approve/Disaprove from wallet app

About

License:MIT License


Languages

Language:JavaScript 73.9%Language:Handlebars 11.0%Language:Solidity 7.4%Language:HTML 4.9%Language:Makefile 1.2%Language:CSS 1.0%Language:Dockerfile 0.5%