This repository provides a generic Gasless Adapter module that adds
ERC2612 (permit) and ERC3009 (gasless transfers) support to any
standard ERC20 token.
- Core base contract:
GaslessAdapterBase - Standard adapter implementation:
StandardGaslessAdapter(deployed via factory) - Factory contract:
GaslessAdapterFactory(deploys adapters) - Standalone extensions:
ERC2612,ERC3009
The design follows EIP-712 and exposes a full ERC20 interface plus:
- ERC2612:
permit,nonces,DOMAIN_SEPARATOR - ERC3009:
transferWithAuthorization,receiveWithAuthorization,cancelAuthorization,authorizationState
Deploy a gasless adapter for your ERC20 using the provided Foundry scripts.
Currently the repository ships with a pre-deployed factory on:
- Base Sepolia
- Chain ID:
84532 - Factory address:
0x5e5E52fb594e5F98BD582b309d16FAE02D1e9032
- Chain ID:
You can deploy additional factories on other networks if needed.
Use the DeployAdapterViaFactory script. Required environment variables:
PRIVATE_KEY: Deployer private keyRPC_URL: RPC endpoint for the target networkFACTORY_ADDRESS: Factory contract address (see above)UNDERLYING_TOKEN: Underlying ERC20 token addressTOKEN_NAME: EIP712 domain nameTOKEN_VERSION: EIP712 domain versionOWNER: Owner address for the adapter
Example (Base Sepolia):
export PRIVATE_KEY=your-private-key
export RPC_URL=https://sepolia.base.org
export FACTORY_ADDRESS=0x5e5E52fb594e5F98BD582b309d16FAE02D1e9032
export UNDERLYING_TOKEN=0x... # your ERC20 token
export TOKEN_NAME="MyToken Adapter"
export TOKEN_VERSION="1"
export OWNER=0x... # adapter owner
forge script script/DeployAdapterViaFactory.s.sol:DeployAdapterViaFactory \
--rpc-url $RPC_URL \
--broadcastThe script will print the deployed adapter address to the console.
If you prefer to deploy the factory yourself on another network, use:
export PRIVATE_KEY=your-private-key
export RPC_URL=<your-rpc-url>
forge script script/GaslessAdapterFactory.s.sol:GaslessAdapterFactoryDeploy \
--rpc-url $RPC_URL \
--broadcastThen pass the new factory address as FACTORY_ADDRESS when running DeployAdapterViaFactory.
You can integrate in two ways:
- Use Factory + SDK - Deploy via factory.
- Write your own adapter contract that inherits
GaslessAdapterBase- For custom logic.
If you need custom logic, inherit GaslessAdapterBase directly:
- Implement
_getUnderlyingToken()to return the underlying ERC20 address. - Optionally:
- inherit
Pausableand override_requireNotPaused()to enforce pause, - inherit
OwnableorAccessControlto restrict admin operations.
- inherit
The signature verification and allowance handling for ERC2612/3009 are already
implemented in GaslessAdapterBase, ERC2612, and ERC3009.
The EIP-712 domain is configured through the GaslessAdapterBase constructor:
tokenName: used as the domainname.tokenVersion: used as the domainversion.
Frontends and wallets must use these values when constructing EIP-712 payloads for:
- ERC2612
Permit:- Type hash:
Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)
- Type hash:
- ERC3009 transfers:
TransferWithAuthorizationReceiveWithAuthorizationCancelAuthorization
Use the adapter’s DOMAIN_SEPARATOR() and nonces(owner) view functions when
building client-side signing payloads.
This repository uses Foundry for building and testing.
- Build
forge build- Test
forge test- Format
forge fmt- Gas Snapshots
forge snapshot- Anvil
anvil