Tether WDK + Observer Protocol

Add self-custodial USDT (Ethereum/Polygon) and Bitcoin wallets to your agent with full Observer Protocol identity verification. ~25 minutes.

v0.2.0-beta.4 · June 2026
@observer-protocol/wdk-protocol-trust@0.2.0-beta.4 now ships the AIP v0.8 spending-mandate surface alongside the bilateral-handshake flow below. The new four-call pattern — verifyMandatewithinScopewallet.sendattest — lets a WDK agent verify a signed delegation credential, gate a proposed spend against its actionScope (per-tx ceiling, allowed rails, allowed categories, authorization-level rules), and emit a portable settlement attestation. See the runnable examples/mandate-flow.mjs and the README §AIP v0.8 mandate surface. Steps below cover the v0.1-era handshake surface, which continues to ship alongside the v0.2 mandate surface — pick the one that matches your flow.

For pre-sign policy enforcement on the now-merged WDK #55 hook, use @observer-protocol/wdk-op-policy (the local transaction policy engine adapter): it registers an ALLOW plus a mandatory fail-closed DENY and refuses an out-of-mandate spend before the key signs. Live demo: observerprotocol.org/wdk.
Ethereum
USDT
Polygon
USDT
Bitcoin
BTC
1

Install Dependencies

Install the WDK packages and the Observer Protocol WDK adapter:

npm install @tetherto/wdk @tetherto/wdk-wallet-evm @tetherto/wdk-wallet-btc
npm install @observer-protocol/wdk-op-policy

Changed 2026-08-03. This step used to say @observerprotocol/sdk, which is a different npm scope, deprecated and unmaintained since April. The adapter above is the package this quickstart actually uses, and it is the one under active release.

Note: The WDK uses native modules for cryptography. Make sure you have Python and build tools installed. On most systems: npm install -g node-gyp

2

Generate or Import Seed Phrase

The WDK uses BIP-39 seed phrases for deterministic key generation. You can generate a new one or import an existing mnemonic:

Unverified, 8 August 2026. This example imported AgentWallet from @observerprotocol/sdk — the scope Step 1's own correction above removes. So the page installed one set of packages and imported from another, in a scope it flags as wrong fifteen lines earlier. The import has been removed rather than repointed: no Observer Protocol package we publish exports AgentWallet, and guessing a replacement would repeat the mistake. Treat the block below as illustrative until the correct import is established.

// import { AgentWallet } from '<unresolved — see note above>';

// Generate new seed phrase (save this securely!)
const seedPhrase = AgentWallet.generateSeedPhrase();
console.log('Seed phrase:', seedPhrase);
// → "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"

// Or use existing seed
const wallet = new AgentWallet({
  seedPhrase: process.env.WDK_SEED_PHRASE,
  agentId: 'my-agent-001',
  alias: 'trading-bot-alpha'
});

⚠️ Security: Store your seed phrase in a secure environment variable. Never commit it to code. The WDK keeps private keys in memory only — no external storage.

3

Initialize Wallets

Initialize wallets for the chains you need. Each chain is initialized on-demand:

// Initialize WDK
await wallet.initializeWDK();

// Initialize Ethereum wallet (for USDT on Ethereum)
const ethWallet = await wallet.initWallet('ethereum', {
  provider: process.env.ETHEREUM_RPC_URL // Optional, defaults to public RPC
});

// Initialize Polygon wallet (for USDT on Polygon - lower fees!)
const polyWallet = await wallet.initWallet('polygon', {
  provider: process.env.POLYGON_RPC_URL
});

// Initialize Bitcoin wallet
const btcWallet = await wallet.initWallet('bitcoin', {
  host: 'bitcoin.lukechilds.co',
  port: 50001,
  protocol: 'tcp'
});

console.log('ETH address:', ethWallet.address);
console.log('BTC address:', btcWallet.address);
4

Register with Observer Protocol<
Unverified derivation, 9 August 2026. The snippet below hashes the DER-encoded SPKI bytes of a secp256k1 key and keeps all 64 hex characters. That is not how Observer Protocol derives an agent id. The documented derivation is agent_id = sha256(public_key_hex)[:32] — the first 32 characters, over the hex string, on an Ed25519 key — and the docs page warns explicitly that hashing the bytes instead of the hex string "yields a different id and a DID that will not resolve". Real agent identifiers on this protocol are 32 characters.

Left in place rather than repointed: this page's wallet.register() call was not exercised, so which value that method actually wants is not established here, and substituting one would repeat the mistake Step 2's own note above records. Use the docs derivation if you need an id that resolves.
/h3>

Register your agent to establish identity and enable bilateral verification:

import crypto from 'crypto';

// Generate a keypair for Observer Protocol identity
// (This is separate from your wallet keys for security isolation)
const identityKey = crypto.generateKeyPairSync('ec', { namedCurve: 'secp256k1' });
const publicKeyHash = crypto
  .createHash('sha256')
  .update(identityKey.publicKey.export({ format: 'der', type: 'spki' }))
  .digest('hex');

// Register agent
await wallet.register({
  alias: 'trading-bot-alpha',
  publicKeyHash: publicKeyHash,
  metadata: {
    description: 'USDT payment agent',
    supportedChains: ['ethereum', 'polygon', 'bitcoin'],
    wdkEnabled: true
  }
});

console.log('✅ Agent registered on Observer Protocol');

5

Send Verified Payments

Send payments with automatic bilateral identity verification. Both sender and recipient must be registered on Observer Protocol:

// Check if recipient is verified
const recipientCheck = await wallet.checkRecipient('merchant-bot-beta');
console.log('Recipient verified:', recipientCheck.verified);

// Send USDT on Polygon (fast, cheap)
const payment = await wallet.verifiedSend({
  recipientAlias: 'merchant-bot-beta',
  amount: '10.00',  // 10 USDT
  chain: 'polygon',
  token: 'USDT'
});

console.log('Payment result:', payment);
// {
//   success: true,
//   verification: { alias, publicKeyHash, ... },
//   payment: { txid, status, amount, recipient, chain, ... }
// }

Bilateral Verification: The recipient's identity is verified before payment executes. The payment object includes both the transaction hash and the verification proof.

6

Verify a delegation, gate the spend, and attest the settlement (AIP v0.8)

For agents acting under a signed delegation credential — the typical pattern for autonomous machine commerce — use @observer-protocol/wdk-protocol-trust v0.2.0-beta.4 to verify the delegation, gate the proposed spend against its actionScope, and emit a portable settlement attestation. Four method calls. OP never touches funds.

npm install @observer-protocol/wdk-protocol-trust
import ObserverTrustProtocol from '@observer-protocol/wdk-protocol-trust';

const op = new ObserverTrustProtocol(wallet, {
  trustedIssuers: ['did:web:observerprotocol.org'],
  attestationKey,   // 32-byte Ed25519 secret. DISTINCT from the WDK wallet key.
  // gate: optional — defaults to AdvisoryGate (client-side gating).
  // WdkPolicyHookGate rides the merged WDK PR #55 policy hook (see @observer-protocol/wdk-op-policy).
});

// 1. Verify the delegation credential (did:web resolve, Ed25519Signature2026,
//    schema allowlist pinned to delegation/v2.1.json, validity window).
const mandate = await op.verifyMandate(agentCredential);

// 2. Gate the proposed action against actionScope. Pure, I/O-free:
//    rail / per_transaction_ceiling (same-currency only, no FX) /
//    allowed_transaction_categories / authorizationLevel-gated rules.
const proposedAction = {
  rail: 'usdt_tron',
  amount: { amount: '10', currency: 'USDT' },
  category: 'ai_inference_credits',
  counterparty_did: 'did:web:vendor.example:agents:store'
};
const decision = await op.withinScope(proposedAction, mandate);
if (!decision.allow) {
  throw new Error('mandate violation: ' + JSON.stringify(decision.reasons));
}

// 3. WDK executes settlement. OP never touches funds.
const tx = await wallet.send(/* … */);

// 4. Sign a portable ObserverSettlementAttestation binding
//    {delegation hash, action, settlement ref, evaluator, timestamp}
//    with the agent's attestation key (Ed25519Signature2026).
const attestation = await op.attest({
  credential: agentCredential,
  action: proposedAction,
  settlement: { rail: 'usdt_tron', ref: tx.id }
});

console.log('✅ Settlement attested:', attestation.id);

cumulative_budget, allowed_counterparty_types, geographic_restriction are reserved as advisory in AIP v0.8 — verifiers surface them but they never ground a deny. Binding semantics for each are reserved for a future draft. See the runnable examples/mandate-flow.mjs for the full self-contained flow including a self-issued demo credential.

7

Direct Send (No Verification)

For payments to non-registered addresses, use direct send:

// Send to any address (no OP verification)
const result = await wallet.send({
  to: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
  amount: '5.00',
  chain: 'ethereum',
  token: 'USDT'
});

console.log('Transaction hash:', result.hash);

// Send Bitcoin
const btcResult = await wallet.send({
  to: 'bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh',
  amount: '0.001',
  chain: 'bitcoin'
});

console.log('BTC txid:', btcResult.txid);
8

Mainnet Beta Checklist

Before deploying to mainnet beta:

  • Use your own RPC endpoints (avoid public nodes for mainnet beta)
  • Get API keys from Etherscan/Polygonscan for verification
  • Store seed phrases in secure environment variables or KMS
  • Set up monitoring for transaction status
  • Implement retry logic for failed transactions
  • Consider using Polygon for USDT (much lower fees than Ethereum)
  • Test on Sepolia testnet first: USDT_CONTRACTS.sepolia

Need Help?

Join the Observer Protocol community for support, share your implementation, or contribute to the SDK.

GitHub → Open Agentic Terminal →