Skip to content

nekrutnikolai/exercise-token

 
 

Repository files navigation

exercise-token

ETKN

Exercise Token (ETKN) is a fool-proof, yet simple and impactful way to incentivize healthy habits using ChainLink Oracles and the power of Smart Contracts!

MIT license

Disclaimer

This project currently does not work as intended.

Inspiration

This project started out as an entry for the Spring 2021 ChainLink hackathon.

Prerequisites

  • This repo forked or cloned
  • Docker installed
  • An ETH crypto wallet like MetaMask installed
    • Set to the Kovan network
    • The wallet funded with ETH, I used this Gitter chat
    • The wallet funded with LINK tokens, by following this guide
  • Create an Infura project
    • Obtain the Web3 Infura Project ID and the ETH Url
  • Create a Google OAuth project
    • Obtain the OAuth Client ID and the OAuth Client Secret

Getting started

We know it's pretty intimidating, but trust us, you'll figure it out!

  • Create the data folder:

    mkdir data && mkdir data/chainlink-kovan

  • Add api and password files with the chainlink node info:

    echo "[email protected]" > ./data/chainlink-kovan/api
    echo "password123" >> ./data/chainlink-kovan/api
    echo "password123" > ./data/chainlink-kovan/password
    
  • Create the development network for docker: docker network create dev

  • Create a file named .env in the root of the project: touch .env

    • Set the following environment variables in the .env
    WEB3_INFURA_PROJECT_ID=[the infura project id]
    ETH_URL=[the url given by infura. should start with wss://...]
    OAUTH_CLIENT_ID=[google api client id]
    OAUTH_CLIENT_SECRET=[google api client secret]
    PRIVATE_KEY=[a wallet private key with kovan eth. to be used to deploy the smart contracts]
    
  • Start the docker containers:

    docker-compose up -d

  • To run the React App:

    • Enter into the react-app directory:

    cd react-app

    • Build the React App:

    docker build --tag react-app .

    • Run the React App on port 3000 using npm run start:

    docker run -p 3000:3000 react-app npm run start sleep 30

  • Install and configure brownie in a docker container:

    • Run a shell in the smart contract dev container:

    docker exec -it smart_contracts /bin/bash

    • Install brownie:

    pip install eth-brownie

    • Set your chainlink node address:

    export CLNODE_ADDRESS='0x9c9361F06180EE1F6A554886e31Bd9383652c92F'

    • Important install the dependencies manually:

    brownie pm install OpenZeppelin/[email protected]

    brownie pm install alphachainio/[email protected]

  • Start deploying the smart contracts:

    • Deploy the oracle contract:

    brownie run scripts/01_deploy_oracle.py --network kovan

    • Add your node to the chainlink oracle contract by calling the setFulfillmentPermission function of the oracle contract:

    brownie run scripts/02_set_fulfillment_permissions.py --network kovan

  • Now, on the Chainlink node create a bridge and a job by logging onto localhost:6688:

    • Create Bridge on the node

      • Bridge Name: ea-google-fit
      • Bridge URL: http://external_adapter.dev:8000
    • Create a Job:

      {
        "name": "google-fit",
      	"initiators": [
      		{
      			"type": "runlog"
      		}
      	],
      	"tasks": [
      		{
      			"type": "ea-google-fit",
      			"confirmations": null,
      			"params": {}
      		},
      		{
      			"type": "copy",
      			"confirmations": null,
      			"params": {
      				"copyPath": [
      					"steps"
      				]
      			}
      		},
      		{
      			"type": "ethuint256",
      			"confirmations": null,
      			"params": {}
      		},
      		{
      			"type": "ethtx",
      			"confirmations": null,
      			"params": {}
      		}
      	],
      	"startAt": null,
      	"endAt": null
      }
      
      • Set the env var for the job just created using the jobid from your web interface:

      export CLNODE_JOBID=YOUR_JOB_ID

  • Deploy the token contract:

    brownie run scripts/03_deploy_exercise_token.py --network kovan

  • Deploy the token contract:

    brownie run scripts/04_deploy_exercise_token_claim.py --network kovan

  • Fund the ChainLink oracle contract:

    brownie run scripts/05_fund_chainlink_api.py --network kovan

  • Add the current claim contract as minter of our token:

    brownie run scripts/06_add_minter.py --network kovan

  • Get the address of the exercise_token smart contract:

    brownie run scripts/98_exercise_token_abi.py --network kovan

  • Get the address of the exercise_token_claim smart contract:

    brownie run scripts/99_exercise_token_claim_abi.py --network kovan

To do

  • Actually make it functional: figure out the smart contract errors and the oracle issue
  • Have the the token issued so 1 step = 1 ETKN
  • Figure out a smart way to reward other types of exercise dependent on personal goals
  • Integrate it with the React-App instead of the horrendous pure HTML
  • Dynamic NFTs that can be purchased with the tokens, and depend on the steps from the ChainLink oracle as well as a ChainLink VRF.
  • Deploy on mainnet!

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Solidity 44.2%
  • Python 30.5%
  • HTML 21.0%
  • CSS 2.0%
  • JavaScript 1.5%
  • Shell 0.5%
  • Dockerfile 0.3%