Agents
Run agents from your own code
Every agent is reachable over plain HTTP (NDJSON stream) or the TypeScript SDK. The dashboard uses exactly these calls.
Match the dashboard
$0.05 per forecast in USDC or fUSD · $0.10 trading cap. Open trading dashboard →
TypeScript SDK
Ask what to buy, then run an agent and stream its events. The agent pays its data providers itself, from its own Hedera account, under its spend policy.
import { FinalityAgents } from './sdk'
import { x402Client } from '@x402/core/client'
import { wrapFetchWithPayment } from '@x402/fetch'
import { ExactHederaScheme } from '@x402/hedera/exact/client'
import { createClientHederaSigner } from '@x402/hedera'
import { PrivateKey } from '@hiero-ledger/sdk'
const baseUrl = 'https://finality.accuracy.wtf'
const finality = new FinalityAgents({ baseUrl })
const signer = createClientHederaSigner(process.env.HEDERA_ACCOUNT_ID!, PrivateKey.fromStringECDSA(process.env.HEDERA_PRIVATE_KEY!), { network: 'hedera:testnet' })
const client = x402Client.fromConfig({ schemes: [{ network: 'hedera:testnet', client: new ExactHederaScheme(signer) }] })
const paidFetch = wrapFetchWithPayment((input, init) => globalThis.fetch(input, init), client)
// Persist a different 64-hex funding id per wallet/agent; reuse it for retries.
// Create one with: crypto.randomBytes(32).toString('hex') in Node.
async function fundAndRun(agentId: string, input: { goal: string; symbol: string; horizonMinutes: number }, fundingId: string) {
const options = { ...input, asset: 'USDC' as const, budgetUsd: 0.1, fundingId }
const response = await paidFetch(baseUrl + '/api/agents/' + agentId + '/fund', {
method: 'POST', headers: { 'content-type': 'application/json' },
body: JSON.stringify({ ...options, payer: signer.accountId }),
})
const funded = await response.json()
if (!response.ok || !funded.success) throw new Error(funded.error?.message ?? 'Funding failed; retain the same funding id')
return finality.run(agentId, {
...options, budgetUsd: funded.data.budgetUsd,
onEvent: (e) => e.type === 'log' && console.log(e.line),
})
}
const trace = await fundAndRun('trader-intel', {
goal: 'Where will HBAR go in the next 30 minutes?', symbol: 'HBAR', horizonMinutes: 30,
}, process.env.FINALITY_FUNDING_ID!)
const call = FinalityAgents.forecastOf(trace) // direction, entry, stopLoss, takeProfits, probability…Stream events
| start | agent id, its Hedera account, model and budget |
| log | one human-readable progress line |
| tool | a tool call started or ended; paid calls carry operationId, USD and the Hedera transaction id |
| result | the trace as soon as paid data is in, before any LLM step: render it immediately |
| done | final trace: text, tool calls, spend, committee, explanation status |
| funding | remaining credit, refund amount/receipt, or pending confirmation |
| error | the failure reason; retain the funding id and check receipts before retrying |
Show results fast
Render on
result: it arrives right after the forecast is paid. The committee and explanation follow in done.Custom agents
Already available in the dashboard: Trading → Custom agents. Choose a watchlist, horizon, risk, allowed calls and budget, then create your profile.
Start with the trading agent
trader-intel is the built-in working template. The ETH scalper below is a custom profile derived from it, not a second independently provisioned identity. It inherits the template’s Hedera wallet, identity and payment controls.await finality.createAgent({
id: 'eth-scalper',
name: 'ETH scalper',
base: 'trader-intel', // reuses its wallet, identity and spend policy
symbols: ['ETH'], horizonMinutes: 10, riskProfile: 'aggressive',
budgetUsd: 0.1, maxPerCallUsd: 0.1,
operations: ['quant.forecast', 'quant.levels'],
strategies: ['breakout', 'momentum'],
committee: { debate: true, riskTeam: false },
style: 'detailed',
})
// Reuse fundAndRun from the SDK setup above. Persist a separate funding id for this agent.
const trace = await fundAndRun('eth-scalper', {
goal: 'Give me a conservative ETH trade for the next 10 minutes.', symbol: 'ETH', horizonMinutes: 10,
}, process.env.ETH_SCALPER_FUNDING_ID!)Agent identities
Provisioned base agents own Hedera accounts, HCS-11 profiles and HCS-10 messaging topics. Custom profiles reuse their base agent’s identity; the table shows the provisioned accounts.
| Agent | Account | HCS-11 profile | HCS-10 inbox |
|---|---|---|---|
| intelligence | 0.0.11342736 | 0.0.11342739 | 0.0.11342737 |
| trader-intel | 0.0.11340703 | 0.0.11340708 | 0.0.11340705 |