Giter Site home page Giter Site logo

unipay's Introduction

Unipay

Uniswap-enabled payments. Allow payment to be made with any ERC-20 token while receiving payment in your token of choice using pooled liquidity.

Unipay accepts tokens and ether, converts these to the desired token, and makes approve calls to allow the payment recipient to transfer those tokens from the contract.

Authored by Vic Woeltjen for The Bee Token ๐Ÿ

Install

npm i

Compile

npm run compile

Compiled contracts will be written to the build directory as Truffle build artifacts.

Usage

A Unipay contract is deployed with the following configuration parameters:

  • address factory: The address of the Uniswap factory contract to use to access swappable liquidity.
  • address recipient: The address of the recipient for payments made via this contract.
  • address token: The address of the token used to represent the payment, as received by the recipient.

Unipay exposes the following methods:

  • price(address token, uint256 value): Get the cost, in units of the identified token, of making a payment of the specified value in this contract's configured payment token.
  • price(uint256 value): Get the cost, in wei, of making a payment of the specified value in this contract's configured payment token.
  • collect(address from, address token, uint256 value, uint256 deadline): Collect payment in the specified token from the from address and swap for value of the configured payment token, with a transaction deadline specified in seconds since the start of 1970. The from address must previously approve this contract to transfer a sufficient amount to complete the swap; user code should call price to determine an appropriate approval amount.
  • pay(uint256 value, uint256 deadline) payable: Deliver payment as ether and swap for value of the configured payment token, with a transaction deadline specified in seconds since the start of 1970. Any excess ether sent with this call will be returned to the caller.

unipay's People

Contributors

woeltjen avatar

Stargazers

Mohamed Badar Hashimi 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.