Git Product home page Git Product logo

nghianv-1868 / token-back-chainlink Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 2.0 6.91 MB

The platform pays rewards in the form of tokens when buying products. Inherited ideas from lending and borrowing on defi products

Home Page: https://chainlink-cashback.web.app

License: MIT License

Shell 0.05% HTML 0.11% Vue 6.81% JavaScript 2.97% SCSS 2.59% CSS 86.61% Solidity 0.85%
cashback harmony chainlink vuejs

token-back-chainlink's Introduction

Welcome to CashBack ๐Ÿ‘‹

Description

Cashback is an e-commerce platform that allows users to purchase items for a payback in the form of HRC20. Each product will have a corresponding payback rate. After being reimbursed in HRC20 form, users can staking that amount of HRC20 to be able to Yield Farming to generate a corresponding ONE, after each day 2% of the HRC20 is converted to ONE. Users can withdraw the converted ONE at any time they want, however when withdrawing the HRC20 amount will be burned corresponding to the percentage of ONE withdrawn.

Functionality

What CashBack does :

  • Users buy the product and get a 8.6% payback of the product value, which is created in the form of a Sun token. After each day, the amount of ONE newly created will be equal to 2% of the amount of Sun tokens the user is holding. This amount of One, users can withdraw to MathWallet at any time.

  • Users withdraw ONE interest generated from staking Sun. After ONE withdrawal, the amount of Sun tokens will be destroyed corresponding to the percentage of One withdrawn. Example: There are 20 ONE and 1000 Sun tokens, withdraw 10 ONE to the wallet, users will only have 500 Sun tokens. From there the interest per day will be calculated based on the remaining Sun tokens

  • Aiming at the converting needs of buyers. We have integrated Chainlink blockchain technology to fetch the price of ONE and convert the price of the product from ONE to USD. This makes it easy for people to know how much the product is worth in USD.

In the future:

  • First,we are building a cross-chain protocol with cosmos - this product will be like a the bridge between Harmony and ETH - from which users can buy and sell products on the Cashback floor with existing tokens.

  • Next we want to make Cashback a marketplace where people can sell their products at their own rates of return (the competition benefits the buyers). Successful transactions will be charged and this fee will be used to pay bonuses to those who are staking HRC20 cash back when buying items.

How we built it

Cashback is built on 2 smart contracts, Market and Point. Market is used to coordinate activities on exchanges such as buying, selling, withdrawing money, ... Contract Point is a temporarily customized HRC20 contract that cannot be transferred between accounts, but will only play the role is staking and to calculate the amount of daily ONE that a user will be paid for by staking.

On the client side, we use vuejs to build, combined with harmony-sdk to help users interact with the application through MathWallet.Users buy and sell as well as keep HRC20 cash back through mathWallet

Activity diagram

Users will have 2 main streams to interact with Cashback

  • Buy item activity :

  • Withdraw interest activity:

Using

  • Landing page:

  • Market - Where you can choose product to buy:

  • Select item:

  • You must sign in before buying and sign transaction:

  • Transaction successful:

  • Show purchased products:

  • Interest will be increased daily based on the amount of Sun coin you hold:

  • You can withdraw the interest at any time but the sun coin will be burned:

Project setup (testnet)

Setup contract :

  • Load dependencies:
cd contract
yarn install
  • Copy .env file:
//LOCAL
//Local uses account one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7 on Shard 0
LOCAL_PRIVATE_KEY='45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e'
LOCAL_MNEMONIC='urge clog right example dish drill card maximum mix bachelor section select'
LOCAL_0_URL='http://localhost:9500'

//TESTNET
//Account: one18t4yj4fuutj83uwqckkvxp9gfa0568uc48ggj7
TESTNET_PRIVATE_KEY='01F903CE0C960FF3A9E68E80FF5FFC344358D80CE1C221C3F9711AF07F83A3BD'
TESTNET_ADDRESS = 'one18t4yj4fuutj83uwqckkvxp9gfa0568uc48ggj7'
TESTNET_MNEMONIC='urge clog right example dish drill card maximum mix bachelor section select'

TESTNET_0_URL='https://api.s0.b.hmny.io'
TESTNET_1_URL='https://api.s1.b.hmny.io'

//MAINNET
//Please replace MAINNET_PRIVATE_KEY and MAINNET_MNEMONIC with your own!
//Account: one18t4yj4fuutj83uwqckkvxp9gfa0568uc48ggj7
MAINNET_PRIVATE_KEY='01F903CE0C960FF3A9E68E80FF5FFC344358D80CE1C221C3F9711AF07F83A3BD'
MAINNET_MNEMONIC='urge clog right example dish drill card maximum mix bachelor section select'
MAINNET_0_URL='https://api.s0.t.hmny.io'

GAS_LIMIT=3321900
GAS_PRICE=1000000000
  • Deploy contract:

Note: Config in contract/scripts/* to deploy in TESTNET

  • You must change network ChainID.HmyMainnet -> ChainID.HmyTestnet
  • MAINNET_PRIVATE_KEY -> TESTNET_PRIVATE_KEY
  • MAINNET_0_URL -> TESTNET_0_URL
yarn all

Setup client:

  • Load dependencies:
cd client
yarn install
  • Run
yarn serve

token-back-chainlink's People

Contributors

nghianv-1868 avatar

Watchers

 avatar  avatar

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.