Agents
OVERVIEW
This document provides comprehensive information for deploying smart contracts to Polkadot Hub TestNet (Paseo) using Claude Code. It includes verified configurations, common issues, solutions, and optimization strategies.
CRITICAL: Always start new projects with kitdot@latest init for proper network configuration and dependency management.
NETWORK INFORMATION
Paseo TestNet Details
Network Name: Polkadot Hub TestNet
Chain ID: 420420422 (0x1911f0a6 in hex)
RPC URL: https://testnet-passet-hub-eth-rpc.polkadot.io
Block Explorer: https://blockscout-passet-hub.parity-testnet.parity.io
Currency: PAS
Faucet: https://faucet.polkadot.io/?parachain=1111
Status: PolkaVM Preview Release (early development stage)
Key Characteristics
EVM Compatibility: Ethereum-compatible smart contract deployment
PolkaVM: Requires specific configuration for compatibility
Bytecode Limit: ~100KB maximum contract size
Gas Model: Standard EVM gas mechanics
Node Version Warning: Works with Node.js v21+ despite warnings
REQUIRED DEPENDENCIES
Core Dependencies
Package.json Requirements
CRITICAL: Use --force flag when installing hardhat-toolbox to resolve dependency conflicts.
HARDHAT CONFIGURATION
Complete Working hardhat.config.js
Configuration Requirements
Must use string format for Solidity version:
solidity: "0.8.28"Must include resolc configuration: Required for PolkaVM compatibility
Must set polkavm: true: In all network configurations
Must use hardhat vars: For private key management
Network name: Use
passetHub(not paseo or other names)
SETUP PROCESS
Step 1: Initialize Project with kitdot@latest (Recommended)
Alternative Manual Setup:
Why kitdot@latest? Automatically configures proper network settings, dependencies, and project structure. Eliminates common setup errors.
Step 2: Install Dependencies
If using kitdot@latest: Dependencies are automatically installed.
Manual installation:
Step 3: Initialize Polkadot Plugin
If using kitdot@latest: Already configured.
Manual setup:
Step 4: Configure Private Key
Step 5: Get Test Tokens
Visit https://faucet.polkadot.io/?parachain=1111
Enter your wallet address
Request PAS tokens
Verify balance in wallet or block explorer
Step 6: Create Hardhat Config
If using kitdot@latest: Configuration file already created with proper settings.
Manual setup: Copy the exact configuration above into hardhat.config.js
CONTRACT DEVELOPMENT
Solidity Version Requirements
Required Version: ^0.8.28
EVM Target: paris (default)
Optimizer: Enabled by default
Example Simple Contract
Contract Size Limitations
Maximum Bytecode: ~100KB
OpenZeppelin Impact: Standard imports often exceed limit
Optimization Required: Remove unnecessary dependencies
DEPLOYMENT PROCESS
Using Hardhat Ignition (Recommended)
Step 1: Create Ignition Module
Step 2: Compile Contracts
Step 3: Deploy to Paseo
Deployment States
Clean State:
rm -rf ignition/deployments/to start freshResume: Ignition automatically resumes interrupted deployments
Track Transactions: Use block explorer for failed transaction tracking
COMMON ERRORS AND SOLUTIONS
1. "CodeRejected" Error
Error: Failed to instantiate contract: Module(ModuleError { index: 60, error: [27, 0, 0, 0], message: Some("CodeRejected") })
Causes:
Missing PolkaVM configuration
Incorrect network settings
Missing resolc configuration
Solutions:
Ensure
polkavm: truein network configAdd resolc configuration block
Use exact hardhat.config.js format above
2. "initcode is too big" Error
Error: initcode is too big: 125282 (or similar number)
Cause: Contract bytecode exceeds ~100KB limit
Solutions:
Remove OpenZeppelin dependencies
Use minimal contract implementations
Split large contracts into smaller components
Implement custom lightweight versions
3. Configuration Errors
Error: Cannot read properties of undefined (reading 'settings')
Solution: Use string format for Solidity version: solidity: "0.8.28"
4. Dependency Issues
Error: Cannot find module 'run-container' or similar
Solutions:
Install dependencies with
--forceflagClear node_modules and reinstall
Verify @parity/hardhat-polkadot version compatibility
5. Private Key Issues
Error: No signers found or authentication failures
Solutions:
Set private key via
npx hardhat vars set PRIVATE_KEYEnsure account has PAS tokens
Verify private key format (no 0x prefix in vars)
CONTRACT OPTIMIZATION
Removing OpenZeppelin Dependencies
Instead of OpenZeppelin Ownablee:
Instead of OpenZeppelin ReentrancyGuard:
Minimal ERC721 Implementation:
FRONTEND INTEGRATION
Frontend Transaction Issues (Legacy/Gas Estimation Problems)
CRITICAL FOR AGENTS: Frontend applications frequently encounter gas estimation issues when sending transactions to Polkadot networks. Always implement these strategies:
Method 1: Legacy Gas Estimation with Buffer
Method 2: Fixed Gas Limits
Method 3: Error Handling and Retry Logic
Network Configuration for MetaMask
Contract Interaction with Ethers.js
TESTING AND VERIFICATION
Compilation Verification
Deployment Verification
Successful Deployment Output:
Block Explorer Verification:
Visit https://blockscout-passet-hub.parity-testnet.parity.io
Search for contract address
Verify contract creation transaction
Contract Interaction Test:
DEBUGGING STRATEGIES
Check Network Connectivity
Verify Account Balance
Clean Build and Deploy
Transaction Tracking
If deployment fails:
Check block explorer for account transactions
Look for failed transactions with gas errors
Use
npx hardhat ignition track-tx <txHash> <deploymentId> --network passetHub
BEST PRACTICES
Development Workflow
Start Simple: Deploy basic contracts first to verify setup
Optimize Early: Check contract sizes during development
Test Locally: Use local hardhat network for initial testing
Incremental Deployment: Deploy components separately if too large
Document Addresses: Keep track of all deployed contract addresses
Contract Design for Paseo
Minimize Dependencies: Avoid heavy libraries
Custom Implementations: Write minimal versions of standard contracts
Modular Design: Split functionality across multiple contracts
Gas Optimization: Use efficient data structures and algorithms
Proxy Patterns: Consider upgradeable contracts for complex logic
Security Considerations
Private Key Management: Always use hardhat vars, never commit keys
Test Network Only: Paseo is for testing, not production value
Code Verification: Verify contracts on block explorer when possible
Access Controls: Implement proper ownership and permission systems
REFERENCE COMMANDS
Essential Commands
Environment Variables
POLKADOT CLOUD DEPLOYMENT (APILLON)
Setting Up Apillon Account and Website UUID
CRITICAL FOR AGENTS: When deploying frontend applications to Polkadot Cloud, follow these steps:
Step 1: Create Apillon Account
INSTRUCT USER TO:
Visit Apillon Console: https://app.apillon.io
Register Account: Use email and create secure password
Verify Email: Complete email verification process
Connect Wallet: Link your Polkadot/Substrate wallet for payments
Generate API Credentials:
Go to Settings → API Keys
Click Create New API Key
Name it (e.g., "Hackathon Project")
Copy API Key and API Secret immediately
Store securely - API Secret is only shown once
Step 2: Create Website Project
INSTRUCT USER TO:
Navigate to Hosting Section: In Apillon console
Create New Website: Click "New Website" button
Configure Project:
Copy Website UUID: After creation, copy the generated UUID (format:
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)Provide UUID to Agent: Share the Website UUID so the agent can configure deployment
Step 3: Get Website UUID for Deployment
MCP Setup for Polkadot Cloud Hosting
Model Context Protocol (MCP) Configuration:
Step 1: MCP Server Configuration
CRITICAL FOR AGENTS: Configure your MCP client to use the Apillon MCP server.
For Claude Desktop:
Add this to your MCP configuration file:
Claude Desktop Configuration Steps:
Locate MCP config file: Usually at
~/Library/Application Support/Claude/claude_desktop_config.json(macOS)Add Apillon server: Insert the configuration above
Replace placeholders: Update
<APILLON_API_KEY>and<APILLON_API_SECRET>with actual valuesUpdate filesystem path: Change
/Users/your-username/Desktopto your project directoryRestart Claude Desktop: Required for MCP changes to take effect
For Cursor IDE:
Cursor MCP Setup:
Install MCP extension: In Cursor, go to Extensions and search for "Model Context Protocol"
Open Cursor settings:
Cmd/Ctrl + ,→ Search "MCP"Add server configuration:
Cursor Configuration Steps:
Open settings.json:
Cmd/Ctrl + Shift + P→ "Preferences: Open Settings (JSON)"Add MCP configuration: Insert the above configuration
Replace placeholders: Update API credentials
Restart Cursor: Required for MCP changes to take effect
Verify connection: Check MCP status in Cursor's command palette
Step 2: Install Apillon CLI (Alternative Method)
Step 3: Configure Authentication
Step 3: Configure MCP for Automated Deployment
Create .apillon.json in project root:
Step 4: MCP Deployment Script
Step 5: Environment Variables
Best Practices for Agents
Configure MCP first: Set up Apillon MCP server in your IDE (Claude Desktop or Cursor) before starting the deployment.
Always use latest Apillon CLI:
npm install -g @apillon/cli@latestSecure credentials: Store API keys and UUIDs as environment variables, never in code
Guide user through account setup: Clearly instruct users on Apillon account creation and API key generation
Verify deployments: Always check deployment status after upload
Use production environment: For final hackathon submissions
Monitor costs: Apillon uses pay-per-use model
Test locally first: Always test builds before deploying
Restart your IDE: After MCP configuration changes (Claude Desktop or Cursor)
Check MCP connection: Verify Apillon MCP server is properly connected before deployment
WRITING GUIDELINES FOR LLMs
When creating documentation or helping developers:
TROUBLESHOOTING CHECKLIST
First: Try kitdot@latest init with fresh project and copy existing code
When deployment fails, check:
LIMITATIONS AND WORKAROUNDS
Current Limitations
Contract Size: 100KB bytecode limit
OpenZeppelin: Most libraries too large
Network Stability: Preview release, potential downtime
Debugging Tools: Limited compared to mainnet
Documentation: Sparse, community-driven solutions
Recommended Workarounds
Size Issues: Use minimal custom implementations
Complex Logic: Split across multiple contracts
State Management: Use events for off-chain data
User Experience: Provide clear error messages
Testing: Extensive local testing before deployment
This guide provides comprehensive information for successful smart contract deployment to Paseo TestNet using Claude Code, including all critical configurations, common issues, and optimization strategies.
Última actualización
