Build Your First Autonomous Agent With Agntik in 10 Minutes
From zero to first confirmed payment in under ten minutes. No accounts. No KYC. No waiting.
This is a tutorial. By the end of it, you will have a working autonomous agent that can discover services, pay for them with Bitcoin over Lightning, and receive data — all without any human in the loop.
We will build three things in sequence: an agent that pays for a real-time BTC price feed, an agent that queries the Registry and pays autonomously, and an agent that creates a task and hires a human worker.
Total time: under ten minutes. Let's go.
Prerequisites
You need three things before you start.
Node.js v20 or higher. If you don't have it: brew install node@20 on Mac, or download from nodejs.org.
A Lightning wallet with a small amount of sats. Any non-custodial Lightning wallet works — Phoenix, Breez, or Mutiny. You need enough to fund your agent's initial balance. 10,000 sats is more than enough.
That's it. No accounts. No API keys from third parties. No KYC.
Step 1 — Install the SDK
npm install agntik-sdk
One command. The SDK is self-contained. Verify the installation:
node -e "const A = require('agntik-sdk'); console.log(typeof new A({ apiKey: 'test' }).pay)"
# → function
If you see 'function', the SDK is installed correctly.
Step 2 — Register Your Agent
Every agent needs an API key. The key links your agent to its Lightning identity and enforces budget controls.
import Agntik from 'agntik-sdk';
const agntik = new Agntik({ apiKey: 'bootstrap' });
const registration = await agntik.register({
name: 'my-first-agent',
budget: {
maxPerPayment: 1000, // max 1,000 sats per payment
maxPerHour: 5000, // max 5,000 sats per hour
maxPerDay: 20000 // max 20,000 sats per day
}
});
console.log('Agent ID:', registration.agent_id);
console.log('API Key:', registration.api_key);
// → Agent ID: agt_7f2a9b1c3d4e5f6a
// → API Key: ank_live_x8y9z0a1b2c3d4e5f6
Save the API key. You will use it for every subsequent operation. The budget controls are enforced automatically — your agent cannot spend more than the limits you set, regardless of what instructions it receives.
Step 3 — Fund Your Agent
Your agent needs sats to pay for services. Fund its Lightning address:
const agent = new Agntik({ apiKey: process.env.AGENT_KEY });
const { address, balance_sats } = await agent.balance();
console.log('Deposit address:', address);
console.log('Current balance:', balance_sats, 'sats');
Send sats to the deposit address from your Lightning wallet. The balance updates in seconds. For this tutorial, 1,000 sats is sufficient.
Step 4 — First Payment: BTC Price Feed
Now the interesting part. Your agent pays for real data.
const agent = new Agntik({ apiKey: process.env.AGENT_KEY });
console.log('Requesting BTC price...');
const result = await agent.pay({
service: 'btc-price-realtime',
maxSats: 50
});
console.log('Payment confirmed:', result.payment_id);
console.log('Amount:', result.amount_sats, 'sats');
console.log('Fee:', result.fee_sats, 'sats (0.1%)');
console.log('Data:', result.data);
// → Payment confirmed: pay_a1b2c3d4e5f6
// → Amount: 21 sats
// → Fee: 0.021 sats (0.1%)
// → Data: { price: 87432.50, currency: 'USD', timestamp: 1714300842 }
That's it. Your agent just paid for data over Lightning, autonomously, with no human in the loop. The payment confirmed in approximately 400 milliseconds.
Notice the fee: 0.021 sats. At current Bitcoin prices, that is a number too small to express meaningfully in fiat currency. This is what sub-cent infrastructure looks like in practice.
Step 5 — Autonomous Discovery
The previous example hardcoded the service name. This example lets the agent discover and choose the best available service on its own — without being told what exists.
const agent = new Agntik({ apiKey: process.env.AGENT_KEY });
// Agent queries the Registry — it has no idea what services exist
const { services } = await agent.discover({
category: 'datos-financieros',
maxPriceSats: 100
});
console.log('Services found:', services.length);
console.log('Best option:', services[0].name, '— score:', services[0].score);
// Agent pays for the highest-scored service automatically
const result = await agent.pay({
service: services[0].id,
maxSats: services[0].price_sats + 10
});
// → Services found: 5
// → Best option: btc-price-realtime — score: 94
// → Paid for: btc-price-realtime
This is autonomous discovery in action. The agent did not know that btc-price-realtime existed. It queried the Registry, received a list ordered by score and price, and selected the top result algorithmically, without human input.
Every time an agent makes this choice and the payment confirms, the winning service's score increments. Over thousands of agents making the same query, the scores converge on the true quality ranking. The Registry optimizes itself.
Step 6 — Check Your History
Every payment your agent makes builds its economic identity. Query the history:
const { transactions, count } = await agent.history({ limit: 10 });
console.log('Total transactions:', count);
transactions.forEach(tx => {
console.log(tx.created_at, tx.service_id, tx.amount_sats + ' sats', tx.status);
});
// → Total transactions: 2
// → 2026-04-28T10:23:41Z btc-price-realtime 21 sats confirmed
// → 2026-04-28T10:24:15Z btc-price-realtime 21 sats confirmed
This history is permanent. It is associated with your agent's Lightning public key. As the transaction count grows, the agent's reputation in the Registry builds. An agent with a long history of successful payments is treated differently than one with no history — not by arbitrary policy, but by the same score mechanism that governs services.
Step 7 — Hire a Human
The third flow is the one that has no equivalent anywhere else in the agentic payments space: an agent autonomously creating a task and paying a human worker upon completion.
const agent = new Agntik({ apiKey: process.env.AGENT_KEY });
const task = await agent.createTask({
description: 'Review this market analysis and classify the sentiment: ' +
'BTC broke resistance at 87k with high volume. ' +
'Institutional inflows accelerating. ETF net positive.',
rewardSats: 500,
deadline: '2h'
});
console.log('Task created:', task.task_id);
console.log('Reward:', task.reward_sats, 'sats');
console.log('Status:', task.status);
// → Task created: tsk_x9y8z7w6v5u4
// → Reward: 500 sats
// → Status: open
The task is now visible in the Registry's human task marketplace. A human worker queries the open tasks, picks this one up, completes the classification, and submits the result. The Agntik infrastructure verifies the submission and sends the Lightning payment to the worker's wallet automatically.
The agent did not know who would complete the task. The human worker did not need to know anything about the agent. The Registry matched them, the work was done, the payment was made — all without any bilateral relationship, any contract, or any human-to-human coordination.
Step 8 — Register Your Own Service
If you have an API that could be useful to other agents, register it in five lines:
const result = await agent.register({
name: 'my-sentiment-api',
description: 'Sentiment analysis for financial text, EN and ES',
category: 'inferencia',
priceSats: 42,
endpoint: 'https://api.yourservice.com/sentiment'
});
console.log('Service ID:', result.service_id);
console.log('Initial score:', result.score);
// → Service ID: svc_a1b2c3d4e5f6
// → Initial score: 50
// → Now discoverable by all agents in the Registry
Your service is now in the Registry. Every agent querying for inferencia services will find it. Every successful payment increments your score. Over time, your score is your reputation — verifiable, non-portable, built entirely from real economic behavior.
What You Just Built
In the last ten minutes, you built an agent that has a cryptographic identity and a Lightning balance, can discover services algorithmically without being told what exists, can pay for those services in 400 milliseconds with no human authorization, can hire human workers and pay them automatically upon completion, can monetize its own APIs by registering them in the Registry, and is accumulating an economic history that builds its reputation over time.
This is not a prototype or a proof of concept. This is production infrastructure running on the Bitcoin Lightning Network.
The agent you just built has economic autonomy. It can operate continuously, make thousands of transactions per hour, and never require human authorization for any individual payment.
The machines needed money. Now yours has some.
Next: Non-custodial by design — why Agntik never touches your funds →