Record Class X402Config

java.lang.Object
java.lang.Record
com.tnsai.payment.x402.X402Config
Record Components:
wallet - signing-capable wallet bound to the same network
network - target settlement network
facilitator - URI of the x402 facilitator that will validate and broadcast the signed authorisation
quoteTtl - how long a fresh quote remains valid before it must be re-priced
maxSlippageBps - acceptable price drift between quote and settle, in basis points
httpClient - HTTP client used for both the 402 probe and the facilitator round-trip
liabilitySink - optional LiabilitySink the broker emits an AgentLiabilityRecord to on every settlement. Empty when the consumer declines accountability wiring (test fixtures, single-tenant local dogfood).
authorityScope - optional AuthorityScope whose spendCeilingUSD the broker enforces before each settlement. Empty = no mandate enforcement.

public record X402Config(Wallet wallet, Network network, URI facilitator, Duration quoteTtl, BigDecimal maxSlippageBps, HttpClient httpClient, Optional<com.tnsai.accountability.LiabilitySink> liabilitySink, Optional<com.tnsai.accountability.AuthorityScope> authorityScope) extends Record
Configuration record for the upcoming x402 broker.

P2 ships the shape only — the consuming broker lands in P3 (TNS-449). The record exists now so the SPI surface is exhaustive: callers can write application code that holds an X402Config reference without waiting for P3, and P3 only adds the broker class that consumes it.

Builder:

 X402Config cfg = X402Config.builder()
     .wallet(InMemoryWallet.forTesting("0xabc...", Network.BASE_SEPOLIA))
     .network(Network.BASE_SEPOLIA)
     .facilitator(URI.create("https://facilitator.x402.org"))
     .build();
 

Sensible defaults are applied if the caller doesn't override:

  • quoteTtl — 60 seconds. The x402 facilitator's standard quote validity window.
  • maxSlippageBps — 50 basis points (0.5%). Tight enough to catch fee-pump shenanigans, loose enough to absorb normal gas-price drift on Base.
  • httpClient — HttpClient.newHttpClient(). Tests and consumers wanting interceptors / pooling override.
Since:
0.10.5 (TNS-449 P2)
  • Field Details

    • DEFAULT_QUOTE_TTL

      public static final Duration DEFAULT_QUOTE_TTL
      Default quote validity — matches the x402 facilitator's published window.
    • DEFAULT_MAX_SLIPPAGE_BPS

      public static final BigDecimal DEFAULT_MAX_SLIPPAGE_BPS
      Default slippage tolerance — 50 basis points (0.5%).
  • Constructor Details

    • X402Config

      public X402Config(Wallet wallet, Network network, URI facilitator, Duration quoteTtl, BigDecimal maxSlippageBps, HttpClient httpClient, Optional<com.tnsai.accountability.LiabilitySink> liabilitySink, Optional<com.tnsai.accountability.AuthorityScope> authorityScope)
      Creates an instance of a X402Config record class.
      Parameters:
      wallet - the value for the wallet record component
      network - the value for the network record component
      facilitator - the value for the facilitator record component
      quoteTtl - the value for the quoteTtl record component
      maxSlippageBps - the value for the maxSlippageBps record component
      httpClient - the value for the httpClient record component
      liabilitySink - the value for the liabilitySink record component
      authorityScope - the value for the authorityScope record component
  • Method Details

    • builder

      public static X402Config.Builder builder()
      Convenience entry point for the builder.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • wallet

      public Wallet wallet()
      Returns the value of the wallet record component.
      Returns:
      the value of the wallet record component
    • network

      public Network network()
      Returns the value of the network record component.
      Returns:
      the value of the network record component
    • facilitator

      public URI facilitator()
      Returns the value of the facilitator record component.
      Returns:
      the value of the facilitator record component
    • quoteTtl

      public Duration quoteTtl()
      Returns the value of the quoteTtl record component.
      Returns:
      the value of the quoteTtl record component
    • maxSlippageBps

      public BigDecimal maxSlippageBps()
      Returns the value of the maxSlippageBps record component.
      Returns:
      the value of the maxSlippageBps record component
    • httpClient

      public HttpClient httpClient()
      Returns the value of the httpClient record component.
      Returns:
      the value of the httpClient record component
    • liabilitySink

      public Optional<com.tnsai.accountability.LiabilitySink> liabilitySink()
      Returns the value of the liabilitySink record component.
      Returns:
      the value of the liabilitySink record component
    • authorityScope

      public Optional<com.tnsai.accountability.AuthorityScope> authorityScope()
      Returns the value of the authorityScope record component.
      Returns:
      the value of the authorityScope record component