npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@lacrypta/gateway

v0.8.17

Published

This is [La Crypta](jttps://www.lacrypta.com.ar)'s _feeless payment gateway_. It provides the building blocks for constructing a MATIC-less payment infrastructure via the usage of _vouchers_.

Downloads

14

Readme

Feeless Payment Gateway

This is La Crypta's feeless payment gateway. It provides the building blocks for constructing a MATIC-less payment infrastructure via the usage of vouchers.

A voucher is nothing more than a signed request, from an owner, to the infrastructure, of a method call.

Thus, a voucher may indicate something along the lines of "please transfer this many tokens from this address to this recipient". The infrastructure should then make this voucher public and have someone pay the MATIC cost of serving said voucher.

Of course, one can do this out of the goodness of one's heart, or some form of incentive may be provided. The current implementation is agnostic to these details, but provides a metadata field specifically to separate the voucher serving data (ie. the payload field) from the infrastructure policies.

Anatomy of a Voucher

A voucher consists of the following fields:

  • tag: a 32-bit number identifying what kind of voucher this is (it is constructed by truncating the keccak of the voucher's type).
  • nonce: a random 256-bit value, used for collision avoidance and tracking only.
  • deadline: a point in time up to which this voucher will be considered valid.
  • payload: an abi.encode()-ed payload data, opaque to the main dispatch mechanism, used for serving the call proper.
  • metadata: an abi.encode()-ed metadata data, opaque to the main dispatch mechanism, used for applying policies on the actual serving of the call.

Upon serving a voucher, the tag is used by the main gateway implementation to dispatch the call to the actual handler, who's free to interpret the payload and metadata fields as they see fit.

Usage

The current implementation consists of:

  • IGateway.sol/Gateway.sol: the abstract base contract for all Gateways, it implements a crude form of voucher dynamic dispatch by abi.encode()-ing and abi.decode()-ing the voucher's payload, dispatching based off of the voucher's tag.
  • IERC20Gateway.sol/ERC20Gateway.sol: an abstract contract serving the voucher for an ERC20 transferFrom() call.
  • IERC20PermitGateway.sol/ERC20PermitGateway.sol: an abstract contract serving the voucher for an ERC20 permit() call (with embedded v/r/s signature).

Creating a new Gateway capable of dealing with a new voucher type is extremely simple, you merely need to:

  1. Create a new contract and inherit from the Gateway of your choice (so as to support ERC20 or ERC20-Permit vouchers as well, or none of them and have a simpler interface).
  2. Define the tags your new contract will be handling. This is straightforward and can be done simply by uint32(bytes4(keccak256(bytes("...")))), where "..." will be something along the lines of "MyVoucher(primitiveType1 fieldName1,primitiveType2 fieldName2,...,primitiveTypeN fieldNameN)".
  3. In your constructor call the _addHandler() method to register the tag you generated as being handled by using the given methods (three are needed: one to extract a user-readable string from the voucher, another one to determine the signer from the voucher's payload, and yet another one to actually execute the call).

As many tags as desired can be handled within the same contract, since each _addHandler call assigns a pair of handling methods to a tag.