githubEditar

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

  1. Must use string format for Solidity version: solidity: "0.8.28"

  2. Must include resolc configuration: Required for PolkaVM compatibility

  3. Must set polkavm: true: In all network configurations

  4. Must use hardhat vars: For private key management

  5. Network name: Use passetHub (not paseo or other names)

SETUP PROCESS

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

  1. Visit https://faucet.polkadot.io/?parachain=1111

  2. Enter your wallet address

  3. Request PAS tokens

  4. 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

Step 1: Create Ignition Module

Step 2: Compile Contracts

Step 3: Deploy to Paseo

Deployment States

  • Clean State: rm -rf ignition/deployments/ to start fresh

  • Resume: 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: true in network config

  • Add 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 --force flag

  • Clear 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_KEY

  • Ensure 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

  1. Successful Deployment Output:

  1. Block Explorer Verification:

  • Visit https://blockscout-passet-hub.parity-testnet.parity.io

  • Search for contract address

  • Verify contract creation transaction

  1. Contract Interaction Test:

DEBUGGING STRATEGIES

Check Network Connectivity

Verify Account Balance

Clean Build and Deploy

Transaction Tracking

If deployment fails:

  1. Check block explorer for account transactions

  2. Look for failed transactions with gas errors

  3. Use npx hardhat ignition track-tx <txHash> <deploymentId> --network passetHub

BEST PRACTICES

Development Workflow

  1. Start Simple: Deploy basic contracts first to verify setup

  2. Optimize Early: Check contract sizes during development

  3. Test Locally: Use local hardhat network for initial testing

  4. Incremental Deployment: Deploy components separately if too large

  5. Document Addresses: Keep track of all deployed contract addresses

Contract Design for Paseo

  1. Minimize Dependencies: Avoid heavy libraries

  2. Custom Implementations: Write minimal versions of standard contracts

  3. Modular Design: Split functionality across multiple contracts

  4. Gas Optimization: Use efficient data structures and algorithms

  5. Proxy Patterns: Consider upgradeable contracts for complex logic

Security Considerations

  1. Private Key Management: Always use hardhat vars, never commit keys

  2. Test Network Only: Paseo is for testing, not production value

  3. Code Verification: Verify contracts on block explorer when possible

  4. 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:

  1. Visit Apillon Console: https://app.apillon.io

  2. Register Account: Use email and create secure password

  3. Verify Email: Complete email verification process

  4. Connect Wallet: Link your Polkadot/Substrate wallet for payments

  5. Generate API Credentials:

    • Go to SettingsAPI 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:

  1. Navigate to Hosting Section: In Apillon console

  2. Create New Website: Click "New Website" button

  3. Configure Project:

  4. Copy Website UUID: After creation, copy the generated UUID (format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)

  5. 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:

  1. Locate MCP config file: Usually at ~/Library/Application Support/Claude/claude_desktop_config.json (macOS)

  2. Add Apillon server: Insert the configuration above

  3. Replace placeholders: Update <APILLON_API_KEY> and <APILLON_API_SECRET> with actual values

  4. Update filesystem path: Change /Users/your-username/Desktop to your project directory

  5. Restart Claude Desktop: Required for MCP changes to take effect

For Cursor IDE:

Cursor MCP Setup:

  1. Install MCP extension: In Cursor, go to Extensions and search for "Model Context Protocol"

  2. Open Cursor settings: Cmd/Ctrl + , → Search "MCP"

  3. Add server configuration:

Cursor Configuration Steps:

  1. Open settings.json: Cmd/Ctrl + Shift + P → "Preferences: Open Settings (JSON)"

  2. Add MCP configuration: Insert the above configuration

  3. Replace placeholders: Update API credentials

  4. Restart Cursor: Required for MCP changes to take effect

  5. 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

  1. Configure MCP first: Set up Apillon MCP server in your IDE (Claude Desktop or Cursor) before starting the deployment.

  2. Always use latest Apillon CLI: npm install -g @apillon/cli@latest

  3. Secure credentials: Store API keys and UUIDs as environment variables, never in code

  4. Guide user through account setup: Clearly instruct users on Apillon account creation and API key generation

  5. Verify deployments: Always check deployment status after upload

  6. Use production environment: For final hackathon submissions

  7. Monitor costs: Apillon uses pay-per-use model

  8. Test locally first: Always test builds before deploying

  9. Restart your IDE: After MCP configuration changes (Claude Desktop or Cursor)

  10. 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

  • 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