Agent skill

X402 Payments

by Nethereum in Nethereum/Nethereum

Accept HTTP 402 cryptocurrency payments using Nethereum (.NET/C).

MITAuto-check passedBackend & APIs

Install X402 Payments

skills CLI
$ npx skills add Nethereum/Nethereum --skill x402-payments -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install Nethereum/Nethereum x402-payments --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/Nethereum/Nethereum.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/nethereum-skills/skills/x402-payments .claude/skills/x402-payments && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
x402-payments
GitHub stars
2.3k
Token cost
~2.2k tokens
SKILL.md length
479 words
Files
1
Skills in repo
71
Repo updated
First seen
Licence
MIT

At a glance

Accept HTTP 402 cryptocurrency payments using Nethereum (.NET/C).

  • The user asks about x402 protocol (version 2)
  • SKILL.md covers Client: Pay Automatically, Server: Protect Endpoints, Asset-Transfer Methods and Build EIP-3009 Authorizations…, plus 2 more sections
  • Calls dotnet; reaches facilitator.x402.org and mainnet.base.org
  • HTTP 402 payments

What it does

X402 Payments is an agent skill from Nethereum/Nethereum. Accept HTTP 402 cryptocurrency payments using Nethereum (.NET/C). Use this skill whenever the user asks about x402 protocol (version 2), HTTP 402 payments, pay-per-request APIs, EIP-3009 transfer authorization, Permit2 payments, USDC payments, crypto API monetization, payment middleware, or accepting cryptocurrency payments in ASP.NET with C or .NET.

Its SKILL.md is about 2.2k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Backend & APIs, covering Crypto and DeFi analysis and Authorization and RBAC. It works with x402, C#, .NET and ASP.NET Core. The repository describes itself as: Ethereum .Net cross platform integration library. The licence is MIT.

When your agent uses it

  • The user asks about x402 protocol (version 2)
  • HTTP 402 payments
  • Pay-per-request APIs
  • EIP-3009 transfer authorization

Example prompts

  • “/x402-payments”

What it can do on your machine

Read from SKILL.md and the folder at commit 229f278. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • dotnet

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Hosts in commands or code, which the agent is likely to contact:

    • facilitator.x402.org
    • mainnet.base.org

    Also links to:

    • docs.nethereum.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

X402 Payments loads about 2.2k tokens when it runs. Until then it costs about 92 tokens; SKILL.md has 479 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~92
When it runs · the whole SKILL.md, loaded when a task matches
~2.2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from Nethereum/Nethereum at commit 229f278, republished under its MIT licence (© Nethereum). 479 words, ~2,189 tokens.

Download SKILL.mdSave it as .claude/skills/x402-payments/SKILL.md (or your agent's skills folder).
name
x402-payments
description
Accept HTTP 402 cryptocurrency payments using Nethereum (.NET/C#). Use this skill whenever the user asks about x402 protocol (version 2), HTTP 402 payments, pay-per-request APIs, EIP-3009 transfer authorization, Permit2 payments, USDC payments, crypto API monetization, payment middleware, or accepting cryptocurrency payments in ASP.NET with C# or .NET.
user-invocable
true

x402: Crypto Payments (protocol v2)

The x402 protocol implements HTTP 402 (Payment Required) for pay-per-request APIs. A client pays with a signed authorization — off-chain (no gas) — and the server or a facilitator settles on-chain. Nethereum's Nethereum.X402 package provides X402HttpClient for automatic payments and X402Middleware for ASP.NET Core endpoint protection.

This library targets x402 version 2: payments carry x402Version = 2, the chosen requirement is echoed in the payload's accepted field, and networks use CAIP-2 identifiers (eip155:<chainId>, e.g. eip155:8453 for Base). The "exact" scheme supports two EVM asset-transfer methods: EIP-3009 (default) and Permit2.

NuGet: Nethereum.X402

bash
dotnet add package Nethereum.X402

The v2 wire uses three base64 headers: PAYMENT-REQUIRED (402 response), PAYMENT-SIGNATURE (request), PAYMENT-RESPONSE (200 response).

Client: Pay Automatically

X402HttpClient handles the full 402 flow — detect requirement, select one, sign it, retry with the payment header. The signing domain (token, chain id, name/version) is derived from the server's PaymentRequirements, so the client is not pre-configured with a token:

csharp
using Nethereum.X402.Client;

var options = new X402HttpClientOptions
{
    MaxAmount = "100000",           // Safety limit per request (USDC)
    PreferredNetwork = "eip155:8453",  // CAIP-2 (Base)
    PreferredScheme = "exact"
};

var x402Client = new X402HttpClient(httpClient, privateKey, options);
var response = await x402Client.GetAsync("https://api.example.com/premium/content");

// Check payment result from the PAYMENT-RESPONSE header
if (response.HasPaymentResponse())
{
    var txHash = response.GetTransactionHash();
    var payer = response.GetPayerAddress();
    var success = response.IsPaymentSuccessful();
}

Supports GetAsync, PostAsync, PutAsync, DeleteAsync, SendAsync. Throws X402PaymentExceedsMaximumException if the requested amount exceeds MaxAmount. The client automatically produces the right payload for the selected requirement's method (EIP-3009, or Permit2 when extra.assetTransferMethod == "permit2").

Manual Payment Flow

Construct with just the payer key and pass explicit PaymentRequirements:

csharp
var x402Client = new X402HttpClient(httpClient, privateKey);

var requirements = new PaymentRequirements
{
    Scheme = "exact",
    Network = "eip155:84532",   // Base Sepolia
    Amount = "1000000",         // $1.00 USDC (6 decimals), atomic units
    Asset = usdcAddress,
    PayTo = receiverAddress,
    MaxTimeoutSeconds = 60,
    Extra = new ExactSchemeExtra { Name = "USDC", Version = "2" }
};

var response = await x402Client.GetAsync("https://api.example.com/premium", requirements);

Server: Protect Endpoints

Register a facilitator client, then add route-based middleware:

csharp
using Nethereum.X402.AspNetCore;
using Nethereum.X402.Server;
using Nethereum.X402.Models;

builder.Services.AddX402Services("https://facilitator.x402.org");

app.UseX402(options =>
{
    options.Routes.Add(new RoutePaymentConfig("/api/premium/*", new PaymentRequirements
    {
        Scheme = "exact",
        Network = "eip155:8453",
        Amount = "1000000",
        Asset = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
        PayTo = "0xYourAddress",
        MaxTimeoutSeconds = 60,
        Extra = new ExactSchemeExtra { AssetTransferMethod = "eip3009", Name = "USDC", Version = "2" }
    }));
});
Self-Facilitated (No External Facilitator)

Settle on-chain directly. Only an RPC endpoint per chain id is configured (token/chain/domain come from each requirement):

csharp
using Nethereum.X402.Extensions;

var rpcByChainId = new Dictionary<int, string> { [8453] = "https://mainnet.base.org" };

// EIP-3009 only (facilitator pays gas):
builder.Services.AddX402TransferProcessor(facilitatorPrivateKey, rpcByChainId);

// EIP-3009 AND Permit2 (routes by payload shape) — recommended:
builder.Services.AddX402ExactProcessor(facilitatorPrivateKey, rpcByChainId);

// Receiver-submitted model (receiver pays gas):
builder.Services.AddX402ReceiveProcessor(receiverPrivateKey, rpcByChainId);

Each overload also accepts an IAccount (external signers/KMS) or an IServiceProvider factory.

Asset-Transfer Methods

MethodProcessorOn-chain call
EIP-3009 (default)X402TransferWithAuthorisation3009ServicetransferWithAuthorization
EIP-3009 (receiver)X402ReceiveWithAuthorisation3009ServicereceiveWithAuthorization
Permit2X402ExactPermit2Servicex402ExactPermit2Proxy.settle
dispatcherX402ExactSchemeProcessorroutes by payload shape

All implement IX402PaymentProcessor (VerifyPaymentAsync, SettlePaymentAsync, GetSupportedAsync). A blockchain processor is constructed with a facilitator key (or IAccount) and a Dictionary<int, IClient> keyed by chain id.

Show full SKILL.md (192 more words)Show less
Permit2 Method

Permit2 works with any ERC-20 the payer has approved to the canonical Permit2 contract (no EIP-3009 support needed). A route opts in with extra.assetTransferMethod = "permit2"; the client signs a Permit2 PermitWitnessTransferFrom (spender = the x402ExactPermit2Proxy, witness = the recipient) and the facilitator settles via proxy.settle, which enforces that funds go only to that recipient:

csharp
options.Routes.Add(new RoutePaymentConfig("/api/premium-permit2", new PaymentRequirements
{
    Scheme = "exact",
    Network = "eip155:84532",
    Amount = "10000",
    Asset = usdcAddress,
    PayTo = receiverAddress,
    MaxTimeoutSeconds = 60,
    Extra = new ExactSchemeExtra { AssetTransferMethod = "permit2" }
}));

// Facilitator: X402ExactPermit2Service (or AddX402ExactProcessor to serve both methods)

The Permit2/proxy addresses are canonical constants (X402Permit2Addresses), the same on every EVM chain. The underlying Permit2 signing lives in Nethereum.Signer.EIP712/Nethereum.ABI, and the contract in Nethereum.Contracts (web3.Eth.GetPermit2Service()).

Build EIP-3009 Authorizations Directly

For custom flows:

csharp
using Nethereum.X402.Signers;

var builder = new TransferWithAuthorisationBuilder();
var signer = new TransferWithAuthorisationSigner();

var authorization = builder.BuildFromPaymentRequirements(requirements, payerAddress);
// Default window: validAfter = 10 min ago, validBefore = 1 hour from now

var signature = await signer.SignWithPrivateKeyAsync(
    authorization, "USD Coin", "2", chainId, usdcAddress, payerPrivateKey);

// Or sign with a Web3 account (hardware wallets, KMS)
var signature = await signer.SignWithWeb3Async(
    authorization, "USD Coin", "2", chainId, usdcAddress, web3, signerAddress);

Error Codes (X402ErrorCodes)

CodeMeaning
invalid_exact_evm_insufficient_balancePayer doesn't have enough tokens
invalid_exact_evm_signatureEIP-3009 signature verification failed
invalid_exact_evm_authorization_valueAmount below the requirement
invalid_exact_evm_recipient_mismatchReceiver mismatch
invalid_exact_evm_nonce_already_usedNonce already used
invalid_network / unsupported_payload_typeNetwork/scheme not supported
invalid_permit2_recipient_mismatchPermit2 witness recipient ≠ PayTo
permit2_amount_mismatch / permit2_token_mismatchPermit2 amount/token mismatch
permit2_allowance_requiredPayer hasn't approved Permit2 for the asset
invalid_permit2_signaturePermit2 signature verification failed

Supported Tokens

Any EIP-3009 token (for the eip3009 method) or any ERC-20 approved to Permit2 (for the permit2 method). Common USDC addresses:

TokenNetworkAddress
USDCEthereum0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
USDCBase0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
USDCBase Sepolia0x036CbD53842c5426634e7929541eC2318f3dCF7e
USDCPolygon0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359
USDCArbitrum0xaf88d065e77c8cC2239327C5EDb3A432268e5831
USDCOptimism0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85

For full documentation, see: https://docs.nethereum.com/docs/defi/guide-x402-payments

© Nethereum, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in plugins/nethereum-skills/skills/x402-payments of Nethereum/Nethereum.

Open the folder on GitHubat commit 229f278

Compare with similar skills

X402 Payments next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

X402 Payments compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
X402 Payments this skillNethereum/Nethereum2.3k—~2.2kAutomated safety check: PassMIT
Tsp Csharpquerylenshq/ef-querylens225—~1.3kAutomated safety check: PassMIT
Alchemy Agentic Gatewaymoonpay/skills113—~2.1kAutomated safety check: NotesMIT
Using Dotnetnovotnyllc/dotnet-artisan233—~2.3kAutomated safety check: WarnMIT
Dotnet Webapidotnet/skills5.6k2 repos~5.5kAutomated safety check: PassMIT
C# and .NET DeveloperJeffallan/claude-skills12k—~1.3kAutomated safety check: PassMIT

Similar skills

  • Tsp Csharp

    querylenshq/ef-querylens

    Comprehensive C and .NET development skill for TSP projects.

    225 GitHub stars~1.3k tokensUpdated 1 mo ago
    Backend & APIsAuto-check passed
  • A skill your agent uses when accessing Alchemy APIs for RPC calls, token balances, NFT metadata, asset transfers, transaction simulation, or Alchemy-specific features.

    113 GitHub stars~2.1k tokensUpdated 29 days ago
    Backend & APIsAuto-check: notes
  • Using Dotnet

    novotnyllc/dotnet-artisan

    Detects .NET intent for any C, ASP.NET Core, EF Core, Blazor, MAUI, Uno Platform, WPF, WinUI, SignalR, gRPC, xUnit, NuGet, or MSBuild request from prompt keywords and repository signals (.sln…

    233 GitHub stars~2.3k tokensUpdated 2 days ago
    Backend & APIsAuto-check: warnings
  • Dotnet Webapi

    dotnet/skills

    Official

    Guides creation and modification of ASP.NET Core Web API endpoints with correct HTTP semantics, OpenAPI metadata, and error handling.

    5.6k GitHub starsUsed in 2 repos~5.5k tokens
    Backend & APIsAuto-check passed
  • C# and .NET Developer

    Jeffallan/claude-skills

    Guides C# work on .NET 8+: ASP.NET Core APIs, Entity Framework Core data access, Blazor apps and CQRS with MediatR, following a five-step build workflow.

    12k GitHub stars~1.3k tokensUpdated 6 days ago
    Backend & APIsAuto-check passed
  • Dotnet Architect

    aiskillstore/marketplace

    Expert .NET backend architect specializing in C, ASP.NET Core, Entity Framework, Dapper, and enterprise application patterns.

    430 GitHub starsUsed in 7 repos~1.9k tokens
    Backend & APIsAuto-check passed

More from Nethereum/Nethereum

All 71 skills in this repo
  • Aa Batching Paymasters

    Nethereum/Nethereum

    Help users batch multiple calls into a single UserOperation and sponsor gas with paymasters using Nethereum Account Abstraction.

    2.3k GitHub stars~1.5k tokensUpdated 4 days ago
    Auto-check passed
  • Aa Bundler

    Nethereum/Nethereum

    Help users run an ERC-4337 bundler using Nethereum — set up in-process or standalone bundlers with mempool, validation, reputation, and JSON-RPC server.

    2.3k GitHub stars~1.2k tokensUpdated 4 days ago
    Auto-check passed
  • Abi Encoding

    Nethereum/Nethereum

    Encode and decode Ethereum ABI data with Nethereum. An agent skill from Nethereum/Nethereum.

    2.3k GitHub stars~1.3k tokensUpdated 4 days ago
    Auto-check passed
  • Abi Retrieval

    Nethereum/Nethereum

    Fetch contract ABIs from Sourcify, Etherscan, and 4Byte Directory using the composite ABIInfoStorage pattern (.NET/C).

    2.3k GitHub stars~1.5k tokensUpdated 4 days ago
    Auto-check passed
  • Account Abstraction

    Nethereum/Nethereum

    Help users implement ERC-4337 Account Abstraction with Nethereum — send UserOperations, use smart accounts, route contract calls through a bundler, enable gasless transactions, or work with AA in…

    2.3k GitHub stars~1.7k tokensUpdated 4 days ago
    Auto-check passed
  • Address Utils

    Nethereum/Nethereum

    Validate and format Ethereum addresses with Nethereum. An agent skill from Nethereum/Nethereum.

    2.3k GitHub stars~1.2k tokensUpdated 4 days ago
    Auto-check passed

Questions about X402 Payments

What does X402 Payments do?

Accept HTTP 402 cryptocurrency payments using Nethereum (.NET/C). X402 Payments is an agent skill from Nethereum/Nethereum.NET/C).

When should I use X402 Payments?

X402 Payments fits situations like: the user asks about x402 protocol (version 2); HTTP 402 payments; pay-per-request APIs; EIP-3009 transfer authorization.

How do I install X402 Payments in Claude Code?

Run `npx skills add Nethereum/Nethereum --skill x402-payments -a claude-code`. Or copy the skill folder (plugins/nethereum-skills/skills/x402-payments in Nethereum/Nethereum) into .claude/skills/x402-payments in your project. Claude Code loads it when a task matches its description.

How do I install X402 Payments in Codex?

Run `npx skills add Nethereum/Nethereum --skill x402-payments -a codex`. Or copy the skill folder (plugins/nethereum-skills/skills/x402-payments in Nethereum/Nethereum) into .agents/skills/x402-payments in your project. Codex loads it when a task matches its description.

Can I use X402 Payments in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add Nethereum/Nethereum --skill x402-payments -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/x402-payments, .gemini/skills/x402-payments, .github/skills/x402-payments and .opencode/skills/x402-payments in your project.

What does X402 Payments need to run?

Going by SKILL.md and its folder, X402 Payments needs the command-line tools its instructions call (dotnet).

Does X402 Payments access the network?

SKILL.md names 3 domains. In commands or code: facilitator.x402.org and mainnet.base.org; the agent is likely to contact these when it follows the instructions. As links in the text: docs.nethereum.com. This is read from the text; nothing was executed.

Is X402 Payments safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does X402 Payments use?

X402 Payments is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does X402 Payments use?

About 2.2k tokens (SKILL.md is roughly 8.8k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to X402 Payments?

Skills that share tags, products or a category with X402 Payments: Tsp Csharp (querylenshq/ef-querylens, 225 stars), Alchemy Agentic Gateway (moonpay/skills, 113 stars), Using Dotnet (novotnyllc/dotnet-artisan, 233 stars) and Dotnet Webapi (dotnet/skills, 5.6k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains X402 Payments?

Nethereum (a GitHub organization) maintains it in Nethereum/Nethereum, which has 2,260 GitHub stars. The repository holds 71 skills in this directory. The repository was last updated on October 5, 2026.

Source: Nethereum/Nethereum on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.