Package com.tnsai.payment.x402
Record Class X402Config
java.lang.Object
java.lang.Record
com.tnsai.payment.x402.X402Config
- Record Components:
wallet- signing-capable wallet bound to the same networknetwork- target settlement networkfacilitator- URI of the x402 facilitator that will validate and broadcast the signed authorisationquoteTtl- how long a fresh quote remains valid before it must be re-pricedmaxSlippageBps- acceptable price drift betweenquoteandsettle, in basis pointshttpClient- HTTP client used for both the 402 probe and the facilitator round-tripliabilitySink- optionalLiabilitySinkthe broker emits anAgentLiabilityRecordto on every settlement. Empty when the consumer declines accountability wiring (test fixtures, single-tenant local dogfood).- optionalAuthorityScopewhosespendCeilingUSDthe 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)
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BigDecimalDefault slippage tolerance — 50 basis points (0.5%).static final DurationDefault quote validity — matches the x402 facilitator's published window. -
Constructor Summary
ConstructorsConstructorDescriptionX402Config(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 aX402Configrecord class. -
Method Summary
Modifier and TypeMethodDescriptionOptional<com.tnsai.accountability.AuthorityScope> Returns the value of theauthorityScoperecord component.static X402Config.Builderbuilder()Convenience entry point for the builder.final booleanIndicates whether some other object is "equal to" this one.Returns the value of thefacilitatorrecord component.final inthashCode()Returns a hash code value for this object.Returns the value of thehttpClientrecord component.Optional<com.tnsai.accountability.LiabilitySink> Returns the value of theliabilitySinkrecord component.Returns the value of themaxSlippageBpsrecord component.network()Returns the value of thenetworkrecord component.quoteTtl()Returns the value of thequoteTtlrecord component.final StringtoString()Returns a string representation of this record class.wallet()Returns the value of thewalletrecord component.
-
Field Details
-
DEFAULT_QUOTE_TTL
Default quote validity — matches the x402 facilitator's published window. -
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 aX402Configrecord class.- Parameters:
wallet- the value for thewalletrecord componentnetwork- the value for thenetworkrecord componentfacilitator- the value for thefacilitatorrecord componentquoteTtl- the value for thequoteTtlrecord componentmaxSlippageBps- the value for themaxSlippageBpsrecord componenthttpClient- the value for thehttpClientrecord componentliabilitySink- the value for theliabilitySinkrecord componentauthorityScope- the value for theauthorityScoperecord component
-
-
Method Details
-
builder
Convenience entry point for the builder. -
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
wallet
Returns the value of thewalletrecord component.- Returns:
- the value of the
walletrecord component
-
network
Returns the value of thenetworkrecord component.- Returns:
- the value of the
networkrecord component
-
facilitator
Returns the value of thefacilitatorrecord component.- Returns:
- the value of the
facilitatorrecord component
-
quoteTtl
Returns the value of thequoteTtlrecord component.- Returns:
- the value of the
quoteTtlrecord component
-
maxSlippageBps
Returns the value of themaxSlippageBpsrecord component.- Returns:
- the value of the
maxSlippageBpsrecord component
-
httpClient
Returns the value of thehttpClientrecord component.- Returns:
- the value of the
httpClientrecord component
-
liabilitySink
Returns the value of theliabilitySinkrecord component.- Returns:
- the value of the
liabilitySinkrecord component
-
authorityScope
Returns the value of theauthorityScoperecord component.- Returns:
- the value of the
authorityScoperecord component
-