A demo application showcasing the GasDock SDK - enabling cross-chain transactions where you execute on one chain while paying with tokens on another.
This sample app demonstrates:
- UserOperation preparation on Base Sepolia (transaction execution chain)
- Permit2 payment on Optimism Sepolia, Arbitrum Sepolia, or Polygon Amoy (token payment chains)
- Automatic UserOp execution after payment confirmation with paymaster sponsorship
Key Features:
- Execute transactions on Base Sepolia while paying with tokens from Optimism, Arbitrum, or Polygon
- Multi-chain payment flexibility - choose which testnet to pay from
- Smart account creation using Circle Modular Wallets (ERC-4337)
- Gasless transactions via paymaster sponsorship
- Permit2 signature-based token approvals
- Automatic token allocation for testing
- Node.js 18+ and pnpm
- MetaMask or compatible Web3 wallet
- API keys from Gelato (bundler) and Pimlico (paymaster)
This sample app uses pre-deployed demo contracts with access control disabled, allowing anyone to settle payments:
| Contract | Chain | Address |
|---|---|---|
| MockToken | Base Sepolia | 0xdaE3E3df2F746B2c859eb2453266D5c84B20281A |
| SettlementEscrow | Base Sepolia | 0xCC87454AaaFD9c11691206DDd4593Be953f81155 |
| SettlementEscrow | Polygon Amoy | 0x925BA1462587a924aDE115A5E15ABE8F3714AB6C |
| SettlementEscrow | Arbitrum Sepolia | 0x925BA1462587a924aDE115A5E15ABE8F3714AB6C |
| SettlementEscrow | Optimism Sepolia | 0x925BA1462587a924aDE115A5E15ABE8F3714AB6C |
For production deployments with access control, see the main README.md.
# 1. Run setup (builds SDK, installs deps, creates .env files)
pnpm run setup
# 2. Configure your API keys in the created .env files:
# - Edit .env.local (sample app)
# - Edit ../relay-server/.env (relay server)
# 3. Start both servers
pnpm run start:allOpen http://localhost:3000 in your browser.
- Builds the GasDock SDK (required dependency)
- Installs relay-server dependencies and creates
.envfrom.env.example - Installs sample app dependencies and creates
.env.localfrom.env.example
You need to configure these in both .env.local and ../relay-server/.env:
| Key | Where to get it |
|---|---|
| Bundler API Key | app.gelato.network |
| Paymaster API Key | dashboard.pimlico.io |
| Allocator Private Key | Any funded wallet (for token allocation) |
| Relayer Private Key | Any funded wallet (for relay-server) |
If you prefer to set up manually instead of using pnpm run setup:
# Build SDK
cd ../sdk && pnpm install && pnpm build
# Setup relay-server
cd ../relay-server && pnpm install && cp .env.example .env
# Setup sample app
cd ../sample && pnpm install && cp .env.example .env.local
# Edit both .env files with your API keys
# Start relay-server (terminal 1)
cd ../relay-server && pnpm dev
# Start sample app (terminal 2)
cd ../sample && pnpm dev- Ensure MetaMask is installed
- Click "Connect Wallet"
- Approve the connection request
- The app will automatically create a smart account for you
Actions:
-
Connect Wallet
- Connects your MetaMask wallet
- Creates a Circle Modular smart account
- Initializes bundler and paymaster clients
-
Select Payment Chain
- Choose which testnet to pay from: Optimism Sepolia, Arbitrum Sepolia, or Polygon Amoy
- Each chain has its own token balance and Permit2 approval
-
Automatic Token Allocation
- The app automatically checks your token balance on the selected payment chain
- If you have insufficient MockTokens, they're automatically minted to your wallet in the background
- No manual action required - tokens are allocated seamlessly as needed
-
Calculate Gas (Prepare UserOp)
- Prepares the UserOperation for the transaction on Base Sepolia
- Calculates gas costs (preVerificationGas, verificationGasLimit, callGasLimit)
- Converts gas cost to equivalent token amount
- Auto-populates the Permit2 payment amount
Actions:
-
Authorize Permit2 (one-time setup per chain)
- Grants Permit2 contract permission to spend your tokens
- Automatically switches network to your selected payment chain
- Sets max allowance for seamless future transactions
- Only needed once per token per chain
-
Sign & Relay Permit2
- Signs EIP-712 Permit2 message with the calculated token amount
- Sends signature to relay server
- Relay server broadcasts transaction on the payment chain
- Automatically triggers UserOp execution after confirmation
What happens:
- MetaMask prompts to switch to payment chain (Op/Arb/Polygon)
- Sign Permit2 message (single popup)
- Relay server submits transaction on-chain
- Payment confirmed, proceeds to Step 3
After Permit2 payment succeeds, the UserOperation automatically executes:
- Signs UserOperation with your smart account
- Sends to bundler on Base Sepolia
- Paymaster sponsors gas fees
- Transaction executes on Base Sepolia
Status updates shown:
- "Sending UserOperation on Base Sepolia…"
- "UserOperation sent: [hash]"
- "Waiting for confirmation…"
- "UserOperation confirmed in block [number]"
- Smart Account Address: Your Circle smart account address
- Gas Estimate: Breakdown of gas costs (preVerificationGas, verificationGasLimit, callGasLimit)
- UserOperation Hash: Transaction hash (shown after execution)
- Payment Chain Selector: Dropdown to choose Op Sepolia, Arb Sepolia, or Polygon Amoy
- Wallet Address: Your connected EOA address
- Token Balance: Current MockToken balance on selected payment chain
- Permit2 Allowance: Amount Permit2 can spend (max after authorization)
- Settlement Manager: Escrow contract address on selected payment chain
- Token Address: MockToken (ERC20) contract address
- Payment Receiver: Address receiving the payment
- Amount: Token amount for payment (auto-calculated, editable)
- Intent Hash: Cryptographic binding between payment and execution
- Permit2 Tx Hash: Payment transaction hash
- Real-time operation status and progress
- Transaction confirmation updates
- Error messages and troubleshooting hints
- Base Sepolia (84532) - UserOperations execute here
- Optimism Sepolia (11155420) - Pay with tokens from Optimism
- Arbitrum Sepolia (421614) - Pay with tokens from Arbitrum
- Polygon Amoy (80002) - Pay with tokens from Polygon
All chains use testnet deployments. See /contracts for contract addresses.
sample/
├── scripts/
│ ├── setup.js # Setup script (builds SDK, creates .env files)
│ └── start.js # Start script (runs relay-server + sample app)
├── src/
│ ├── pages/
│ │ ├── _app.tsx # App wrapper with providers
│ │ └── index.tsx # Main demo page
│ ├── utils/
│ │ ├── allocateTokens.ts # Auto token allocation
│ │ └── checkBalances.ts # Balance checking utilities
│ ├── assets/ # Contract ABIs
│ ├── config.ts # Chain and contract config
│ └── wagmi.ts # Wagmi configuration
├── .env.local # Environment variables (created by setup)
└── package.json # Dependencies
- Main README - Project overview and SDK usage
- Relay Server - Relay server setup
- Contracts - Smart contract documentation
