Giter Club home page Giter Club logo

docs's Introduction

Ethereum Gas Station Network (GSN)

Ethereum Gas Station Network (GSN) abstracts the process of paying for gas away from end users which minimizes UX friction for dapps. With GSN, gasless clients can interact with Ethereum smart contracts without users needing ETH for transaction fees. The GSN is a decentralized system that improves dapp usability without sacrificing security.

Example use cases for GSN:

  1. Privacy: Enabling ETH-less withdrawal of tokens sent to stealth addresses
  2. Pay for gas in supported ERC-20 tokens: Allow users to pay for gas in ERC-20 tokens that support permit function
  3. Pay for gas off-chain: Allow users to pay for gas indirectly via a L2 rollup or a credit card
  4. Onboarding: Allow dapps to subsidize the onboarding process for new users

The problem

Without GSN, anyone who sends an Ethereum transaction needs to have ETH to pay for gas fees. This forces new users to pass KYC and purchase ETH before they can start using any dapp. This can be a major hurdle for users without prior crypto experience that are unfamiliar with the concept of needing to keep ETH in their wallet for gas.

This is also a UX pain for existing users that need to continually replenish their ETH balance to pay for gas fees even if they have enough ERC-20 tokens in their wallet to pay for the transactions they need.

Architecture

Components:

Client: signs & sends meta transaction to relay server

A meta-transaction is a fancy name for a simple idea: a relay server can send a user's transaction and pay for the gas cost itself. Instead of signing an Ethereum transaction, which would require ETH for gas, a user signs a message containing information about a transaction they would like to execute and sends it to a relay server.

Relay servers: submits a transaction and pays Ethereum protocol gas fees for doing so

Upon receiving the request to relay a transaction from the client, the Relay server will validate this transaction to make sure it pays back the amount of ETH that covers the expenses of submitting it and some extra fee to allow the relayer to turn a profit.

If everything is fine, the relayer signs a native Ethereum transaction, submits it to the mempool and returns a signed transaction to the client for validation. In case anything goes wrong, the client can just pick a different relay server and try to send a transaction via a new one.

This creates a "one for all and all for one" effect where taking down the frontend of any dapp is as hard as taking down the entire network. The more dapps participate the more robust the availability guarantee.

Paymaster: agrees to refund relay server for gas fees

In the GSN all gas refund logic is implemented inside the Paymaster contracts. A paymaster maintains an ETH balance in the RelayHub and can implement any business logic to decide whether to accept or reject a meta transaction. For example, accepting only transactions by whitelisted users, or to the contracts methods required for onboarding users that also passed a captcha, or only transactions that include a repayment in tokens to the Paymaster, etc.

Forwarder: verifies sender signature and nonce

Meta transaction aware recipient contracts only rely on a small trusted forwarder contract for their security. This contract verifies the signature and nonce of the original sender.

Recipient contract: sees the original sender and executes the original transaction

Any public method of the recipient contract can be executed through GSN.

To support meta transactions recipient contracts inherit from a simple base class and replace msg.sender with _msgSender(). It returns the original sender that signed the meta transaction request.

It is still possible to make a native transaction call to this contract. The _msgSender() method will simply return msg.sender if the contract was called directly.

RelayHub: coordinates the process in a trustless way

RelayHub connects users running clients, relay servers and paymasters so that participants don't need to know about or trust each other.

Dapp developers don't need to understand or trust the inner workings of RelayHub in order to integrate with the GSN. Recipient contracts are not exposed to potential security issues in RelayHub.

Under the hood the RelayHub helps clients discover the best third-party relay server, prevents third-party relay servers from censoring transactions, and ensures Paymasters pay back relay servers for gas fees plus transaction fees.

Next Steps

To learn more about the GSN, head over to the following resources:

docs's People

Contributors

0xjjpa avatar aharvet avatar awesamarth avatar azf20 avatar drortirosh avatar dysbulic avatar forshtat avatar lirazsiri avatar moonr2 avatar omahs avatar qbzzt avatar shahafn avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

docs's Issues

Missing installation instructions for contracts

It might be obvious, but it's probably worth adding yarn add @opengsn/contracts both in the website and docs to make sure people know that they need to install these for their contracts.

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.