A clean, modular implementation demonstrating how to:
- Create ETH transfers using account abstraction UserOperation objects
- Sign UserOperations with TACo threshold signatures via Porter gateway
- Submit to ERC-4337 bundlers with proper format conversion
- Integrate with Discord bot commands (smart wallet provider agnostic)
-
config.py: Configuration and constantsSmartAccountConfig: Network and API configuration- Network constants and default gas limits
-
user_operations.py: UserOperation creation utilitiescreate_eth_transfer_user_operation(): ETH transfer UserOp creation- Smart wallet execute function encoding
-
porter.py: TACo network gateway servicePorterSignatureService: Porter gateway integration for TACo signatures- Discord context handling and TACo threshold signature aggregation
-
bundler.py: Pimlico bundler integrationBundlerClient: ERC-4337 bundler communicationconvert_user_operation_to_pimlico_format(): Format conversion
-
smart_account.py: Main service orchestrationTacoSmartWalletService: High-level ETH transfer operations- Gas optimization and balance validation
-
app.py: Discord bot implementation- Signature verification and command handling
- Background thread processing for async operations
- Clean error handling and response formatting
-
Environment Setup
export PIMLICO_API_KEY="your_pimlico_api_key" export DISCORD_BOT_PUBLIC_KEY="your_discord_bot_public_key"
-
Installation
pip install -r requirements.txt
-
Run the Bot
python app.py
-
Environment Setup Create a
.envfile in the project root:# TACo Smart Wallet Configuration PIMLICO_API_KEY=your_pimlico_api_key_here DISCORD_BOT_PUBLIC_KEY=your_discord_bot_public_key_here # Discord Command Sync Configuration (for syncing slash commands) DISCORD_APPLICATION_ID=your_discord_application_id_here DISCORD_BOT_TOKEN=your_discord_bot_token_here
-
Run with Docker Compose
docker-compose up --build
The bot will be available at
http://localhost:8080with a health check at/health
To sync slash commands with Discord (required for first-time setup or when commands change):
python sync_commands.pyThis requires DISCORD_APPLICATION_ID and DISCORD_BOT_TOKEN environment variables.
- Slash command:
/tip <amount> <recipient> - Background processing to avoid Discord timeouts
- Clean error messages and transaction feedback
- Network: Base Sepolia (Chain ID: 84532)
- EntryPoint:
0x0000000071727De22E5E9d8BAf0edAc6f37da032 - Smart Wallet:
0xBF151420A84A6Bb7b1213d8269a5F1fe43FC3276(example - works with any ERC-4337 wallet)
- Porter Gateway:
https://porter-lynx.nucypher.io - Cohort ID: 2 (Lynx domain)
- Threshold: 2 TACo signatures required
- User runs
/tip 0.01 @friendin Discord - Discord signature verified and user ID extracted
- Tip parameters parsed and validated
- UserOperation created for ETH transfer
- TACo network signs with threshold signatures (2/3 nodes) via Porter gateway
- Bundler submits to Base Sepolia network
- Transaction hash returned to Discord channel