This project demonstrates a gasless token-transfer flow on the Flare Network using a two-piece architecture:
-
Front-end (React + Ethers.js)
- Presents a simple UI: a “recipient” field, an “amount” field, and a “Send Gasless” button.
- Builds an EIP-712 “transferWithAuthorization” payload off-chain (including timestamps, nonce, etc.).
- Prompts the user’s wallet (e.g. MetaMask) for an EIP-712 signature of that payload—no gas needed from the user at this step.
- Sends the signed payload to the relayer via a POST request.
-
Relayer (Express + Ethers.js)
- Listens for
/relay-transferrequests. - Verifies and submits the user’s signed “transferWithAuthorization” on-chain by calling the USD₮0 contract’s
transferWithAuthorization(...)method, paying the FLR gas itself. - Returns the resulting on-chain transaction hash back to the front-end.
- Listens for
This setup lets end users move USD₮0 tokens without holding any FLR—they only sign a message, and the relayer covers the gas.
Clone the repository:
git clone https://github.com/vmmunoza/Gasless-USDT0-Flow.gitAnd make sure you comply with all relevant dependencies (Node.js, npm, and EOA with FLR tokens for the relayer).
In your project root (where you see .env.example, frontend/ and relayer/), open a PowerShell or terminal and run:
copy .env.example .envThis creates .env with all the placeholders.
Open .env in your editor. In the back‑end section, set:
# — Flare RPC & USD₮0 contract
FLARE_RPC_URL=… # e.g. https://rpc.flare.network or http://127.0.0.1:8545 for local
USD0_ADDRESS=… # the USD₮0 token contract you want to use
# — Relayer credentials
RELAYER_PRIVATE_KEY=… # a private key of an account with FLR (or test FLR) on that network
PORT=3000 # (or your preferred port)- Note 1: If you’re demoing locally, you can point
FLARE_RPC_URLat your Hardhat node and use one of the “Account #” private keys printed bynpx hardhat node. ( On Coston2/testnet, use an account you’ve topped up with test FLR.) - Note 2: The current project setup has been implemented on mainnet.
Still in the same .env, confirm (or adjust) the front‑end vars:
VITE_FLARE_RPC_URL=${FLARE_RPC_URL}
VITE_USD0_ADDRESS=${USD0_ADDRESS}
VITE_RELAYER_URL=http://localhost:${PORT}Vite will automatically expose any VITE_… keys to your React code via import.meta.env.
Now pull in all the packages:
# In project root
npm install
# (Optional: if you prefer per‑folder installs)
cd relayer && npm install && cd ../frontend && npm install && cd ..Open two terminals:
-
Relayer
cd relayer npm run startYou should see
Listening on http://localhost:3000. -
Front‑end
cd frontend npm run devYour browser should open the demo form.
Once both services are running, head to the React UI, fill in a recipient and amount, sign the MetaMask prompt, and watch the USD₮0 move—all without the user holding any FLR.
You can visit the complete documentation section at the Flare Dev Hub
DeepWiki - https://deepwiki.com/vmmunoza/Gasless-USDT0-Flow
Note: There's an additional branch for testing new UX improvements. If you'd like to contribute, it's a good branch to open a PR request.