Skip to content

xmtplabs/xmtp-agent-examples / skills/handling-transactions

handling-transactions

Verified

Token transactions and wallet integration for XMTP agents. Use when sending USDC, creating transaction requests, or handling transaction confirmations. Triggers on USDC transfer, wallet calls, or transaction reference.

FileKindSize
SKILL.mdskill md3.9 KB
rules/balance-check.mdmarkdown2.0 KB
rules/receive-transaction-reference.mdmarkdown1.6 KB
rules/send-usdc-transfer.mdmarkdown1.5 KB

rules/receive-transaction-reference.md

View on GitHub
---
title: Handle transaction confirmations
impact: CRITICAL
tags: transactions, reference, confirmation
---

## Handle transaction confirmations

Use the `transaction-reference` event to handle completed transactions.

**Basic handler:**

```typescript
agent.on("transaction-reference", async (ctx) => {
  const transactionRef = ctx.message.content;
  
  await ctx.conversation.sendText(
    `βœ… Transaction confirmed!\n` +
    `πŸ”— Network: ${transactionRef.networkId}\n` +
    `πŸ“„ Hash: ${transactionRef.reference}`
  );
});
```

**Coinbase Wallet compatibility:**

Coinbase Wallet incorrectly wraps transaction references. Handle both formats:

```typescript
agent.on("transaction-reference", async (ctx) => {
  // Handle both standard and Coinbase's nested format
  // Standard: { networkId, reference, metadata }
  // Coinbase: { transactionReference: { networkId, reference, metadata } }
  
  // @ts-expect-error - Coinbase Wallet wraps incorrectly
  let transactionRef = ctx.message.content.transactionReference;
  if (transactionRef?.transactionReference) {
    transactionRef = transactionRef.transactionReference;
  } else {
    transactionRef = ctx.message.content;
  }

  console.log("Network:", transactionRef.networkId);
  console.log("Hash:", transactionRef.reference);
  
  if (transactionRef.metadata) {
    console.log("Metadata:", transactionRef.metadata);
  }
});
```

**Transaction reference structure:**

```typescript
interface TransactionReference {
  networkId: string;      // e.g., "base-sepolia"
  reference: string;      // Transaction hash
  metadata?: {
    // Optional transaction metadata
  };
}
```
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why β€” repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" β€” or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself β€” your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall