BNB ERC-2771 Gasless Token system #186
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Gasless Token Project
This project implements an ERC-2771 compliant Gasless Token system on the BNB Chain (or any EVM chain). It allows users to transfer tokens without paying gas fees, by signing messages that are relayed by a backend service.
Project Structure
The repository is organized into three main components:
1.
contracts/Contains the Solidity smart contracts, tests, and deployment scripts using Foundry.
GaslessToken.sol: An ERC20 token that inherits fromERC2771Context, allowing it to unwrap meta-transactions forwarding the real sender.Ownableto restrict minting (if applicable) to the owner.0.8.20.Forwarder.sol: A trusted forwarder contract that verifies EIP-712 signatures and forwards the call to the target contract.2.
relayer/A Node.js/Express service that acts as the Relayer.
Forwardercontract, paying the gas fee.3.
frontend/A Next.js 14 application providing the user interface.
Prerequisites
foundryup.Setup & Installation
1. Smart Contracts
Compile and test the contracts:
To deploy (e.g., to a local Anvil node):
anvilGaslessTokenandForwarder.2. Relayer Service
Navigate to
relayer/:cd relayer npm installConfigure Environment Variables:
Copy
.env.exampleto.envand fill in the details:Start the Relayer:
3. Frontend
Navigate to
frontend/:cd frontend npm installConfigure Environment Variables:
Copy
.env.exampleto.env.localand fill in the details:Start the App:
Features & Usage
Gasless Transfer Flow
Forwarder.execute()on-chain.GaslessToken.transfer()._msgSender()and processes the transfer.Deployment
Mainnet / Testnet
.envfiles with real RPC URLs (e.g. BSC Testnet)..envfiles.