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

3,000,000 HYDRO to create a Coupon Ethereum Smart Contract #255

Closed
mitdralla opened this issue Jan 29, 2019 · 6 comments

Comments

@mitdralla
Copy link
Member

commented Jan 29, 2019

Project Details

3,000,000 HYDRO to create an Ethereum smart contract on top of Hydro Snowflake that allows a business to create coupons for their services and for a user to redeem these coupons, with unique characteristics.

Background:

  • A coupon contains information about a percent-off or amount-off discount you might want to apply to a customer.
  • Coupons can be an important part of e-commerce, point of sales transactions (POS), invoicing, and orders.
  • An on-chain approach can make coupons unique and eliminate fraud and disputes in the marketplace.
  • These functions can be used by dApp developers in the Hydro ecosystem to power commerce globally.

Features:

  • Simple Marketplace:
    • One-to-many seller-to-buyer Resolver on Snowflake
    • Seller is contract owner (admin)
    • Seller can list items with the following properties
      • Name
      • Description
      • Price
      • Uuid
      • Item type (probably a hash of the description of the item type)
    • Buyers can purchase listed items at-price by by sending a transaction that:
      • Calls allow-and-call for the user on Snowflake
        • Sets an allowance equal to the price
        • Draws the corresponding allowance from the user
        • Transfers ownership of the item to the buyer
      • Transactions should be facilitated through a via contract which must be written as part of this task (instructions below); in most instances, the ‘via’ will do nothing; however, if the user has a “coupon,” the via will apply the coupon as part of the transaction. Coupons work as follows:
  • Issuer creates the coupon:
    • Coupons that correspond to a given marketplace are denominated by a coupon-generation function.
    • The marketplace admin can generate coupons at-will.
    • Coupon generation function should take the following parameters:
      • Item type - the type of item for which this coupon applies
      • Discount rate - the percentage discount the coupon offers
      • Distribution address - defines the logic for how coupons are distributed; must follow a standard interface with a function that can be called from the coupon-generation function to define the initial distribution of coupons once generated.
      • Each coupon should have a uuid
  • Via contract to use coupons:
    • When a buyer is buying an item, the transfer function call on Snowflake should include the address of the via contract, and an extraData bytes parameter that will encode a function call. This bytes parameter should include the uuid of the user-owned coupon. The logic of the via contract will draw the apply the discount rate of the coupon to the item, and then transfer the coupon to a burner address. The user’s discount will be refunded to them while the seller receives the rest of the value of the transaction. Finally, ownership of the purchased item should be transferred to the user. All this should be achievable in one synchronous function-call. If a user passes 0 as the uuid for the coupon, the via should just conduct a transfer as normal as if no coupon were present.
    • The via contract will need to check to enforce that the user actually has the coupon they are trying to pass.
  • Front-end:
    • This task requires the creation of a user-facing front-end using React integrated into the Snowflake dashboard. Admin functions may rely on direct calls to the smart contract, or you may make an admin portal if desired.

Other Notes:

Once this task has been completed, we will test your product and provide feedback and notes for the creation of a potential V2 task as part of the HCDP.

Future versions may include:

  • Multiple types of discounts (amount taken off instead of percentage)
  • Multiple sellers each issuing items and corresponding coupons
  • Ability for Seller to hotswap inbound payments to receive DAI or another token despite HYDRO being used on the buyer-side.

What are the deliverables?

Solidity code, in the form of an open-source smart contract as well as a front-end integrated into the Hydro Dapp store. Your code should be verified on Etherscan and deployed on Etherscan, and submitted to the Hydro community github (exact repo to be provided soon).
Reference

##You should use the following tools for reference:##

Timeframe?

We propose three months as the timeframe for completion of this task.

Submission process?

First, comment on this issue to declare your willingness to complete the task. Next, fill out the Coupon Smart Contract Claim Form. We will evaluate candidates factoring in their qualifications, Github activity, and the order in which they expressed interest.

Oversight Process

One of the DAs will be assigned to oversee the completion of this task once it’s awarded.

Reward Structure

Once you have been selected, you will have one month to complete the task. The time frame begins as soon as we award the task to the candidate by communication within this thread.
During this time we will be able to provide some support around questions about the workflow on Discord.

During this time the candidate needs to update the codebase regularly in a subrepo of our official Github. This will be setup and conveyed to the candidate by the assigned DA.

If the task is not completed within the timeframe we reserve the right to offer an extension, or transfer the task to another candidate. If no extension is granted, then we reserve the right to continue on the codebase committed. The fractional disbursement for it, if any, would be given at our discretion.

Once the task is completed we will test the plug-in for efficiency and whether or not it correctly incorporates the Hydro workflow. If we approve the plug-in, we will then send you 3,000,000 Hydro.

@Luiserebii

This comment has been minimized.

Copy link

commented Feb 10, 2019

I'm very interested in completing this task, and am excited to get started, if possible!

@mitdralla

This comment has been minimized.

Copy link
Member Author

commented Feb 11, 2019

This task is assigned to @Luiserebii - we will reach out with next steps. 👍

@Luiserebii

This comment has been minimized.

Copy link

commented Jun 11, 2019

Hello @mitdralla,

Thank you so much for the opportunity to work on this, it truly has been a great learning experience. There were many, many more roadblocks than I anticipated, one of which led to me creating an npm module to ease the issue, haha. Apologies, and thank you again for your patience.

I am happy to say that I am finished with the bounty! Aside from the /docs folders within the repositories, I have also created more formal documentation in the form of a PDF: https://github.com/Luiserebii/HydroSnowflake-Marketplace-Coupons/blob/master/docs/HydroSnowflake%20Marketplace%20Coupon%20-%20Formal%20Documentation.pdf

Hydro Snowflake Coupon Marketplace Smart Contract Repo: https://github.com/Luiserebii/HydroSnowflake-Marketplace-Coupons
React Dashboard Repo: https://github.com/Luiserebii/HydroSnowflake-Marketplace-Dashboard

Thank you again, I am truly grateful for the extension. Please let me know if there's anything I missed, I attempted to be as thorough as possible.

Best,
Luiserebii~

@mitdralla

This comment has been minimized.

Copy link
Member Author

commented Jun 12, 2019

Fantastic! @Luiserebii could you please provide your ETH address below?

@Luiserebii

This comment has been minimized.

Copy link

commented Jun 12, 2019

Definitely! My ETH address is: 0x2512abB14D4c67f6CCaeBDE7E41Ea4B2B689a516

@mitdralla

This comment has been minimized.

Copy link
Member Author

commented Jun 13, 2019

@mitdralla mitdralla added Completed and removed In Development labels Jun 13, 2019
@mitdralla mitdralla closed this Jun 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.