Developer Resources

This guide provides developers with quick access to TAP implementation resources, including TypeScript types, JSON schemas, and usage examples.

Quick Start

TypeScript/JavaScript

Install the official TAP types package:

npm install @taprsvp/types

Basic usage:

import { Transfer, DIDCommMessage } from '@taprsvp/types';

// Create a transfer message
const transfer: Transfer = {
  "@context": "https://tap.rsvp/schema/1.0",
  "@type": "Transfer",
  asset: "eip155:1/erc20:0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", // USDC on Ethereum
  amount: "1000.00",
  settlementAddress: "eip155:1:0x1234567890123456789012345678901234567890",
  originator: {
    "@type": "Party",
    name: "Alice Smith"
  },
  agents: [
    {
      "@type": "Agent",
      did: "did:web:example.com",
      role: "originator"
    }
  ]
};

// Wrap in DIDComm envelope
const message: DIDCommMessage<Transfer> = {
  id: "550e8400-e29b-41d4-a716-446655440000",
  type: "https://tap.rsvp/schema/1.0#Transfer",
  from: "did:web:originator.com",
  to: ["did:web:beneficiary.com"],
  created_time: Date.now(),
  body: transfer
};

JSON Schema Validation

Using with JavaScript

const Ajv = require('ajv');
const addFormats = require('ajv-formats');

// Initialize validator
const ajv = new Ajv();
addFormats(ajv);

// Fetch and compile schema
async function validateTransfer(transferMessage) {
  const response = await fetch('https://taips.tap.rsvp/schemas/messages/transfer.json');
  const schema = await response.json();
  
  const validate = ajv.compile(schema);
  const valid = validate(transferMessage);
  
  if (!valid) {
    console.error('Validation errors:', validate.errors);
    return false;
  }
  return true;
}

Direct Schema URLs

All schemas are available at https://taips.tap.rsvp/schemas/:

Message Schemas

  • Transfer: https://taips.tap.rsvp/schemas/messages/transfer.json
  • Payment: https://taips.tap.rsvp/schemas/messages/payment.json
  • Authorize: https://taips.tap.rsvp/schemas/messages/authorize.json
  • Settle: https://taips.tap.rsvp/schemas/messages/settle.json
  • View all message schemas

Data Structure Schemas

  • Party: https://taips.tap.rsvp/schemas/data-structures/party.json
  • Agent: https://taips.tap.rsvp/schemas/data-structures/agent.json
  • Policy: https://taips.tap.rsvp/schemas/data-structures/policy.json
  • Invoice: https://taips.tap.rsvp/schemas/data-structures/invoice.json

Common Type Schemas

  • Base Types: https://taips.tap.rsvp/schemas/common/base-types.json
  • CAIP Types: https://taips.tap.rsvp/schemas/common/caip-types.json
  • DIDComm Base: https://taips.tap.rsvp/schemas/common/didcomm-base.json

Message Types Reference

Transaction Messages

Transfer

Initiates a virtual asset transfer between parties.

import { Transfer } from '@taprsvp/types';

const transfer: Transfer = {
  "@context": "https://tap.rsvp/schema/1.0",
  "@type": "Transfer",
  asset: "eip155:1/erc20:0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
  amount: "1000.00",
  originator: { "@type": "Party", name: "Alice" },
  beneficiary: { "@type": "Party", name: "Bob" },
  agents: [/* agent details */]
};

Payment

Requests payment with optional invoice details.

import { Payment } from '@taprsvp/types';

const payment: Payment = {
  "@context": "https://tap.rsvp/schema/1.0",
  "@type": "Payment",
  amount: "99.99",
  currency: "USD",
  merchant: { "@type": "Party", name: "Example Store" },
  agents: [/* agent details */]
};

Authorization Flow Messages

  • Authorize: Approves a transaction
  • Settle: Confirms on-chain settlement
  • Reject: Rejects a transaction with reason
  • Cancel: Cancels an ongoing transaction
  • Revert: Requests transaction reversal

Agent Management Messages

  • UpdateAgent: Updates agent information
  • UpdateParty: Updates party information
  • AddAgents: Adds new agents to transaction
  • ReplaceAgent: Replaces an existing agent
  • RemoveAgent: Removes an agent

Connection Messages

  • Connect: Establishes agent connection
  • AuthorizationRequired: Requests authorization for connection
  • ConfirmRelationship: Confirms party-agent relationship
  • UpdatePolicies: Updates agent policies

Common Patterns

Creating DIDComm Messages

All TAP messages follow the DIDComm v2 format:

import { DIDCommMessage, Transfer } from '@taprsvp/types';

function createDIDCommMessage<T>(
  body: T,
  type: string,
  from: string,
  to: string[]
): DIDCommMessage<T> {
  return {
    id: crypto.randomUUID(),
    type,
    from,
    to,
    created_time: Date.now(),
    body
  };
}

// Usage
const transfer: Transfer = { /* transfer details */ };
const message = createDIDCommMessage(
  transfer,
  "https://tap.rsvp/schema/1.0#Transfer",
  "did:web:sender.com",
  ["did:web:receiver.com"]
);

Working with CAIP Identifiers

TAP uses Chain Agnostic Improvement Proposals (CAIPs) for blockchain-agnostic identifiers:

import { CAIP2, CAIP10, CAIP19 } from '@taprsvp/types';

// Blockchain identifier (CAIP-2)
const ethereum: CAIP2 = "eip155:1"; // Ethereum mainnet
const bitcoin: CAIP2 = "bip122:000000000019d6689c085ae165831e93"; // Bitcoin mainnet

// Account identifier (CAIP-10)
const ethAccount: CAIP10 = "eip155:1:0x1234567890123456789012345678901234567890";
const btcAccount: CAIP10 = "bip122:000000000019d6689c085ae165831e93:1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa";

// Asset identifier (CAIP-19)
const usdc: CAIP19 = "eip155:1/erc20:0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48";
const nft: CAIP19 = "eip155:1/erc721:0x06012c8cf97BEaD5deAe237070F9587f8E7A266d";

Policy Examples

import { RequirePresentation, RequirePurpose } from '@taprsvp/types';

// Require KYC credential presentation
const kycPolicy: RequirePresentation = {
  "@type": "RequirePresentation",
  credentialType: "KYCCredential",
  from: "originator"
};

// Require transaction purpose
const purposePolicy: RequirePurpose = {
  "@type": "RequirePurpose",
  required: ["purpose", "categoryPurpose"]
};

Testing and Validation

Validate Against Test Vectors

Clone the TAIPs repository and run the validation script:

git clone https://github.com/TransactionAuthorizationProtocol/TAIPs.git
cd TAIPs/schemas
npm install
npm run validate

Create Your Own Test Vectors

const fs = require('fs');

// Create a test vector
const testVector = {
  id: "test-001",
  type: "https://tap.rsvp/schema/1.0#Transfer",
  from: "did:web:test.com",
  to: ["did:web:recipient.com"],
  created_time: 1234567890,
  body: {
    "@context": "https://tap.rsvp/schema/1.0",
    "@type": "Transfer",
    asset: "eip155:1/erc20:0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
    amount: "100.00",
    agents: [{
      "@type": "Agent",
      did: "did:web:test.com",
      role: "originator"
    }]
  }
};

// Save test vector
fs.writeFileSync('test-transfer.json', JSON.stringify(testVector, null, 2));

Implementation Libraries

Rust Implementation

A Rust implementation of TAP is available for systems programming and high-performance applications:

  • Repository: tap-rs
  • Features: Full TAP protocol implementation in Rust

IVMS101 TypeScript Types

TypeScript definitions for IVMS101 (InterVASP Messaging Standard) used in Travel Rule compliance:

  • Repository: ivms101
  • NPM Package: @notabene/ivms101
  • Usage: Required for TAIP-10 Travel Rule implementation

Example usage with Travel Rule data:

import { NaturalPerson } from '@notabene/ivms101';
import { Party } from '@taprsvp/types';

const originator: Party = {
  "@type": "Party",
  name: "Alice Smith",
  ivms101: {
    naturalPerson: {
      name: {
        nameIdentifier: [
          {
            primaryIdentifier: "Smith",
            secondaryIdentifier: "Alice",
            nameIdentifierType: "LEGL"
          }
        ]
      },
      nationalIdentification: {
        nationalIdentifier: "123456789",
        nationalIdentifierType: "DRLC", // Driver's License
        countryOfIssue: "US"
      }
    } as NaturalPerson
  }
};

ISO 20022 External Code Sets

TypeScript definitions for ISO 20022 purpose codes used in TAP transactions:

  • Repository: iso20022-external-code-sets
  • NPM Package: @taprsvp/iso20022_external_codes
  • Usage: Required for TAIP-13 Transaction Purpose Codes

Example usage with purpose codes:

import { Purpose, CategoryPurpose } from '@taprsvp/iso20022_external_codes';
import { Transfer } from '@taprsvp/types';

const transfer: Transfer = {
  "@context": "https://tap.rsvp/schema/1.0",
  "@type": "Transfer",
  asset: "eip155:1/erc20:0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
  amount: "1000.00",
  purpose: Purpose.CASH, // Cash Management Transfer
  categoryPurpose: CategoryPurpose.CASH, // Cash Transaction
  // ... other fields
};

Additional Resources

Getting Help