Application demonstrating gas sponsorship on Alpen blockchain where the native gas token is BTC.
This monorepo contains a full-stack application for demonstrating gas sponsorship on the Alpen blockchain. It consists of three main packages:
packages/api- Backend API built with Honopackages/ui- Frontend React applicationpackages/contracts- Smart contracts built with Foundry
- Framework: Hono - Fast web framework
- Language: TypeScript
- Libraries:
ethers/viem- Blockchain interactionzod- Schema validation
- Framework: React
- Build Tool: Vite
- Language: TypeScript
- Routing: TanStack Router
- State Management: TanStack Query
- Wallet: Privy
- UI Components: Radix UI
- Framework: Foundry
- Language: Solidity 0.8.27
- EVM Version: Cancun
Each package has its own README with setup instructions:
packages/api/README.md- Backend API setup and developmentpackages/ui/README.md- Frontend application setup and developmentpackages/contracts/README.md- Smart contracts setup and development
For end-to-end testing and local development, follow this sequence:
-
Deploy Smart Contracts (see
packages/contracts/README.md)- Deploy
BatchCallAndSponsorandSponsorWhitelistcontracts - Deploy
Countercontract - Add
Counterto theSponsorWhitelistallow list - Save all deployed contract addresses
- Test contracts (dry-run): Run
./script/test-contracts.shto verify contracts work before proceeding
- Deploy
-
Configure Backend API (see
packages/api/README.md)- Copy
packages/api/.env.exampletopackages/api/.env - Set
RPC_URLto your Alpen RPC endpoint - Set
SPONSOR_PRIVATE_KEYwith your sponsor wallet private key - Set
BATCH_CALL_AND_SPONSOR_ADDRESSandSPONSOR_WHITELIST_ADDRESSfrom step 1 - Start the API server:
cd packages/api && npm run dev
- Copy
-
Configure Frontend UI (see
packages/ui/README.md)- Copy
packages/ui/.env.exampletopackages/ui/.env - Set
VITE_API_URLto match your API server (default:http://localhost:9999) - Set
VITE_COUNTER_CONTRACT_ADDRESS,VITE_BATCH_CALL_AND_SPONSOR_ADDRESS, andVITE_SPONSOR_WHITELIST_ADDRESSfrom step 1 - Configure Privy wallet credentials (
VITE_PRIVY_APP_ID,VITE_PRIVY_CLIENT_ID) - Start the UI:
cd packages/ui && npm run dev
- Copy
-
Run Smoke Tests (optional but recommended)
- Run
npm run test:smokefrom the root directory to verify all components are connected - This checks backend API, contract connectivity, and basic configuration
- Run
# From the root directory, start both API and UI
npm run devThis will start:
- API server on
http://localhost:9999 - UI application on
http://localhost:3000
For detailed architecture, design decisions, and implementation details:
packages/documentation/architecture-and-design.md- Complete technical documentation including:- System architecture and component interactions
- EIP-7702 delegation flow with sequence diagrams
- Smart contracts design and responsibilities
- Security considerations and best practices
- Wallet integration details and alternatives