← Back to blog

Platform-Specific Deployment Guides for Fetch.ai Autonomous Agents

March 16, 2026
Fetch.ai autonomous agent code generationPlatform-specific deployment guidesAI agent discovery file generation

Platform-Specific Deployment Guides for Fetch.ai Autonomous Agent Code Generation

TL;DR: Quick Overview

Fetch.ai autonomous agent code generation requires platform-specific deployment configurations for different environments. This guide covers deploying agents across mainnet, testnet, and local networks, including AI agent discovery file generation, configuration management, and validation procedures. Each platform requires unique setup steps, environment variables, and endpoint configurations to ensure proper agent functionality and discoverability.

Introduction

Fetch.ai has emerged as a leading platform for creating autonomous agents that operate within decentralized networks. Deploying Fetch.ai autonomous agents requires understanding platform-specific requirements, whether you're targeting the mainnet for production use, testnet for validation, or local environments for development.

Proper deployment ensures your autonomous agents can register with the network, discover other agents, and execute transactions seamlessly. This guide walks through the complete deployment process across multiple platforms, focusing on practical implementation details and common pitfalls to avoid.

Prerequisites Before Starting

Before deploying Fetch.ai autonomous agents, ensure you have:

  • Python 3.8 or higher installed on your system

  • Fetch.ai agent framework (fetchai/agents package version 0.10.0 or later)

  • Access to an RPC endpoint for your target network (mainnet or testnet)

  • A wallet with sufficient funds for transaction fees (testnet tokens for testing)

  • Git for version control and repository management

  • Node.js and npm installed if you're integrating with web services

  • Basic understanding of agent-oriented development concepts

  • An IDE or text editor (VS Code, PyCharm, or similar)


Verify your Python installation:
```bash
python --version
```

Install the Fetch.ai agents package:
```bash
pip install fetchai[agents]
```

Step 1: Understand Platform-Specific Architecture

Fetch.ai operates across three distinct deployment environments, each with unique characteristics:

Testnet Environment


  • Network ID: `testnet-v2`

  • RPC Endpoint: `https://testnet-fetch.allthatnode.com:1317`

  • Chain ID: `fetch-testnet`

  • Block time: Approximately 5 seconds

  • Use case: Development, testing, and validation

  • Faucet: Available for obtaining test tokens


Mainnet Environment


  • Network ID: `mainnet`

  • RPC Endpoint: `https://mainnet-fetch.allthatnode.com:1317`

  • Chain ID: `fetchhub-4`

  • Block time: Approximately 6 seconds

  • Use case: Production deployment with real transactions

  • Validator set: 100+ active validators


Local Environment


  • Network setup: Standalone local node using Docker

  • RPC Endpoint: `http://localhost:26657`

  • Instant finality: Blocks finalize immediately

  • Use case: Rapid development iteration and debugging

  • Reset capability: Complete state reset between sessions


Understanding these differences prevents deployment failures and ensures your agents operate correctly in each environment.

Step 2: Configure Your Development Environment

Create a project directory structure for your Fetch.ai autonomous agent:

```bash
mkdir fetch-agent-deployment
cd fetch-agent-deployment
```

Initialize a Python virtual environment:

```bash
python -m venv agent_env
source agent_env/bin/activate # On Windows: agent_env\Scripts\activate
```

Create a `requirements.txt` file with essential dependencies:

```
fetchai[agents]==0.14.0
fetchai-cli==0.3.0
python-dotenv==1.0.0
requests==2.31.0
aiohttp==3.9.0
```

Install dependencies:

```bash
pip install -r requirements.txt
```

Create a `.env` file for environment-specific configuration:

```
NETWORK_NAME=testnet
RPC_ENDPOINT=https://testnet-fetch.allthatnode.com:1317
CHAIN_ID=fetch-testnet
PRIVATE_KEY=your_private_key_here
AGENT_NAME=MyAutonomousAgent
AGENT_PORT=8000
```

Important: Add `.env` to your `.gitignore` to prevent accidental credential exposure:

```bash
echo ".env" >> .gitignore
```

Step 3: Generate AI Agent Discovery File

The AI agent discovery file enables other agents and services to locate and interact with your autonomous agent. This file contains critical metadata for platform-specific deployment.

Create a file named `agent_config.json`:

```json
{
"name": "MyAutonomousAgent",
"version": "1.0.0",
"description": "An autonomous agent for decentralized operations",
"agent_address": "agent1qf4xk6zfjpxg2jcxd2nq5nwl3h7k8v9j2m3n4p5q6r7s8t9u0v1w2x3y4z5",
"network": {
"name": "fetch-testnet",
"chain_id": "fetch-testnet",
"rpc_endpoint": "https://testnet-fetch.allthatnode.com:1317"
},
"endpoints": [
{
"name": "default",
"url": "http://localhost:8000",
"port": 8000
}
],
"services": [
{
"name": "info",
"description": "Provides agent information",
"protocol": "http"
}
],
"capabilities": [
"data_processing",
"transaction_execution",
"agent_discovery"
],
"registration": {
"registered": true,
"registration_timestamp": "2024-01-15T10:30:00Z"
}
}
```

This discovery file serves as the agent's identity document on the network, containing:

  • Agent address: Unique identifier derived from your wallet

  • Network configuration: Platform-specific RPC endpoints

  • Service endpoints: URLs where the agent can be reached

  • Capabilities: Functions the agent can perform

  • Service registration: Proof of network registration


For testnet deployment, use the testnet RPC endpoint. For mainnet, update the endpoint to production-grade infrastructure.

Step 4: Create Your Agent Code with Platform-Specific Configuration

Create the main agent file `my_agent.py`:

```python
import os
from dotenv import load_dotenv
from fetchai import Context
from fetchai.agents import Agent, Bureau
from fetchai.network import get_network

load_dotenv()

Load configuration from environment


NETWORK_NAME = os.getenv("NETWORK_NAME", "testnet")
RPC_ENDPOINT = os.getenv("RPC_ENDPOINT")
CHAIN_ID = os.getenv("CHAIN_ID")
PRIVATE_KEY = os.getenv("PRIVATE_KEY")
AGENT_NAME = os.getenv("AGENT_NAME")
AGENT_PORT = int(os.getenv("AGENT_PORT", 8000))

Configure network parameters


NETWORK_CONFIG = {
"testnet": {
"rpc_endpoint": "https://testnet-fetch.allthatnode.com:1317",
"chain_id": "fetch-testnet",
"network_prefix": "agent"
},
"mainnet": {
"rpc_endpoint": "https://mainnet-fetch.allthatnode.com:1317",
"chain_id": "fetchhub-4",
"network_prefix": "agent"
},
"local": {
"rpc_endpoint": "http://localhost:26657",
"chain_id": "fetchhub-4",
"network_prefix": "agent"
}
}

config = NETWORK_CONFIG.get(NETWORK_NAME, NETWORK_CONFIG["testnet"])

Initialize agent with platform-specific configuration


agent = Agent(
name=AGENT_NAME,
port=AGENT_PORT,
network=config["chain_id"],
private_key=PRIVATE_KEY
)

@agent.on_message(model="Request")
async def handle_request(ctx: Context, sender: str, msg: dict):
"""
Handle incoming requests from other agents.
"""
ctx.logger.info(f"Received request from {sender}: {msg}")

response = {
"status": "success",
"agent_name": AGENT_NAME,
"network": NETWORK_NAME,
"message": f"Response from {AGENT_NAME}"
}

await ctx.send(sender, response)

if __name__ == "__main__":
print(f"Starting {AGENT_NAME} on {NETWORK_NAME}")
print(f"RPC Endpoint: {config['rpc_endpoint']}")
print(f"Chain ID: {config['chain_id']}")
agent.run()
```

This code demonstrates:

  • Dynamic network configuration based on deployment target

  • Environment variable loading for credential security

  • Platform-specific RPC endpoints for each network

  • Agent initialization with proper chain IDs

  • Message handling for agent-to-agent communication


Step 5: Register Your Agent on the Network

Agent registration makes your autonomous agent discoverable on the Fetch.ai network.

Create a registration script named `register_agent.py`:

```python
import json
import os
from dotenv import load_dotenv
from fetchai.network import get_network

load_dotenv()

NETWORK_NAME = os.getenv("NETWORK_NAME")
PRIVATE_KEY = os.getenv("PRIVATE_KEY")
AGENT_NAME = os.getenv("AGENT_NAME")

Load agent configuration


with open("agent_config.json", "r") as f:
agent_config = json.load(f)

Update configuration with current network


agent_config["network"]["name"] = NETWORK_NAME

if NETWORK_NAME == "mainnet":
agent_config["network"]["rpc_endpoint"] = "https://mainnet-fetch.allthatnode.com:1317"
agent_config["network"]["chain_id"] = "fetchhub-4"
elif NETWORK_NAME == "local":
agent_config["network"]["rpc_endpoint"] = "http://localhost:26657"
agent_config["network"]["chain_id"] = "fetchhub-4"
else:
agent_config["network"]["rpc_endpoint"] = "https://testnet-fetch.allthatnode.com:1317"
agent_config["network"]["chain_id"] = "fetch-testnet"

print(f"Registering {AGENT_NAME} on {NETWORK_NAME}...")
print(f"Configuration: {json.dumps(agent_config, indent=2)}")

Register agent (implementation depends on your network configuration)


This is a placeholder for actual registration logic


print("Agent registration initiated. Awaiting confirmation...")
```

Run the registration:

```bash
python register_agent.py
```

Step 6: Deploy to Testnet

Testnet deployment allows you to validate your agent before production release.

Update your `.env` file:

```
NETWORK_NAME=testnet
RPC_ENDPOINT=https://testnet-fetch.allthatnode.com:1317
CHAIN_ID=fetch-testnet
PRIVATE_KEY=your_testnet_private_key
AGENT_NAME=TestAutonomousAgent
AGENT_PORT=8000
```

Obtain testnet tokens from the faucet:

```bash
curl -X POST https://testnet-fetch.allthatnode.com/faucet \
-H "Content-Type: application/json" \
-d '{"address": "agent1your_address_here"}'
```

Start your agent:

```bash
python my_agent.py
```

Verify deployment:

```bash
curl http://localhost:8000/info
```

Expected response:

```json
{
"status": "running",
"agent_name": "TestAutonomousAgent",
"network": "testnet",
"port": 8000
}
```

Step 7: Deploy to Mainnet

Mainnet deployment requires production-ready configurations and security measures.

Security Considerations

  • Use hardware wallets for private key management

  • Implement rate limiting on agent endpoints

  • Enable TLS/SSL for all network communications

  • Monitor gas fees to prevent excessive transaction costs

  • Implement circuit breakers for fault tolerance


Update `.env` for mainnet:

```
NETWORK_NAME=mainnet
RPC_ENDPOINT=https://mainnet-fetch.allthatnode.com:1317
CHAIN_ID=fetchhub-4
PRIVATE_KEY=your_mainnet_private_key
AGENT_NAME=ProductionAutonomousAgent
AGENT_PORT=8000
```

Create a production configuration file `production_config.yaml`:

```yaml
agent:
name: ProductionAutonomousAgent
port: 8000
log_level: INFO

network:
name: mainnet
rpc_endpoint: https://mainnet-fetch.allthatnode.com:1317
chain_id: fetchhub-4

security:
tls_enabled: true
rate_limit: 1000
timeout_seconds: 30

monitoring:
enabled: true
prometheus_port: 9090
```

Deploy using Docker for production environments:

Create `Dockerfile`:

```dockerfile
FROM python:3.10-slim

WORKDIR /app

COPY requirements.txt .
RUN pip install -r requirements.txt

COPY . .

EXPOSE 8000

CMD ["python", "my_agent.py"]
```

Build and run:

```bash
docker build -t fetch-agent:latest .
docker run -p 8000:8000 --env-file .env fetch-agent:latest
```

Step 8: Validate Deployment and Test Agent Discovery

After deployment, validate that your agent functions correctly and is discoverable.

Create a validation script `validate_deployment.py`:

```python
import requests
import json
from datetime import datetime

def validate_agent(agent_url: str, network: str) -> dict:
"""
Validate agent deployment and discovery file generation.
"""
validation_results = {
"timestamp": datetime.now().isoformat(),
"network": network,
"checks": []
}

# Check 1: Agent responds to health check
try:
response = requests.get(f"{agent_url}/health", timeout=5)
validation_results["checks"].append({
"name": "Health Check",
"status": "PASS" if response.status_code == 200 else "FAIL",
"details": response.text
})
except Exception as e:
validation_results["checks"].append({
"name": "Health Check",
"status": "FAIL",
"details": str(e)
})

# Check 2: Agent discovery file accessible
try:
with open("agent_config.json", "r") as f:
config = json.load(f)
validation_results["checks"].append({
"name": "Discovery File",
"status": "PASS",
"agent_address": config.get("agent_address")
})
except Exception as e:
validation_results["checks"].append({
"name": "Discovery File",
"status": "FAIL",
"details": str(e)
})

# Check 3: Network connectivity
try:
response = requests.get(f"{agent_url}/network-info", timeout=5)
validation_results["checks"].append({
"name": "Network Connectivity",
"status": "PASS",
"network_info": response.json()
})
except Exception as e:
validation_results["checks"].append({
"name": "Network Connectivity",
"status": "FAIL",
"details": str(e)
})

return validation_results

if __name__ == "__main__":
results = validate_agent("http://localhost:8000", "testnet")
print(json.dumps(results, indent=2))
```

Run validation:

```bash
python validate_deployment.py
```

Common Mistakes to Avoid

Mistake 1: Incorrect RPC Endpoints


Problem: Using wrong RPC endpoint for the target network causes connection failures.

Solution: Double-check RPC endpoints against official Fetch.ai documentation. Use dedicated node providers with high uptime:

  • Testnet: `https://testnet-fetch.allthatnode.com:1317`

  • Mainnet: `https://mainnet-fetch.allthatnode.com:1317`


Mistake 2: Missing Private Key Management


Problem: Hardcoding private keys in source code exposes credentials to attackers.

Solution: Always use environment variables or secure vaults. Implement `.env` files for local development and AWS Secrets Manager or HashiCorp Vault for production.

Mistake 3: Insufficient Gas Estimation


Problem: Transactions fail due to inadequate gas fees.

Solution: Implement dynamic gas price calculation:

```python
def estimate_gas(transaction_type: str) -> int:
gas_prices = {
"agent_registration": 50000,
"message_send": 20000,
"contract_interaction": 100000
}
return gas_prices.get(transaction_type, 30000)
```

Mistake 4: Neglecting Discovery File Updates


Problem: Outdated discovery files prevent proper agent discovery.

Solution: Implement automatic discovery file refresh after agent startup:

```python
async def refresh_discovery_file():
with open("agent_config.json", "r+") as f:
config = json.load(f)
config["registration"]["registration_timestamp"] = datetime.now().isoformat()
f.seek(0)
json.dump(config, f, indent=2)
f.truncate()
```

Mistake 5: No Error Handling for Network Failures


Problem: Agent crashes when network conditions are poor.

Solution: Implement retry logic with exponential backoff:

```python
import asyncio

async def send_with_retry(message: dict, max_retries: int = 3) -> bool:
for attempt in range(max_retries):
try:
# Send message logic
return True
except Exception as e:
wait_time = 2 attempt
print(f"Attempt {attempt + 1} failed. Retrying in {wait_time}s...")
await asyncio.sleep(wait_time)
return False
```

Monitoring and Maintenance

Implement continuous monitoring for deployed agents:

```python
import logging
from datetime import datetime

logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[
logging.FileHandler('agent.log'),
logging.StreamHandler()
]
)

logger = logging.getLogger(__name__)

def log_agent_metrics(agent_name: str, network: str, uptime: int):
logger.info(
f"Agent: {agent_name} | Network: {network} | Uptime: {uptime}s"
)
```

Set up alerts for:

  • Agent downtime exceeding 5 minutes

  • RPC endpoint latency above 2 seconds

  • Failed transactions exceeding 10% of total

  • Insufficient wallet balance for gas fees


Key Takeaways

  • Platform-specific deployment requires understanding testnet, mainnet, and local network configurations

  • AI agent discovery file generation creates the network identity for your autonomous agent

  • Environment-based configuration using `.env` files prevents credential exposure

  • Proper registration makes your agent discoverable to other network participants

  • Validation before mainnet deployment prevents costly production failures

  • Security measures like private key management and TLS are essential for production

  • Continuous monitoring ensures agent reliability and performance
  • Conclusion

    Successful Fetch.ai autonomous agent deployment requires careful attention to platform-specific requirements. Whether deploying to testnet for validation or mainnet for production, following these steps ensures your agents are properly configured, registered, and discoverable within the Fetch.ai ecosystem.

    For advanced configurations and troubleshooting, consult the official Fetch.ai documentation and community resources. Platforms like agentseo.guru provide additional guidance on optimizing agent discovery and network visibility for maximum effectiveness.