New:Microsoft Teams Notifications Are Now Available in Socket.Learn more →
Get Started

@txn-dev/sdk

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@txn-dev/sdk

Payments for AI agents. Wallets, idempotent transfers, and hiring humans with escrowed payment.

latest
Source
npmnpm
Version
0.3.1
Version published
Maintainers
1
Created
Source

@txn-dev/sdk

TypeScript SDK for txn.dev - payments infrastructure for AI agents.

Install

npm install @txn-dev/sdk

Usage

import { Txn } from "@txn-dev/sdk";

const txn = new Txn("txn_live_...");

// Create wallets for your agents
const sender = await txn.wallets.create({ name: "coordinator" });
const worker = await txn.wallets.create({ name: "translator" });

// Pay for completed work
const tx = await txn.pay({
  from: sender.id,
  to: worker.id,
  amount: 0.003,
  memo: "translated 340 words en>fr",
});

// List all wallets
const wallets = await txn.wallets.list();

// Get a specific wallet
const wallet = await txn.wallets.get(sender.id);

// Fund a wallet via Stripe
const { checkout_url } = await txn.fund({
  wallet_id: sender.id,
  amount: 50,
});

API Reference

new Txn(apiKey, options?)

Create a client. Options:

  • baseUrl - Override API URL (default: https://txn.dev/api)

txn.wallets.create({ name, currency?, metadata? })

Create a wallet. Currency defaults to "usd". Supports "usd", "eur", "gbp".

txn.wallets.list()

List all wallets in your organization.

txn.wallets.get(id)

Get a single wallet by ID.

txn.pay({ from, to, amount, memo?, idempotency_key?, metadata? })

Transfer funds between wallets. Settles in ~4ms. Supports sub-cent amounts up to 8 decimal places.

Pass an idempotency_key for safe retries.

txn.fund({ wallet_id, amount })

Generate a Stripe checkout URL to fund a wallet. Amount range: $20 - $100,000.

Error Handling

import { Txn, TxnError } from "@txn-dev/sdk";

try {
  await txn.pay({ from: "...", to: "...", amount: 100 });
} catch (err) {
  if (err instanceof TxnError) {
    console.log(err.message); // "Insufficient balance"
    console.log(err.status);  // 400
  }
}

License

MIT

Keywords

ai-agents

FAQs

Package last updated on 02 Sep 2026

Related posts