Skip to content

QingZhouCheng/FUSD

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flux USD (FUSD)

Solidity Built with Hardhat

A Gasless, Sponsored Stablecoin Implementation

Flux USD (FUSD) is an ERC-20 stablecoin designed to eliminate the friction of blockchain payments. By implementing meta-transaction standards (EIP-2771, EIP-2612, EIP-3009), FUSD allows users to send and receive tokens without holding ETH or paying gas fees directly.

This repository contains the smart contract implementation, deployment scripts, and test suites demonstrating the gasless workflow using a Relayer pattern.

📖 Project Overview

Traditional stablecoins require users to hold native currency (ETH) to pay for transaction fees. This creates a significant onboarding barrier. FUSD solves this by shifting the gas burden to a "Sponsor" (Relayer).

Core Logic:

  1. Off-Chain Signature: The user signs a structured message (EIP-712) authorizing a transfer.
  2. Relayer Submission: A trusted relayer receives the signature and submits the transaction to the blockchain, paying the gas fees.
  3. On-Chain Verification: The FUSD contract verifies the signature and executes the transfer on behalf of the user.

✨ Features

  • Standard ERC-20 Compliance: Fully compatible with wallets and exchanges.
  • Meta-Transactions (EIP-2771): Native support for Trusted Forwarders (Relayers) to enable gas abstraction.
  • Gasless Approvals (EIP-2612): Built-in permit function allows modifying allowances via signatures.
  • Atomic Gasless Transfers (EIP-3009): Implements transferWithAuthorization for one-step, "pay-as-digital-cash" payments without prior approval.
  • Secure Access Control: Uses OpenZeppelin's Ownable for minting and administrative tasks.

🛠 Tech Stack

  • Framework: Hardhat
  • Language: Solidity ^0.8.20, TypeScript
  • Libraries: OpenZeppelin Contracts v5.x
  • Testing: Mocha, Chai, Ethers.js v6

🚀 Getting Started

Prerequisites

  • Node.js (v18 or later recommended)
  • pnpm

Installation

Clone the repository and install dependencies:

git clone <repository-url>
cd <repository-directory>
pnpm install

Compile

Compile the smart contracts:

pnpm compile

Testing

Run the test suite to verify the gasless transfer logic. The tests simulate a full EIP-3009 flow where a user signs a message and a relayer executes it.

pnpm run test

🧩 Architecture Details

EIP-3009: Transfer With Authorization

This is the core feature for payments. Unlike permit + transferFrom (which requires two steps), transferWithAuthorization is atomic.

  • TypeHash: TransferWithAuthorization(address from,address to,uint256 value,uint256 validAfter,uint256 validBefore,bytes32 nonce)
  • Nonce Handling: Uses a unique 32-byte nonce to prevent replay attacks.

EIP-2771: Trusted Forwarder

The contract inherits ERC2771Context. It overrides _msgSender() to ensure that when a Relayer calls the contract, the internal logic sees the original user as the sender, not the Relayer.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors