algorand-x402-typescript

Comprehensive guide for building x402 HTTP-native payment applications on Algorand using TypeScript. This is the parent skill that aggregates all TypeScript x402 sub-skills. Use when working with x402 payments in TypeScript/JavaScript, building clients, servers, facilitators, paywalls, or Next.js apps with Algorand x402, or when explaining x402 concepts to TypeScript developers. Strong triggers include "x402 TypeScript", "x402 Algorand TypeScript", "@x402-avm", "payment protocol TypeScript", "402 payment TypeScript", "x402 client fetch axios", "x402 server express hono", "x402 facilitator TypeScript", "x402 paywall", "x402 Next.js", "x402 core avm TypeScript", "explain x402 TypeScript", "teach x402".

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "algorand-x402-typescript" with this command: npx skills add algorand-devrel/algorand-agent-skills/algorand-devrel-algorand-agent-skills-explain-algorand-x402-typescript

x402 on Algorand - TypeScript

This is the aggregated parent skill for all x402 HTTP-native payment protocol skills targeting TypeScript/JavaScript. Use the reference files below to find detailed guidance for each component.

TypeScript Quick Start

# Core + AVM mechanism
npm install @x402-avm/core @x402-avm/avm algosdk

# Server middleware (pick one)
npm install @x402-avm/express    # Express.js
npm install @x402-avm/hono       # Hono
npm install @x402-avm/next       # Next.js

# Client (pick one)
npm install @x402-avm/fetch      # Fetch API
npm install @x402-avm/axios      # Axios

Register AVM Scheme

Every component registers the AVM exact scheme unconditionally — no environment variable guards:

// Client
import { registerExactAvmScheme } from "@x402-avm/avm/exact/client";
registerExactAvmScheme(client, { signer });

// Server
import { registerExactAvmScheme } from "@x402-avm/avm/exact/server";
registerExactAvmScheme(server);

// Facilitator
import { registerExactAvmScheme } from "@x402-avm/avm/exact/facilitator";
registerExactAvmScheme(facilitator, { signer, networks: ALGORAND_TESTNET_CAIP2 });

TypeScript algosdk Encoding

TypeScript algosdk works with raw Uint8Array directly — no conversion needed. This matches the @txnlab/use-wallet ecosystem standard. Encoding/decoding to/from base64 happens only at protocol boundaries (PAYMENT-SIGNATURE header serialization).

Reference Guide

Navigate to the appropriate reference based on your task. Each topic has three files:

  • {name}.md — Step-by-step implementation guide
  • {name}-reference.md — API details and type signatures
  • {name}-examples.md — Complete, runnable code samples

Explaining x402 for TypeScript

Understand @x402-avm/* TypeScript package structure, signer interfaces (ClientAvmSigner, FacilitatorAvmSigner), registration patterns, builder patterns, constants, and utilities.

Building Clients

Build HTTP clients with Fetch or Axios that automatically handle 402 payments. Covers wrapFetchWithPayment, wrapAxiosWithPayment, ClientAvmSigner for browser wallets or Node.js private keys.

Building Servers

Build payment-protected servers with Express.js or Hono middleware. Covers route pricing, multi-network support (AVM+EVM+SVM), 402 responses, and dynamic pricing.

Building Next.js Apps

Build fullstack Next.js apps with x402 payment protection using paymentProxy and withX402. Covers App Router integration, middleware-level protection, and per-endpoint control.

Building Facilitators and Bazaar Discovery

Build facilitator services that verify and settle Algorand payments on-chain. Covers FacilitatorAvmSigner, Express.js facilitator servers, and Bazaar discovery extension for API cataloging (bazaarResourceServerExtension, withBazaar, declare_discovery_extension on servers).

Building Paywalls

Build browser paywall UIs with server-side middleware and client-side wallet integration (Pera, Defly, Lute). Covers PaywallBuilder, avmPaywall, multi-network paywalls.

Low-Level SDK Usage

Use @x402-avm/core and @x402-avm/avm packages directly for custom integrations. Covers payment policies, AVM signer interfaces, transaction groups, fee abstraction, and low-level primitives.

TypeScript Package Quick Reference

PackagePurpose
@x402-avm/fetchWrap fetch with automatic 402 payment handling
@x402-avm/axiosWrap axios with automatic 402 payment handling
@x402-avm/expressExpress.js payment middleware
@x402-avm/honoHono payment middleware
@x402-avm/nextNext.js payment middleware and route wrappers
@x402-avm/paywallBrowser paywall UI components
@x402-avm/coreCore protocol primitives (client, server, facilitator)
@x402-avm/avmAVM mechanism (signers, transaction builders, constants)

How to Use This Skill

  1. Start here to understand which reference you need
  2. Read the {name}.md file for step-by-step implementation guidance
  3. Consult {name}-reference.md for API details
  4. Use {name}-examples.md for complete, runnable code samples

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

test-smart-contracts

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

troubleshoot-errors

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

search-algorand-examples

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

implement-arc-standards

No summary provided by upstream source.

Repository SourceNeeds Review