Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

smart contract workshop (fitbit, oraclize) #24

Open
33 of 35 tasks
Tracked by #4
serapath opened this issue Aug 17, 2019 · 0 comments
Open
33 of 35 tasks
Tracked by #4

smart contract workshop (fitbit, oraclize) #24

serapath opened this issue Aug 17, 2019 · 0 comments

Comments

@serapath
Copy link
Member

serapath commented Aug 17, 2019

@todo

  • when the user signs up, the encrypted token should be stored in the contract (it's encrypted and because it's used to get beginStep it's now bound to our contract, so nobody else who would copy the encrypted token could use it
  • the methods kill and ownerWithdrawal should be removed
    • because we don't want to replace centralised servers with almighty owners
  • for funders, the minimum funding should be bigger than the users signup fee of 0.1
  • users should NEVER have to update their steps
    • instead, the frontend should fetch current steps from the fitbit web api to compare it to beginStep to show the user his progress
  • when the owner closes the round, the contract should now loop over all users and use their fitbit token to get their end steps
    • maybe you also need to save a beginDate and then compare the endDate to check if the average daily steps were 10.000
    • the user can close the round only once, so calling the method again will not be possible so the contract can never use the encrypted token again to check step data from users
  • if possible - this probably expensive transaction to get all steps from all users should be either paid by the funds in the contract or the owner should be re-imbursed for this by taking that amount from the funds
  • when users come to the page after the round was closed, they should be able to "withdraw" their funds from the contract to get them into their metamask account
  • add ability to set a custom duration (like e.g. 5 minutes) when deploying a contract instance, but (by default it's 30 days) => owner should only be allowed to close contest rount AFTER duration is over
  • allow https://alincode.github.io/fitbit-dapp#dev to show "debug buttons"
    • e.g. beginning of all javascript checks localStorage.debug = locatin.hash === "#dev"
    • including a button to load a different "contract address"
  • when in #dev mode, display a button to change contract instance address, so app loads with different contract
  • switch the entire contract to ROPSTEN test network
  • display on website how much time is left until the contest can close
    • e.g. steps in the next ${duration} ${unit ="days"} (10.000 steps per day)
    • add The Fitbit Contest ends in ${ duration - (now - start)} ${unit}
  • display to owner a button to "end contest" (but if duration is not over yet alert('wait for ' + duration - (now - start))
  • fix: updateAllUserStep should add userAddr parameter.
  • oraclize often out of gas, it is hard to test.
  • use public test chain, it need to waiting very long time to get callback
  • Oraclize Token Encryption
  • Fitbit: Presentation for distributed health
    • prepare videos/screencasts for learners
    • Can you try to find "test fitbit accounts"? so that learners can sign in and use the dapp?
    • Could you make 1-5 minute screencast videos to explain the topics used in the dapp?
      • fitbit and how to use fitbit api (get token to make requests)
      • use fitbit api to get steps (javascript fetch)
      • use oraclize web api (to encrypt request/token)
      • use web3.js to call contract methods (e.g. send encrypted request token to contract)
      • use oraclize in a solidity contract ("computational query?" and what it can do)
    • people can join the competition, pay the entrance fee & those who actually successfully finish split the funds amognst themselves
    • some sponsors can join and add funds to the pool
  • Prepare Fitbit Demo for Remix folks
  • Can you make a PR to update the english "wording" to improve/change some variable or function names and maybe some other text (...maybe code comments, etc...)
  • fix metamask issue alincode/fitbit-dapp@99c2348

RESULT:


It would:

  1. use fitbit's api https://dev.fitbit.com/build/reference/web-api/
  2. so fitbit users can "sign up" and stake some "money/tokens" (alternatively a health insurance provider could take a small percentage of peoples monthly insurance payment and stake it)
  3. and fitbit users then get personalised fitness challenges
  4. ...if people achieved or over achieved those challenges, they get back what they staked OR they get back money from their health insurance provider - essentially making their insurance cheaper
  5. ...if people under achieved their staked tokens or part of their monthly insurance fee goes to all the ones who achieved or over achieved :-)

THIS could be the "baseline scenario" and now we could

  1. connect to the fitbit API using some kind of oracle provider service thing (and teach people how to use those)
  2. build the contract
  3. build the frontend (dapp)
  4. write some tests
  5. maybe figure out a good scenario which can be used for debugging
  6. etc....

The result should be presentable in multiple short captured screencasts:

  1. The resources we produce should be chunked into parts that are consumable in 5-10 minutes at most for each of the chunks
  2. We can then later use those in online workshops (or documentation) for other people to learn it

the above is meant as a theme (or use case) on which we can show all the different aspects ethereum users might need to think of when using the ecosystem + we can come up with a "story line" that presents all of the remix features - and then split the presentation in small individually presentable chunks :-) ...because in the real world, people want to use existing web services and databases to either fetch some data from or write some new data to.

Links:

To try out:

I build a base function for use Integration call api, and Integration dapp.

Good news is work now, even code still ugly.

https://github.com/alincode/devon4

This is the smart contract information page.
https://rinkeby.etherscan.io/address/0x696a92a0d6b36628dc92e32daba92b85df1c5d5c

1st line: oraclize callback
2st line: 2st call smart contract callUserAPI method
3st line: oraclize callback
4st line: 1st call smart contract callUserAPI method, it should don't need to pay any ether, because 1st call for free.
5st line: it is created smart contract transaction.

Bad news is, it is very unstable in test chain. Even I paid 1 ether, it always out of gas. it should don't need so many gas, it is just so simple smart contract. I asked the oraclize team, I am waiting for the their reply.

the function is correct, because not always happened "out of gas", I can get correct callback sometime.
oraclize

2018-08-17 16 30 47

2018-08-17 16 32 21

https://github.com/oraclize/ethereum-bridge
https://github.com/oraclize/truffle-starter

oraclize1
oraclize2
oraclize3

The goal is to code a dapp (solidity + frontend) that pulls data from a regular web API.
diagram

slides

Prepare the slides

To include:

  • oraclize price Query fee too high on mainnet provable-things/ethereum-api#10
  • question of privacy (if token is sent over blockchain vs. if all the competition is hosted on centralized server, problem of trust (escrow), problem of transparency (did they pay all contestants?))
  • don't replace central server with a smartcontract which has an almighty owner
    • part of workshop: improve concept of contract by thinking through edge cases
      • (e.g. does the contest happen if only one participant signs up?)

Story

Problem

Lack of trust in NGOs creates problems when trying to raise donations for a cause. With the use of Smart contracts we can make the flow of donations from donors to recipients transparent.

Cause - example

DONORS
Help us promote a healthy lifestyle by incentivizing people to be more active in their daily life.

CONTESTANTS
Win 1.000$ reward for tracking your steps every day for a month. To make it hassle-free for you to get rewarded for staying active, the smart contract automatically syncs your steps from Fitbit. It checks at the end of the month if you hit your step goal every day. If you did, you will receive the full reward, if not, your reward will be reduced by -33$ for every day you didn't manage to hit your goal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant