Under 10 minutes
First agent payment
on Ergo testnet.
No theory. No setup ceremony. One npm package, 30 lines, one command — and you see a real transaction on Ergo testnet explorer.
bash
npm install @fleet-sdk/core
Prerequisites
- Node.js 18+ installed
- A testnet address (create one in Nautilus wallet → Settings → Testnet mode)
- Testnet ERG from faucet at testnet.ergofaucet.org
- 5 minutes of uninterrupted focus
01
Install Fleet SDK
~30 secondsbash
mkdir my-agent && cd my-agent npm init -y npm install @fleet-sdk/core node-fetch
Fleet SDK is the official TypeScript/JS SDK for Ergo. Works in Node.js and browsers.
02
Create agent-pay.js
~2 minutesjavascript
// agent-pay.js
import { TransactionBuilder, OutputBuilder, SAFE_MIN_BOX_VALUE } from "@fleet-sdk/core";
// ── Config ───────────────────────────────────────────────────────────────────
const TESTNET_API = "https://api-testnet.ergoplatform.com";
const YOUR_ADDRESS = "YOUR_TESTNET_ADDRESS"; // paste your testnet address
const RECEIVER_ADDRESS = "3WwbzW6u8hKWBcL1W7kNVMr25s2UHfSBnYtwSHvrRQt7DdPuoXrt"; // testnet receiver
// ── 1. Fetch unspent boxes ────────────────────────────────────────────────────
const res = await fetch(
`${TESTNET_API}/api/v1/boxes/unspent/byAddress/${YOUR_ADDRESS}`
);
const { items: inputs } = await res.json();
// ── 2. Build transaction ──────────────────────────────────────────────────────
const unsignedTx = new TransactionBuilder(await getCurrentHeight())
.from(inputs)
.to(
new OutputBuilder("1000000", RECEIVER_ADDRESS) // 0.001 ERG
)
.sendChangeTo(YOUR_ADDRESS)
.payMinFee()
.build()
.toEIP12Object();
console.log("Unsigned TX:", JSON.stringify(unsignedTx, null, 2));
// → Sign with Nautilus wallet or server-side key, then submit
async function getCurrentHeight() {
const r = await fetch(`${TESTNET_API}/api/v1/info`);
const info = await r.json();
return info.fullHeight;
}This script fetches your testnet UTxOs, builds a transaction, and outputs the unsigned TX object.
03
Run the script
~10 secondsbash
node agent-pay.js
You'll see the unsigned transaction JSON. Sign it with Nautilus (browser) or a server-side key, then POST to /api/v1/transactions.
04
Add a Note (agent payment)
~5 minutesjavascript
// Note payment — agent pays for an API call
import { TransactionBuilder, OutputBuilder, SByte, SColl } from "@fleet-sdk/core";
const TASK_HASH = "a1b2c3d4..."; // blake2b256 of task output
const noteOutput = new OutputBuilder("5000000", RECEIVER_ADDRESS) // 0.005 ERG
.setAdditionalRegisters({
R4: SColl(SByte, Buffer.from(TASK_HASH, "hex")), // task hash
R5: SByte(await getCurrentHeight() + 100), // expiry: +100 blocks
});
const tx = new TransactionBuilder(await getCurrentHeight())
.from(inputs)
.to(noteOutput)
.sendChangeTo(YOUR_ADDRESS)
.payMinFee()
.build();This extends the basic TX to create a Note — a bearer instrument with a task hash register. The receiver redeems it against a Reserve.
See your TX on explorer
After submitting, your transaction appears on Ergo testnet explorer. Paste your TX ID at:
https://testnet.ergoplatform.com/transactions/{TX_ID}