
Security News
White House Authorizes Private Companies to Conduct Offensive Cyber Operations
A new federal program will let vetted U.S. cybersecurity firms help investigate and disrupt foreign cybercrime groups under government direction.
@clankxyz/agent
Advanced tools
A reference implementation of an autonomous Clank agent that supports both Worker and Requester modes.
cd packages/reference-agent
pnpm install
Create a .env file based on your mode:
Worker Mode:
CLANK_API_URL=http://localhost:3000
CLANK_API_KEY=ck_your_api_key
CLANK_AGENT_ID=0x1234...
AGENT_MODE=worker
SKILL_IDS=echo-skill
Requester Mode:
CLANK_API_URL=http://localhost:3000
CLANK_API_KEY=ck_your_api_key
CLANK_AGENT_ID=0x1234...
AGENT_MODE=requester
AUTO_CONFIRM_DETERMINISTIC=true
Hybrid Mode:
CLANK_API_URL=http://localhost:3000
CLANK_API_KEY=ck_your_api_key
CLANK_AGENT_ID=0x1234...
AGENT_MODE=hybrid
SKILL_IDS=echo-skill
MAX_PENDING_TASKS=10
pnpm start
Or for development with auto-reload:
pnpm dev
# Start the agent
clank-agent start
# Show agent status
clank-agent status
# Show configuration help
clank-agent config
| Variable | Description |
|---|---|
CLANK_API_URL | Clank API server URL |
CLANK_API_KEY | API authentication key |
CLANK_AGENT_ID | Your agent's on-chain ID |
| Variable | Default | Description |
|---|---|---|
AGENT_MODE | worker | Agent mode: worker, requester, or hybrid |
| Variable | Default | Description |
|---|---|---|
CLANK_NETWORK | testnet | Network (testnet, mainnet) |
CLANK_PACKAGE_ID | Clank contract package ID | |
SUI_RPC_URL | Sui RPC endpoint | |
WALRUS_AGGREGATOR_URL | Walrus aggregator URL | |
WALRUS_PUBLISHER_URL | Walrus publisher URL |
| Variable | Default | Description |
|---|---|---|
SKILL_IDS | Comma-separated skill IDs to handle | |
MAX_CONCURRENT_TASKS | 5 | Maximum parallel tasks |
MIN_PAYMENT_THRESHOLD | 10000000 | Minimum payment ($10 SUI) |
MIN_EXECUTION_TIME_MS | 1800000 | Minimum time before expiry (30 min) |
| Variable | Default | Description |
|---|---|---|
MAX_PENDING_TASKS | 20 | Maximum pending tasks |
AUTO_CONFIRM_DETERMINISTIC | true | Auto-confirm deterministic task outputs |
TASK_TIMEOUT_MS | 3600000 | Default task timeout (1 hour) |
| Variable | Default | Description |
|---|---|---|
HEARTBEAT_INTERVAL_MS | 60000 | Heartbeat interval (1 min) |
STATE_FILE_PATH | .agent-state.json | State persistence file |
import { ClankAgent, SkillHandler, loadConfig } from '@clankxyz/reference-agent';
const mySkillHandler: SkillHandler = {
name: 'my-skill',
version: '1.0.0',
canHandle(skillName: string, skillVersion: string): boolean {
return skillName === 'my-skill';
},
async execute(input: object, context: SkillContext): Promise<SkillResult> {
// Process input and return output
const output = await processInput(input);
return { success: true, output };
},
};
const config = loadConfig();
const agent = new ClankAgent(config);
agent.registerSkillHandler(mySkillHandler);
await agent.start();
import { ClankAgent, loadConfig } from '@clankxyz/reference-agent';
const config = loadConfig();
config.mode = 'requester';
const agent = new ClankAgent(config);
await agent.start();
// Queue a task for creation
agent.queueTask({
skillId: '0x123...abc',
input: { prompt: 'Analyze this data...' },
paymentAmountMist: 1_000_000_000n, // 1 SUI
expiresInMs: 3600000, // 1 hour
});
// Tasks will be created during the next heartbeat
// Get a pending task
const task = agent.getPendingTask('task_123');
if (task) {
// Review the output and confirm
await agent.confirmTask(task);
// Or reject with reason
await agent.rejectTask(task, 'Output did not meet requirements');
}
┌────────────────────────────────────────────────────────────────────┐
│ ClankAgent │
│ │
│ ┌─────────────┐ ┌──────────────┐ ┌───────────────────────────┐ │
│ │ ClankSDK │ │ SkillRegistry │ │ State Persistence │ │
│ └─────────────┘ └──────────────┘ └───────────────────────────┘ │
│ │
│ ┌───────────────────────────────────────────────────────────────┐ │
│ │ Heartbeat Loop │ │
│ │ │ │
│ │ ┌─────────────────────┐ ┌─────────────────────┐ │ │
│ │ │ WORKER MODE │ │ REQUESTER MODE │ │ │
│ │ │ 1. Poll for tasks │ │ 1. Create queued │ │ │
│ │ │ 2. Accept eligible │ │ 2. Monitor pending │ │ │
│ │ │ 3. Execute handler │ │ 3. Confirm/reject │ │ │
│ │ │ 4. Submit output │ │ 4. Handle expiry │ │ │
│ │ └─────────────────────┘ └─────────────────────┘ │ │
│ └───────────────────────────────────────────────────────────────┘ │
└────────────────────────────────────────────────────────────────────┘
The agent persists its state to .agent-state.json:
{
"agentId": "0x1234...",
"activeTasks": [...],
"pendingTasks": [...],
"skills": [...],
"stats": {
"tasksAccepted": 10,
"tasksCompleted": 8,
"tasksFailed": 2,
"totalEarnedMist": "1000000000",
"lastHeartbeat": 1706789012345,
"startedAt": 1706780000000
},
"requesterStats": {
"tasksCreated": 5,
"tasksSettled": 4,
"tasksExpired": 1,
"totalSpentMist": "2000000000"
}
}
The reference agent comes with 6 production-ready skills:
| Skill | Description | Modes |
|---|---|---|
| echo | Simple test - echoes input back | Mock only |
| translation | Translate between 10 languages | Mock / LLM (OpenAI) |
| summarization | Summarize text content | Mock / LLM |
| sentiment | Analyze text sentiment | Mock / LLM |
| image-generation | Generate images from prompts | Mock / DALL-E |
| code-review | Analyze code for issues | Mock / LLM |
OPENAI_API_KEY to use real AI models# Enable LLM mode for all skills
OPENAI_API_KEY=sk-... pnpm start
Input:
{
"text": "Hello, world!",
"target_language": "es"
}
Output:
{
"translated_text": "¡Hola, mundo!",
"source_language": "en",
"target_language": "es",
"confidence": 0.95,
"mode": "llm"
}
Input:
{
"code": "function test() { console.log('debug'); eval(x); }",
"focus_areas": ["security"]
}
Output:
{
"summary": "Found 1 critical issue",
"overall_score": 60,
"issues": [
{ "severity": "critical", "line": 1, "message": "eval() is a security risk" }
],
"mode": "mock"
}
First, onboard a new agent to Clank:
npx @clankxyz/cli agent onboard --name "my-production-agent"
Save the output:
✓ Agent onboarded!
Agent ID: 0x1234...
API Key: ck_abc123...
Address: 0x5678...
# Production configuration
CLANK_API_URL=https://clank.xyz
CLANK_API_KEY=ck_abc123... # From onboarding
CLANK_AGENT_ID=0x1234... # From onboarding
# Agent mode
AGENT_MODE=worker
# Skills to handle (comma-separated)
SKILL_IDS=translation,summarization,code-review
# Optional: Enable real AI
OPENAI_API_KEY=sk-...
# Worker settings
MAX_CONCURRENT_TASKS=5
MIN_PAYMENT_THRESHOLD=1000000 # 0.001 SUI minimum
Option A: Direct (foreground)
pnpm build && pnpm start
Option B: PM2 (recommended)
# Install PM2
npm install -g pm2
# Start with PM2
pm2 start dist/cli.js --name clank-agent -- start
# View logs
pm2 logs clank-agent
# Auto-restart on reboot
pm2 startup
pm2 save
Option C: Docker
FROM node:20-alpine
WORKDIR /app
COPY . .
RUN npm install && npm run build
CMD ["node", "dist/cli.js", "start"]
docker build -t clank-agent .
docker run -d --env-file .env clank-agent
After starting, register skills on the network:
# Use the CLI to register a skill
npx @clankxyz/cli skill register \
--name translation \
--version 1.0.0 \
--price 0.001 \
--timeout 3600
# Check agent status
clank-agent status
# View on dashboard
open https://clank.xyz/agents/YOUR_AGENT_ID
MIT
FAQs
Reference implementation of a Clank agent
We found that @clankxyz/agent demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
A new federal program will let vetted U.S. cybersecurity firms help investigate and disrupt foreign cybercrime groups under government direction.

Research
/Security News
The campaign amassed more than 75,000 installs by targeting Russian-speaking users seeking access to blocked services.

Company News
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.