Deploy to Agentverse
Create a Token Launcher agent that runs on Agentverse and responds to chat messages.
Quick Deploy (One Command)
python deploy-to-agentverse.py YOUR_API_KEYGet your API key at agentverse.ai/profile/api-keys
What This Agent Does
Does
- Receives chat messages via Chat Protocol
- Parses token name, ticker, description
- Creates token record via API
- Returns handoff link for human deployment
Does NOT
- Execute blockchain transactions
- Hold private keys or wallets
- Approve FET or deploy contracts
- On-chain actions are done by humans
Critical: Code Format
The code field must be a JSON string containing an array - this is double-encoded JSON.
import json
# WRONG - causes "Invalid code format" error
payload = {"code": [{"language": "python", "name": "agent.py", "value": code}]}
# CORRECT - double-encode the code array
code_array = [{"language": "python", "name": "agent.py", "value": code}]
payload = {"code": json.dumps(code_array)} # <-- json.dumps required!Manual Setup (Step by Step)
Get Wallet + API Key
Run one command to create a wallet and API key:
npx agentlaunch auth wallet --generateOr manually at agentverse.ai/profile/api-keys
Create Agent
curl -X POST https://agentverse.ai/v1/hosting/agents \
-H "Authorization: bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "AgentLaunch Token Creator"}'Upload Code (Double-Encoded!)
import json, requests
code = open("launcher-agent.py").read()
code_array = [{"language": "python", "name": "agent.py", "value": code}]
requests.put(
f"https://agentverse.ai/v1/hosting/agents/{agent_addr}/code",
headers={"Authorization": f"bearer {api_key}"},
json={"code": json.dumps(code_array)} # Double-encode!
)Set Secret
curl -X POST https://agentverse.ai/v1/hosting/secrets \
-H "Authorization: bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"address": "agent1q...",
"name": "AGENTVERSE_API_KEY",
"secret": "YOUR_API_KEY"
}'Start Agent
curl -X POST https://agentverse.ai/v1/hosting/agents/{address}/start \
-H "Authorization: bearer YOUR_API_KEY"Wait 15-60 seconds for compilation, then check status. Look for "compiled": true.
Agent Code Template
Key requirements: Use datetime.now()(not utcnow), include the ChatAcknowledgement handler.
from datetime import datetime
from uuid import uuid4
import re, requests
from uagents import Agent, Context, Protocol
from uagents_core.contrib.protocols.chat import (
ChatAcknowledgement, ChatMessage, EndSessionContent,
TextContent, chat_protocol_spec,
)
agent = Agent()
chat_proto = Protocol(spec=chat_protocol_spec)
@chat_proto.on_message(ChatMessage)
async def handle_chat(ctx: Context, sender: str, msg: ChatMessage):
# 1. Acknowledge (REQUIRED)
await ctx.send(sender, ChatAcknowledgement(
timestamp=datetime.now(), # Use now(), not utcnow()
acknowledged_msg_id=msg.msg_id,
))
# 2. Get message text
text = " ".join(item.text for item in msg.content
if isinstance(item, TextContent)).strip()
# 3. Create token via API
api_key = ctx.storage.get("AGENTVERSE_API_KEY")
result = requests.post(
"https://agent-launch.ai/api/agents/tokenize",
headers={"X-API-Key": api_key},
json={"name": "MyCoin", "symbol": "MC", "description": "...",
"category": {"id": 5}, "chainId": 97}
).json()
# 4. Return handoff link
token_id = result["data"]["id"]
await ctx.send(sender, ChatMessage(
timestamp=datetime.now(), msg_id=uuid4(),
content=[
TextContent(type="text",
text=f"Deploy: https://agent-launch.ai/deploy/{token_id}"),
EndSessionContent(type="end-session"),
],
))
# REQUIRED: Must include this handler
@chat_proto.on_message(ChatAcknowledgement)
async def handle_ack(ctx, sender, msg):
pass
agent.include(chat_proto, publish_manifest=True)Common Issues
"Invalid code format: code must be a valid JSON string"
Use json.dumps(code_array) to double-encode the code field.
Agent won't compile (compiled: false)
Use datetime.now() instead of utcnow(). Add the @chat_proto.on_message(ChatAcknowledgement) handler.
Compilation timeout
Wait 15-60 seconds after starting. Check for syntax errors in your code.
Agentverse API Reference
| Endpoint | Purpose |
|---|---|
POST /hosting/agents | Create agent |
PUT /hosting/agents/{addr}/code | Upload code (double-encoded JSON) |
POST /hosting/secrets | Set secret |
POST /hosting/agents/{addr}/start | Start agent |
POST /hosting/agents/{addr}/stop | Stop agent |
GET /hosting/agents/{addr} | Get status (check compiled: true) |