@x402r/core package includes deployment presets that handle the full lifecycle of deploying a PaymentOperator and all its supporting contracts.
Presets
The SDK ships two deployment presets. Pick the one that matches your use case:| Preset | Use case | Freeze | Fees | RefundRequest |
|---|---|---|---|---|
deployMarketplaceOperator | General marketplace with dispute resolution | Yes (optional) | Yes (optional) | Yes |
deployDeliveryProtectionOperator | Garbage detection / delivery verification | No | No | No |
Marketplace operator
A complete marketplace operator deployment includes:- EscrowPeriod: Records authorization time, enforces waiting period before capture
- Freeze: Allows payer to freeze payment during escrow, receiver to unfreeze
- ReceiverCondition: Gates voids to the merchant (receiver)
- RefundRequest (
IHook): Wired asvoidPostActionHook, flips pending refund requests toApprovedduringvoidPayment() - StaticFeeCalculator: Optional operator fee (basis points)
- PaymentOperator: The main contract tying everything together
Deploy your operator
Prerequisites:- Node.js 20+, pnpm 9.15+
- A private key with Base Sepolia ETH (get Sepolia ETH)
deployMarketplaceOperator from @x402r/core with a viem wallet client. Because every contract uses CREATE2, deploys are idempotent: re-running with the same parameters reuses any existing contract at the predicted address and skips it.
Configuration options
| Option | Type | Description |
|---|---|---|
chainId | number | Target chain ID (for example, 84532 for Base Sepolia) |
feeReceiver | Address | Address that receives operator fees |
arbiter | Address | Arbiter address for dispute resolution |
escrowPeriodSeconds | bigint | Escrow waiting period (for example, 604800n for 7 days) |
freezeDurationSeconds | bigint | How long freezes last. Default: 0n (permanent until unfrozen) |
operatorFeeBps | bigint | Fee in basis points. Default: 0n (no fee). 100n = 1% |
authorizedCodehash | Hex | Optional. Restricts which contract codehashes can record. Defaults to bytes32(0) (no restriction) |
Deployment result
Preview addresses (no deploy)
Marketplace operator slot configuration
The deployed marketplace operator has the following slot configuration:| Slot | Contract | Purpose |
|---|---|---|
AUTHORIZE_PRE_ACTION_CONDITION | (none) | Default: anyone with a valid signature can authorize |
AUTHORIZE_POST_ACTION_HOOK | EscrowPeriod | Records authorization timestamp |
CHARGE_PRE_ACTION_CONDITION | (none) | No restrictions on charge |
CAPTURE_PRE_ACTION_CONDITION | EscrowPeriod (or AND(EscrowPeriod, Freeze) if freeze enabled) | Blocks capture during escrow period |
VOID_PRE_ACTION_CONDITION | OR(Receiver, Arbiter) | Receiver or arbiter can approve |
VOID_POST_ACTION_HOOK | RefundRequest | Tracks refund request state |
REFUND_PRE_ACTION_CONDITION | Receiver | Only receiver after escrow |
FEE_CALCULATOR | StaticFeeCalculator | Fixed percentage fee (if configured) |
FEE_RECEIVER | Your address | Receives fees |
Network support
The deploy presets target the chains in@x402r/core’s x402rChains (Base and Base Sepolia today). See Network support for chain IDs, EIP-155 IDs, and token addresses.
Delivery Protection Operator
For programmatic quality verification (AI garbage detection, schema validation), use the delivery protection preset. No RefundRequest, Evidence, or Freeze contracts. The arbiter or payer can capture funds, and the arbiter can issue immediate refunds without waiting for escrow expiry.| Option | Type | Description |
|---|---|---|
chainId | number | Target chain |
arbiter | Address | Arbiter address for capture and refund decisions |
feeReceiver | Address | Receives protocol fees |
escrowPeriodSeconds | bigint | Verification window before automatic refund |
authorizedCodehash | Hex | Override the default hookCombinatorCodehash. Optional |
paymentIndexRecorderHookAddress | Address | Override the default PaymentIndexRecorderHook. Pass zeroAddress to skip on-chain payment indexing. Optional |
allowArbiterRefund | boolean | Lets the arbiter refund immediately during escrow. Default: false |
Deployment Result Type
Deployment Result Type
paymentIndexRecorderHookAddress: zeroAddress, the HookCombinator is skipped (5 contracts).Redeploying with the same parameters is idempotent (CREATE2). The tooling reuses any contract that already exists at the predicted address.Preview Addresses (No Deploy)
Preview Addresses (No Deploy)
Compute addresses without deploying:
Delivery Protection Slot Configuration
Delivery Protection Slot Configuration
| Slot | Contract | Purpose |
|---|---|---|
CAPTURE_PRE_ACTION_CONDITION | OrCondition([SAC(arbiter), PayerCondition]) | Arbiter or satisfied payer can capture |
AUTHORIZE_POST_ACTION_HOOK | HookCombinator([EscrowPeriod, PaymentIndexRecorderHook]) | Records authorization time and indexes payments on-chain |
VOID_PRE_ACTION_CONDITION | OrCondition([EscrowPeriod, ReceiverCondition, SAC(arbiter)]) | Escrow expiry, receiver voluntary refund, or arbiter immediate refund |
REFUND_PRE_ACTION_CONDITION | ReceiverCondition | Only receiver after escrow |
Next Steps
Merchant Guide
Accept payments, capture funds from escrow.
Examples
See working merchant and client examples.
forwardToArbiter()
Forward escrow settlements to an arbiter service.
Smart Contracts
On-chain architecture, conditions, and hooks.
