Payments
GHO is an ERC-20 contract which also implements EIP-2612 to support signature based approvals. This guide will walk-through the different methods for transferring GHO tokens as well as provide ideas, resources, and inspiration for hackathon projects.
transfer
The simplest method for transferring ERC-20 tokens is transfer
which can be used to send tokens to any address without a prior token approval. The limitation of transfer
is that it must be executed directly by the token holder, so it cannot be used within a smart contract function call.
transferFrom
To transfer tokens within a smart contract function, transferFrom
is the method that is used. The transferFrom
function requires the sender to have approved the spender
address for at least the transfer amount
. There are two methods which can be used to perform the approval:
approve
The standard ERC-20 approve
requires an on-chain transaction from the token holder to a approve a specified spender
and amount
.
permit
EIP-2612 permit
is a type of token approval which requires two components:
- A signed approval message from the token holder which encodes: owner, spender, amount, nonce, deadline, DOMAIN_SEPERATOR
- An on-chain
permit
transaction which can be executed from any address
The advantages to using permit
in place of approve
are that the gas cost of the transaction can be paid for by an address other than the token owner, and can reduce the number of transactions by batching the permit
call with another action, an example of this is supplyWithPermit from Aave Protocol V3.
Ideas
- SDK or widget to allow application to embed GHO as payment input and convert to their desired recipient chain/token
- Integration with Aave facilitator to borrow GHO on-demand for payments
- Application to improve user experience of managing GHO borrows and transfers
- Integration with Web2 <-> Web3 payment gateway
- Smart contract wallet integration
Resources
- transfer vs transferFrom
- JavaScript permit package
- Permit2
- The Box - swap/bridge aggregator
- Aave Address Book - solidity & npm registry