Skip to content

stablecoinxyz/swap

Repository files navigation

swap

This project is a simple web application that allows users to swap tokens on the Base blockchain without having to pay for gas fees. It uses an open-sourced Paymaster from SBC and common libraries like viem to execute the swaps via the Uniswap V3 Router and WalletConnect to connect to the user's wallet.

Usage

You can see it live here. You need to be on the Base blockchain.

gasless-swap

After connecting your wallet, you can swap between USDC and SBC tokens in either direction.

You don't need any ETH to pay for gas fees as our Paymaster will cover the fees for you.

Environment Variables

To run this project locally, you'll need to set up the following environment variables in your .env file:

Required API Keys

# Get a project ID from https://cloud.reown.com/ (WalletConnect)
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=""

# Get an Alchemy RPC endpoint for the Base network from https://alchemy.com/
NEXT_PUBLIC_ALCHEMY_BASE_ENDPOINT=""

Account Abstraction Setup

# 1. Get an API Key for the SBC paymaster from the SBC Dashboard - https://dashboard.stablecoin.xyz/
# 2. Replace YOUR_SBC_API_KEY with your API Key from the SBC Dashboard
NEXT_PUBLIC_AA_BASE_URL="https://api.aa.stablecoin.xyz/rpc/v1/base/YOUR_SBC_API_KEY"

EIP-7702 Setup (Optional)

# 1. Get your ZeroDev App ID from https://dashboard.zerodev.app/projects (Make sure Base is enabled)
# 2. Replace YOUR_ZERODEV_APP_ID with your ZeroDev app ID
NEXT_PUBLIC_ZERODEV_APP_ID="YOUR_ZERODEV_APP_ID"

Run locally

Install dependencies

npm install

Start development server

npm run dev

Author

About

Swap between USDC <-> SBC (Stable Coin) without paying for gas

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages