Beta Environment Notice
TDM is currently in Beta. Exercise caution when handling assets. Use at your own risk.
Fast Export
Switch the current page to Markdown for fast agent reading, or download it as a .md file.
TDM is currently in Beta. Exercise caution when handling assets. Use at your own risk.
Fast Export
Switch the current page to Markdown for fast agent reading, or download it as a .md file.
# TDM SDK Reference Summary: Reference page for the current TDM SDK surface. This page covers payable wrappers, framework-mode helpers, smart CLI flows, Session Gas Tank billing, seller payouts, and protocol-first examples. Status: Beta - All Features Active Topics: - TDM SDK documentation - tdm-sdk reference - makePayable - framework-mode - createFetchHookClient - Session Gas Tank - seller payouts - protocol-first integrations - Local402Circuit - LocalVault - SolanaJupiterSweeper - BaseOdosSweeper - runtime synchronization Packages: - tdm-sdk Commands: - tdm connect - tdm doctor - tdm where - tdm status - tdm workspace status - tdm agent status - tdm storage add media ./seller-storage --use - tdm workspace create seller-lab --storage media --use - tdm storage publish ./catalog --mode tunnel - tdm signer serve - tdm fuel - tdm make payable - tdm sweep - tdm sweep status - tdm cashout - tdm agent - tdm stats
tdm-sdk is the main developer surface for TDM. It includes both the SDK APIs and the built-in tdm CLI.
npm i tdm-sdk is the same command in short form.
npm install tdm-sdkYou can also use npm i -g tdm-sdk.
npm install -g tdm-sdktdm connect
tdm doctor
tdm where
tdm status
tdm storage add media ./seller-storage --use
tdm workspace create seller-lab --storage media --use
tdm workspace status
tdm mcp
tdm mcp servetdm storage import-dir ./products/docs --storage media
tdm storage sync ./products/docs --storage media --prune
tdm storage publish ./products/docs --storage media --mode tunnel
tdm workspace create seller-lab --storage media --use
tdm workspace attach-agent seller-lab worker-1
tdm where
tdm status
tdm agent status worker-1
tdm make payable --asset <asset-id> --storage media --price 0.05These are the core components of tdm-sdk that are fully operational in the current Beta.
import { createFetchHookClient, makePayable } from 'tdm-sdk'
const hooks = createFetchHookClient({
baseUrl: 'https://tdm.todealmarket.com',
})
const run = makePayable(
async (input: string) => `processed:${input}`,
{
operation: 'demo:process',
tokenOrUuid: 'local-demo',
hooks,
},
)
const result = await run('hello')
console.log(result)The SDK now also ships a lighter integration layer for teams that want a friendlier API over the current live gateway contract without switching to a fake monolithic runtime.
import { createAuthorizeClient } from 'tdm-sdk/authorize'
import { createSessionTanksClient } from 'tdm-sdk/session-tanks'
import { createCheckoutClient } from 'tdm-sdk/checkout'
import { createPayoutsClient } from 'tdm-sdk/payouts'
const authorize = createAuthorizeClient({
baseUrl: 'https://tdm.todealmarket.com',
sessionToken: process.env.TDM_SESSION_TOKEN,
})
const tanks = createSessionTanksClient({
baseUrl: 'https://tdm.todealmarket.com',
rootId: process.env.TDM_ROOT_ID,
})
const checkout = createCheckoutClient({
baseUrl: 'https://tdm.todealmarket.com',
})
const payouts = createPayoutsClient({
baseUrl: 'https://tdm.todealmarket.com',
})import { createAuthorizeClient } from 'tdm-sdk/authorize'
import { createCheckoutClient } from 'tdm-sdk/checkout'
const authorize = createAuthorizeClient({
baseUrl: 'https://tdm.todealmarket.com',
sessionToken: process.env.TDM_SESSION_TOKEN,
})
const checkout = createCheckoutClient({
baseUrl: 'https://tdm.todealmarket.com',
})
await authorize.authorizePayment({
requestId: 'req_demo_1',
tokenOrUuid: 'demo-user',
operation: 'demo:run',
priceUsd: '0.05',
})
await checkout.createSession({
resourceId: 'res_demo_123',
chain: 'solana',
})import { createGatewayClients, createTelemetryContext } from 'tdm-sdk'
const clients = createGatewayClients({
baseUrl: 'https://tdm.todealmarket.com',
sessionToken: process.env.TDM_SESSION_TOKEN,
})
const telemetry = createTelemetryContext({
scope: 'sdk.authorize',
attributes: {
integration_path: 'facade',
},
})
await clients.authorize.authorizePayment({
requestId: 'req_demo_2',
tokenOrUuid: 'demo-user',
operation: 'demo:run',
})
console.log(telemetry.event('request_started'))If you want Solana browser wallets to keep signing while your SDK runtime broadcasts through a faster RPC, pass an explicit rpcUrl or set TDM_SOLANA_RPC_URL / SOLANA_RPC_URL.
import {
SolanaWalletAdapter,
createFetchHookClient,
makePayable,
} from 'tdm-sdk'
const wallet = new SolanaWalletAdapter({
rpcUrl: 'https://mainnet.helius-rpc.com/?api-key=YOUR_KEY',
})
const hooks = createFetchHookClient({
baseUrl: 'https://tdm.todealmarket.com',
})
const run = makePayable(
async () => {
return { ok: true }
},
{
operation: 'demo:solana-tool',
tokenOrUuid: 'demo-solana-tool',
hooks,
},
)
await wallet.connect()
const result = await run()
console.log(result)If you want provider keys or custom RPC URLs to survive terminal restarts and npm upgrades, use tdm env instead of relying on a one-off shell export. Project scope writes.env.local in the current repo. Session scope prints a ready-to-run command for your current shell.
tdm env status
tdm env set helius YOUR_HELIUS_KEY
tdm env set solana-rpc https://mainnet.helius-rpc.com/?api-key=YOUR_HELIUS_KEY
tdm env set reown YOUR_REOWN_PROJECT_ID
tdm env set 0x YOUR_ZEROX_KEY
# One terminal session only
tdm env set reown YOUR_REOWN_PROJECT_ID --scope session --shell powershellBeyond wrapping plain functions with makePayable(...), the SDK now exposes framework-mode helpers so developers can charge directly at the route layer in the style of Next.js, Hono, Elysia, Express, or Deno handlers.
import { chargeFetchHandler, createFetchHookClient } from 'tdm-sdk'
const hooks = createFetchHookClient({
baseUrl: 'https://tdm.todealmarket.com',
})
export const POST = chargeFetchHandler(
{
operation: 'demo:chat',
priceUsd: '0.10',
resourceId: 'https://api.example.com/chat',
tokenResolver: (request) => request.headers.get('x-tdm-token') ?? 'anonymous',
hooks,
},
async () => Response.json({ ok: true }),
)The CLI now auto-detects whether you passed a local file or a public URL. Local files default to serve. Public URLs default to url. Serve mode stays local-only; use --public-url when the resource should sync to the gateway.
tdm make payable ./agent-route.ts --price 0.05
tdm make payable https://api.example.com/premium/route --price 0.05
tdm make payable ./agent-route.ts --price 0.05 --mode url --public-url https://api.example.com/premium/route
tdm make payable ./tool-output.json --price 0.05 --mode url --public-url https://cdn.example.com/tool-output.json --max-downloads 3
tdm make payable paid-note --price 0.05 --inline-file ./note.md --delivery-content-type text/markdown
tdm make payable ./premium-route.ts --price 0.05 --billing-mode session_gas_tankUse the SDK function inside code when you want to wrap a route handler, tool function, or framework endpoint directly in your application code.
Use the CLI when the faster path is resource registration: a public URL, a hosted API, a file, or a paid unlock flow that should go live without adding new wrapper code first.
tdm connect
tdm make payable https://api.example.com/library/query --price 0.02 --name "My Library API"
tdm share resource_key_hereAdvanced users can run a localhost-only signer daemon backed by LocalVault when they want custom local scripts to request signatures without exporting keys.
tdm signer serve
tdm signer serve --vault photos --port 41011GET /v1/health
GET /v1/agents
GET /v1/limits/:agent
POST /v1/sign/root
POST /v1/sign/agent/:agentRequired header for non-health endpoints:
X-TDM-Signer-Token: <token>
Built-in hardening:
- localhost host validation
- forwarded-header rejection
- Fetch Metadata checks
- Origin / Referer checksTDM supports two charging modes: normal account balance and prepaid session_gas_tank. In both cases the request stays streamlined, and seller credits accumulate duringPOST /authorize for later payout requests.
account mode:
- debit user's general balance
session_gas_tank mode:
- debit prepaid agent/session tank
seller settlement:
- buyer debit happens during POST /authorize
- seller credits accumulate
- seller later requests payout via POST /publisher/payoutstdm payout wallets set --solana <solana_address> --base 0xabc...
tdm payout wallets status
tdm payout request --amount 20 --chain solana
tdm payout request --amount 20 --chain baseRe-running tdm payout wallets set replaces the saved wallet for the chain you pass. During one-time onboarding,tdm connect also attempts a safe default sync for the connected wallet when that chain slot is still empty. If a wallet is already saved for the requested chain, --to becomes optional on tdm payout request.
tdm payout auto status
tdm payout auto set --enable --min-amount 25 --every-days 3
tdm payout auto disableThe public CLI now includes a dedicated tdm security surface. The default profile is already active for new accounts, and advanced users can review or change that profile deliberately when they need a wider operating envelope.
Default paid request limits:
- $10 per paid action
- $25 per hour
- $100 per day
Default payout limits:
- $100 per payout
- $500 per day
Default payout hold:
- 24 hours for larger payouts
- starts at $100 by default
Default sensitive-action posture:
- extra confirmation for payouts
- extra confirmation for security changes
- extra confirmation for new payout destinationstdm security settings
tdm security methods
tdm security totp enroll
tdm security totp verify --method-id <id> --code 123456
tdm security challenge create
tdm security challenge verify --id <challenge-id> --code 123456
tdm security settings settdm trust verify domain --target api.example.com --resource res_demo123
tdm trust verify github --target github.com/your-org/your-repo --resource res_demo123
tdm allowlist verified
tdm allowlist add api.example.com --verified
tdm allowlist add api.example.com --scope vault --vault seller-bot --verified
tdm allowlist check https://api.example.com/private/route
tdm allowlist listSee the current limits, payout hold rules, and whether the account is still using the default profile or an advanced one.
Enroll an authenticator app so higher-risk changes and payout actions can be approved with an extra code.
Use a short-lived challenge when changing important account settings or confirming a more sensitive payout flow.
Raise or lower limits deliberately when your workflow needs it, without removing the public safety model entirely.
Keep public proof separate from local policy. Verify a domain or GitHub target first, then decide whether that host belongs in the local allowlist used by guarded agents and runtime routes.
Use tdm allowlist check on a concrete URL before you let an agent or guarded runtime depend on it. That keeps route policy explicit and fast to review.
tdm stats gives developers a quick view of local usage and payment status. For teams that use structured reporting, tdm analytics export remains part of the public CLI surface.
tdm stats
tdm analytics export --format json --dataset summaryFor stacks that do not have a native SDK yet, TDM now ships a protocol-first HTTP contract plus minimal examples for multiple languages.
Available protocol-first examples:
- Python
- Go
- Java
- Rust
- C
- C++
Public API:
- https://tdm.todealmarket.com
- https://tdm.todealmarket.com/authorizeimport { Local402Circuit, LocalVault } from 'tdm-sdk'
const circuit = new Local402Circuit()
const key = Local402Circuit.key('demo:op', 'user-123')
// Local retry record tracking
const backoff = circuit.record402(key)
console.log(backoff)
const vault = new LocalVault()
await vault.ensureInitialized()
await vault.setGatewayUrl('https://tdm.todealmarket.com')
await vault.setSessionId('sess_beta_123')
const runtime = await vault.getRuntimeCredentials()
console.log(runtime)The local vault now supports a root vault plus agent sub-vaults. Agent vaults are created locally, kept in the OS keyring, and booted into short-lived session tokens instead of exposing private keys to runtimes.
Hard cap per agent vault. Ideal for bounded tasks.
Monthly cap funded by the root vault when the agent depletes.
tdm vault create photos --use
tdm vault current
tdm agent spawn <name> --type DISCRETE --limit <amount>
tdm agent spawn <name> --type AUTO_REFILL --cap <amount>
tdm agent list
tdm agent status <name>
tdm agent revoke <name>
tdm agent boot <name>
tdm signer serve --vault photos --port 41011Recovery flows are fully integrated with the TDM ecosystem. The CLI and SDK support automated sweeps for depleted session states.
import { BaseOdosSweeper, SolanaJupiterSweeper } from 'tdm-sdk'
const solanaSweeper = new SolanaJupiterSweeper({
tdmTreasuryAddress: 'TREASURY_SOLANA_ADDRESS',
jupiterApiKey: process.env.JUPITER_API_KEY,
jupiterApiUrl: 'https://api.jup.ag/swap/v1',
})
const baseSweeper = new BaseOdosSweeper({
tdmEvmTreasuryAddress: '0xabc...',
odosApiKey: process.env.ODOS_API_KEY,
})tdm sweep --network solana --mode burner --deposit-address <solana_address>
tdm sweep --network base --mode wallet --project-id wc_xxx --treasury 0xabc...tdm sweep is strictly for conversion (memecoins → USDC → destination wallet or local target agent). Returning stablecoin leftovers to an external wallet is handled by tdm cashout.
tdm cashout
tdm cashout --to <address>
tdm cashout --agent vault1
tdm cashout --agents vault1,vault2