x402.Coinbase 0.0.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package x402.Coinbase --version 0.0.3
                    
NuGet\Install-Package x402.Coinbase -Version 0.0.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="x402.Coinbase" Version="0.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="x402.Coinbase" Version="0.0.3" />
                    
Directory.Packages.props
<PackageReference Include="x402.Coinbase" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add x402.Coinbase --version 0.0.3
                    
#r "nuget: x402.Coinbase, 0.0.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package x402.Coinbase@0.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=x402.Coinbase&version=0.0.3
                    
Install as a Cake Addin
#tool nuget:?package=x402.Coinbase&version=0.0.3
                    
Install as a Cake Tool

x402-dotnet

x402 Payment Protocol implementation for .Net

Install the x402 package from NuGet:

Features:

  • Add a x402 compatible paywall to any URL
  • Handle payment settlement using a remote server

How to use?

Setup the Facilitator in Program.cs

// Add the facilitator in Program.cs
builder.Services.AddHttpClient<IFacilitatorClient, HttpFacilitatorClient>(client =>
{
    client.BaseAddress = new Uri("https://localhost:7141"); // Address of your facilitator
});

Use the MVC Attribute

// Use the Payment Required Attribute
 [HttpGet]
 [Route("protected")]
 [PaymentRequired("1", "0x00..Asset..Address", "0xYourWalletAddressHere", "base-sepolia")]
 public IActionResult Protected()
 {
     return Content("Protected");
 }

Directly in an API Controller

[HttpGet]
[Route("dynamic")]
public async Task<IActionResult> Dynamic(string amount)
{
    var request = this.HttpContext.Request;
    var fullUrl = $"{request.Scheme}://{request.Host}{request.Path}{request.QueryString}";

    var x402Result = await X402Handler.HandleX402Async(this.HttpContext, facilitator, fullUrl,
        new Models.PaymentRequirements
        {
            Asset = "USDC",
            Description = "Dynamic payment",
            Network = "base-sepolia",
            MaxAmountRequired = amount,
            PayTo = "0x"
        });

    if (!x402Result.CanContinueRequest)
    {
        return new EmptyResult(); // Response already written by HandleX402Async, so just exit
    }

    //Continue with the request
}

Or use the Middleware to require payment for a list of URLs

// Add Middleware
var facilitator = app.Services.GetRequiredService<IFacilitatorClient>();
var paymentOptions = new x402.Models.PaymentMiddlewareOptions
{
    Facilitator = facilitator,
    DefaultPayToAddress = "0xYourWalletAddressHere", // Replace with your actual wallet address
    DefaultNetwork = "base-sepolia",
    PaymentRequirements = new Dictionary<string, x402.Models.PaymentRequirementsConfig>()
        {
            {  "/url-to-pay-for", new x402.Models.PaymentRequirementsConfig
                {
                    Scheme = x402.Enums.PaymentScheme.Exact,
                    MaxAmountRequired = 1000000,
                    Asset = "0x......", // Contract address of asset
                    MimeType = "application/json"
                }
            }
        },
};

app.UsePaymentMiddleware(paymentOptions);

Coinbase Facilitator

To use the Coinbase Facilitator, install x402.Coinbase

// Add the Coinbase Config and Facilitator
builder.Services.Configure<CoinbaseOptions>(builder.Configuration.GetSection(nameof(CoinbaseOptions)));
builder.Services.AddHttpClient<IFacilitatorClient, CoinbaseFacilitatorClient>();

Add to appsettings.json:

 "CoinbaseOptions": {
   "ApiKeyId": "YOUR_COINBASE_API_KEY_ID",
   "ApiKeySecret": "YOUR_COINBASE_API_KEY_SECRET"
 }

Facilitators

List of facilitators you can use:

Development

There is a sample website and mock Settlement server included.

  • Start the Aspire project: x402-dotnet.AppHost
  • Navigate to the sample website https://localhost:7154/
  • Use the x402.SampleWeb.http for sample web requests

Contributions

Contributions are welcome. Fork this repository and send a pull request if you have something useful to add.

Useful tools when developing x402 solutions:

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0 115 1/9/2026
0.0.17 202 12/5/2025
0.0.16 674 12/2/2025
0.0.15 421 11/18/2025
0.0.13 165 11/7/2025
0.0.11 173 10/31/2025
0.0.10 211 10/29/2025
0.0.9 209 10/29/2025
0.0.8 170 10/24/2025
0.0.7 162 10/24/2025
0.0.6 195 10/22/2025
0.0.5 151 10/17/2025
0.0.4 211 10/8/2025
0.0.3 203 10/7/2025
0.0.2 198 10/6/2025
0.0.1 152 10/3/2025