Socket
Socket
Sign inDemoInstall

ethereum-transfer-gateway

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ethereum-transfer-gateway

Ethhereum Transfer Gateway to Receiver Token without prior Approval


Version published
Weekly downloads
7
decreased by-41.67%
Maintainers
1
Weekly downloads
 
Created
Source

Transfer Gateways

Another way to solve the two step approve and transfer process

Transfer gateways are intermediary contract that make the transfer to the destination contract before calling the contract.

They can be pre-approved globally as immutable address from the ERC20 contract (see _gateway in solc_0.7/Test/BaseERC20.sol) so ERC20 contract can benefit from it without requiring user confirmation.

Alternatively for existing contract, users can approve it only once and can then make purchase in any contract that support such gateways.

This technic is not exclusive to ERC20 and can be used for other contract types.

I am planning to make an ERC721Gateway that support the transfer of multiple ERC721 (from different token contract). use case : https://mystery.market so we can deploy new sale contract without every time requiring approval for transferring ERC721 into it.

How it works

Let say there is a Sale Contract that sell some things (represented by id) for a specific price

User create the data to make the call to SaleContract

const { data, to } = await SaleContract.populateTransaction.purchase(1);

Then the User call the TransferGateway transferERC20AndCall function with the tokeen address and amount to transfer

As shown in the diagram below, this in turn

  • perforrm a transfer on the token to send the token to the destination
  • call the destination and append the data, namely the sender, token address and amount to the msg.data (same as in EIP-2771)

Diagram

Alternative: forwarding

The Gateway also allow to operate without any approval, by letting the sender make an atomic call that first transfer the token to the gateway and then call forward as shown in the following diagram:

Diagram

Keywords

FAQs

Package last updated on 29 Oct 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc