uvd-x402-sdk 2.69.0 → 2.71.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -927,6 +927,86 @@ const result = await erc8004.submitFeedback({
927
927
  await erc8004.appendResponse('ethereum', 42, 1, 'Thank you for your feedback!');
928
928
  ```
929
929
 
930
+ ### Ratings the chain attributes to the rater
931
+
932
+ `submitFeedback()` above works, but the registry records `msg.sender` as the
933
+ author -- and on that route `msg.sender` is the **facilitator**. It is why 87,2%
934
+ of the reputation on Base (1.384 of 1.587 feedbacks) is attributed to one
935
+ wallet, which can also revoke it.
936
+
937
+ EIP-7702 fixes it without touching the registry: the rater delegates their own
938
+ EOA to a `FeedbackDelegate`, and the transaction is sent **to the rater's
939
+ address**, so the registry sees the rater while the facilitator still pays the
940
+ gas.
941
+
942
+ ```typescript
943
+ import { Erc8004Client, supportsRelayedFeedback } from 'uvd-x402-sdk/backend';
944
+
945
+ const erc8004 = new Erc8004Client();
946
+
947
+ if (!supportsRelayedFeedback('base')) {
948
+ // fall back to submitFeedback(); the facilitator is the author there
949
+ }
950
+
951
+ const prep = await erc8004.prepareRelayedFeedback({
952
+ x402Version: 1,
953
+ network: 'base',
954
+ feedback: {
955
+ agentId: 18896,
956
+ value: 95,
957
+ tag1: 'quality',
958
+ rater: raterAddress, // who the chain will record as the author
959
+ },
960
+ });
961
+
962
+ // 1. Sign with the RATER's key. WHICH value you sign depends on HOW you sign
963
+ // it — get this wrong and you produce a well-formed signature that
964
+ // authorises nobody, and the only symptom is `relay_bad_signature`.
965
+ //
966
+ // `prep.digest` already carries the EIP-191 envelope. A raw key signs it as
967
+ // a prehash; a wallet's personal_sign would add the envelope a SECOND time,
968
+ // so wallets sign `prep.signingPayload` instead.
969
+ const signature = await account.sign({ hash: prep.digest! }); // raw key
970
+ // ...or, from a browser wallet:
971
+ // const signature = await walletClient.signMessage({
972
+ // account, message: { raw: prep.signingPayload! },
973
+ // });
974
+
975
+ // 2. Only the first time this rater rates: point their EOA at the delegate.
976
+ const authorization = prep.delegated
977
+ ? undefined
978
+ : {
979
+ chainId: prep.chainId, // 0 is EIP-7702's wildcard: valid on every chain
980
+ address: prep.delegate!,
981
+ nonce: prep.accountNonce!,
982
+ ...(await signAuthorization(prep.chainId, prep.delegate!, prep.accountNonce!)),
983
+ };
984
+
985
+ const result = await erc8004.submitRelayedFeedback({
986
+ x402Version: 1,
987
+ network: 'base',
988
+ feedback: { agentId: 18896, value: 95, tag1: 'quality', rater: raterAddress },
989
+ deadline: prep.deadline!, // short by design; past it, refused
990
+ nonce: prep.nonce!,
991
+ signature,
992
+ authorization,
993
+ });
994
+ ```
995
+
996
+ Pass the **same** feedback parameters, `deadline` and `nonce` back to
997
+ `submitRelayedFeedback()`. They are not redundant: the facilitator rebuilds the
998
+ registry calldata from them and refuses to relay anything the rater's signature
999
+ does not cover.
1000
+
1001
+ Available on the nine networks in `RELAYED_FEEDBACK_NETWORKS` -- the eight
1002
+ mainnets with a deployed `FeedbackDelegate` (base, ethereum, polygon, arbitrum,
1003
+ optimism, celo, bsc, monad) plus base-sepolia. **Avalanche is not one of them
1004
+ and is not waiting to become one**: its C-Chain rejects the transaction type
1005
+ itself (`-32000 transaction type not supported`), so anchor the rating on a
1006
+ chain that supports EIP-7702 -- the payment stays where it was made.
1007
+
1008
+ Requires facilitator v1.93.0+ for the mainnets; base-sepolia since v1.74.0.
1009
+
930
1010
  ## `/accepts` Negotiation
931
1011
 
932
1012
  Discover what the facilitator can settle before constructing payment authorizations. Used by Faremeter middleware and clients.
@@ -1385,6 +1385,152 @@ declare function wireNetwork(network: string): string;
1385
1385
  * reaches the wire. Use 'base'.
1386
1386
  */
1387
1387
  type Erc8004Network = 'ethereum' | 'base' | 'polygon' | 'arbitrum' | 'optimism' | 'celo' | 'bsc' | 'monad' | 'avalanche' | 'scroll' | 'skale-base' | 'base-mainnet' | 'ethereum-sepolia' | 'base-sepolia' | 'polygon-amoy' | 'arbitrum-sepolia' | 'optimism-sepolia' | 'celo-sepolia' | 'avalanche-fuji' | 'skale-base-sepolia' | 'solana' | 'solana-devnet';
1388
+ /**
1389
+ * Networks where the facilitator serves the RELAYED feedback rail, i.e. where
1390
+ * Execution Market has deployed a `FeedbackDelegate` and the facilitator
1391
+ * verified it on-chain (code present, and its `REPUTATION_REGISTRY()` reads
1392
+ * back that network's registry).
1393
+ *
1394
+ * Anywhere else `POST /feedback/evm/prepare` answers 400 — and it should. An
1395
+ * invented delegate address would send a type-4 transaction to an account with
1396
+ * no code behind it, and in the EVM a `.call()` to an address with no code
1397
+ * RETURNS SUCCESS. The failure would look exactly like a rating that rated
1398
+ * nobody.
1399
+ *
1400
+ * `avalanche` is absent and is not waiting to join: the C-Chain rejects the
1401
+ * transaction type itself (`-32000 transaction type not supported`), so there
1402
+ * is nothing to deploy against. Anchor the rating on a chain that supports
1403
+ * EIP-7702; the payment stays where it was made.
1404
+ */
1405
+ declare const RELAYED_FEEDBACK_NETWORKS: readonly Erc8004Network[];
1406
+ /**
1407
+ * Whether `network` serves the rater-authored feedback rail.
1408
+ *
1409
+ * Lets a caller route without paying a round trip for a 400. The facilitator
1410
+ * re-checks the delegate on-chain on every request regardless — this list is a
1411
+ * routing hint, never the authority.
1412
+ */
1413
+ declare function supportsRelayedFeedback(network: string): boolean;
1414
+ /**
1415
+ * An EIP-7702 authorization, as a wallet produces it.
1416
+ *
1417
+ * Needed only the first time a rater rates: it points their EOA at the
1418
+ * `FeedbackDelegate`. Once delegated, `prepare` answers `delegated: true` and
1419
+ * the submission carries no authorization at all.
1420
+ */
1421
+ interface RelayAuthorizationParams {
1422
+ /**
1423
+ * Chain the authorization is for.
1424
+ *
1425
+ * `0` is EIP-7702's wildcard and is valid on EVERY chain — a far broader
1426
+ * grant than pinning this one. Send the chain id `prepare` returned.
1427
+ */
1428
+ chainId: number;
1429
+ /**
1430
+ * The delegate the account is pointed at. Must be the address `prepare`
1431
+ * offered; the facilitator refuses anything else before it pays for a
1432
+ * transaction.
1433
+ */
1434
+ address: string;
1435
+ /** The rater account's nonce at the moment the authorization executes */
1436
+ nonce: number;
1437
+ yParity: number;
1438
+ r: string;
1439
+ s: string;
1440
+ }
1441
+ /**
1442
+ * Request body for `POST /feedback/evm/prepare`.
1443
+ *
1444
+ * `rater` is the address that will appear on-chain as the author, which is the
1445
+ * whole point of this rail.
1446
+ */
1447
+ interface PrepareRelayFeedbackRequest {
1448
+ x402Version: 1 | 2;
1449
+ network: Erc8004Network;
1450
+ feedback: FeedbackParams & {
1451
+ rater: string;
1452
+ };
1453
+ }
1454
+ /**
1455
+ * Response from `POST /feedback/evm/prepare`.
1456
+ *
1457
+ * Everything the rater has to sign so the CHAIN records them as the author
1458
+ * while the facilitator pays the gas.
1459
+ */
1460
+ interface PrepareRelayFeedbackResponse {
1461
+ success: boolean;
1462
+ /** The `FeedbackDelegate` the rater's EOA must be delegated to */
1463
+ delegate?: string;
1464
+ /** Registry calldata the rater is authorising, hex-encoded */
1465
+ data?: string;
1466
+ /**
1467
+ * The value the rater's signature must recover against.
1468
+ *
1469
+ * **The EIP-191 envelope is already applied here.** A holder of a raw key
1470
+ * signs this directly as a prehash (viem's `sign({ hash })`, ethers'
1471
+ * `signingKey.sign`). A WALLET must not be handed this value: `personal_sign`
1472
+ * applies the envelope itself, so it gets wrapped twice and recovers an
1473
+ * address that is not the rater. Wallets sign {@link signingPayload}.
1474
+ */
1475
+ digest?: string;
1476
+ /**
1477
+ * The same hash with the envelope still OFF — what a wallet signs.
1478
+ *
1479
+ * `keccak256('\x19Ethereum Signed Message:\n32' || signingPayload)` is
1480
+ * exactly {@link digest}, so a client can check the two against each other
1481
+ * rather than rebuilding the preimage from `data`.
1482
+ *
1483
+ * Requires facilitator v1.95.0+. Older facilitators omit it; a client that
1484
+ * needs it should fail loudly rather than fall back to signing `digest`
1485
+ * through a wallet, which produces a well-formed signature that authorises
1486
+ * nobody.
1487
+ */
1488
+ signingPayload?: string;
1489
+ /**
1490
+ * Unix seconds after which the authorisation is void. Short on purpose:
1491
+ * relaying is permissionless, so a signed authorisation is live in the wild
1492
+ * until it expires.
1493
+ */
1494
+ deadline?: number;
1495
+ /** Single-use value binding this authorisation. Echo it back on submit */
1496
+ nonce?: string;
1497
+ /**
1498
+ * Whether the account is already delegated. When `false` the submission MUST
1499
+ * carry an `authorization`.
1500
+ */
1501
+ delegated: boolean;
1502
+ /** The account nonce to put in the EIP-7702 authorization, when needed */
1503
+ accountNonce?: number;
1504
+ chainId: number;
1505
+ error?: string;
1506
+ network: Erc8004Network;
1507
+ }
1508
+ /**
1509
+ * Request body for `POST /feedback/evm/submit`.
1510
+ *
1511
+ * The feedback parameters are not redundant with `prepare`: the facilitator
1512
+ * rebuilds the registry calldata from them and requires the rater's signature
1513
+ * to cover exactly that. It does not relay calldata it was handed.
1514
+ */
1515
+ interface SubmitRelayFeedbackRequest {
1516
+ x402Version: 1 | 2;
1517
+ network: Erc8004Network;
1518
+ feedback: FeedbackParams & {
1519
+ rater: string;
1520
+ };
1521
+ /** The deadline `prepare` returned */
1522
+ deadline: number;
1523
+ /** The single-use nonce `prepare` returned */
1524
+ nonce: string;
1525
+ /**
1526
+ * The rater's signature. It must recover to `rater` over `digest` — so
1527
+ * either a raw-key prehash signature over `digest`, or a wallet
1528
+ * `personal_sign` over `signingPayload`. Not `personal_sign` over `digest`.
1529
+ */
1530
+ signature: string;
1531
+ /** Required only when `prepare` answered `delegated: false` */
1532
+ authorization?: RelayAuthorizationParams;
1533
+ }
1388
1534
  /**
1389
1535
  * Proof of payment returned when settling with ERC-8004 extension
1390
1536
  */
@@ -1871,6 +2017,14 @@ declare class Erc8004Client {
1871
2017
  *
1872
2018
  * Requires proof of payment for authorized feedback submission.
1873
2019
  *
2020
+ * @deprecated On this route the facilitator is the AUTHOR: the registry
2021
+ * records `msg.sender`, and that is the facilitator's wallet — which can also
2022
+ * revoke what it wrote. On the networks in {@link RELAYED_FEEDBACK_NETWORKS}
2023
+ * use {@link Erc8004Client.prepareRelayedFeedback} +
2024
+ * {@link Erc8004Client.submitRelayedFeedback} instead, which record the RATER
2025
+ * as author. This route still works and is not going away without notice: it
2026
+ * is the only one available where no `FeedbackDelegate` is deployed.
2027
+ *
1874
2028
  * @param request - Feedback request with agent ID, value, and proof
1875
2029
  * @returns Feedback response with transaction hash
1876
2030
  *
@@ -1898,6 +2052,71 @@ declare class Erc8004Client {
1898
2052
  * ```
1899
2053
  */
1900
2054
  submitFeedback(request: FeedbackRequest): Promise<FeedbackResponse>;
2055
+ /**
2056
+ * Ask the facilitator what the rater must sign to author a rating.
2057
+ *
2058
+ * Step 1 of the rater-authored rail. Writes nothing on-chain and costs
2059
+ * nothing: it reads the delegate, the rater's delegation state and their
2060
+ * account nonce, then hands back a digest, a deadline and a single-use nonce.
2061
+ *
2062
+ * Why this exists: the ERC-8004 Reputation Registry records `msg.sender` as
2063
+ * the author, and the deployed implementation has no delegation path — no
2064
+ * `giveFeedbackWithSignature`, no ERC-2771 forwarder. So a rating the
2065
+ * facilitator relays the ordinary way is a rating attributed to the
2066
+ * FACILITATOR. EIP-7702 fixes it without touching the registry: the rater
2067
+ * delegates their own EOA to the `FeedbackDelegate` and the transaction is
2068
+ * sent TO THE RATER'S ADDRESS, so the registry sees the rater while the
2069
+ * facilitator pays.
2070
+ *
2071
+ * What to do with the answer:
2072
+ * 1. Produce the rater's signature. **Which value you sign depends on how you
2073
+ * sign it**, and getting it wrong yields a well-formed signature that
2074
+ * authorises nobody:
2075
+ * - raw key: sign `digest` as a **prehash**. It already carries the
2076
+ * EIP-191 envelope.
2077
+ * - wallet: `personal_sign` over `signingPayload`. `personal_sign` adds the
2078
+ * envelope itself, so signing `digest` with it wraps the value TWICE and
2079
+ * recovers a stranger — the only symptom is `relay_bad_signature`.
2080
+ * 2. If `delegated` is `false`, also produce an EIP-7702 authorization over
2081
+ * `(chainId, delegate, accountNonce)`.
2082
+ * 3. Hand both to {@link submitRelayedFeedback} with the SAME feedback
2083
+ * parameters, `deadline` and `nonce`.
2084
+ *
2085
+ * @param request - Network, rater address and feedback parameters
2086
+ * @returns Everything needed to sign, including whether an EIP-7702
2087
+ * authorization is still required
2088
+ *
2089
+ * @example
2090
+ * ```ts
2091
+ * const prep = await erc8004.prepareRelayedFeedback({
2092
+ * x402Version: 1,
2093
+ * network: 'base',
2094
+ * feedback: { agentId: 18896, value: 95, tag1: 'quality', rater: raterAddress },
2095
+ * });
2096
+ * // prep.delegated === false -> an EIP-7702 authorization is required
2097
+ * ```
2098
+ */
2099
+ prepareRelayedFeedback(request: PrepareRelayFeedbackRequest): Promise<PrepareRelayFeedbackResponse>;
2100
+ /**
2101
+ * Relay a rater-authored rating; the facilitator pays the gas.
2102
+ *
2103
+ * Step 2 of the rater-authored rail. The on-chain record that comes out of it
2104
+ * has the RATER as `msg.sender`, so `getClients(agentId)` shows the rater
2105
+ * rather than the facilitator.
2106
+ *
2107
+ * Pass back the same feedback parameters, `deadline` and `nonce` that
2108
+ * {@link prepareRelayedFeedback} returned. They are not redundant: the
2109
+ * facilitator rebuilds the registry calldata from them and requires the
2110
+ * rater's signature to cover exactly that.
2111
+ *
2112
+ * `authorization` is required only when `prepare` answered
2113
+ * `delegated: false`. One that names a different delegate than the one
2114
+ * `prepare` offered is refused before any gas is spent.
2115
+ *
2116
+ * @param request - Feedback parameters plus the rater's signature
2117
+ * @returns Feedback response with the transaction hash
2118
+ */
2119
+ submitRelayedFeedback(request: SubmitRelayFeedbackRequest): Promise<FeedbackResponse>;
1901
2120
  /**
1902
2121
  * Revoke previously submitted feedback
1903
2122
  *
@@ -2528,4 +2747,4 @@ declare class AdvancedEscrowClient {
2528
2747
  private sendViaAdapter;
2529
2748
  }
2530
2749
 
2531
- export { type AdvancedAuthorizationResult, AdvancedEscrowClient, type AdvancedEscrowClientOptions, type AdvancedEscrowContracts, type AdvancedEscrowTaskTier, type AdvancedPaymentInfo, type AdvancedTransactionResult, type AgentId, type AgentIdentity, type AgentRegistration, type AgentRegistrationFile, type AgentService, type AtomStats, BASE_MAINNET_CONTRACTS, BazaarClient, type BazaarClientOptions, type BazaarDiscoverOptions, type BazaarDiscoverResponse, type BazaarRegisterOptions, type BazaarResource, type CreateEscrowOptions, DEPOSIT_LIMIT_USDC, type DiscoveryAccepts, type DiscoveryCuration, type DiscoveryHealth, type DiscoveryHealthStatus, type DiscoveryListOptions, type DiscoveryPagination, type DiscoveryRegisterOptions, type DiscoveryResource, type DiscoveryResponse, type DiscoverySource, type DiscoveryStats, type DiscoveryTier, type Dispute, type DisputeOutcome, ERC8004_CONTRACTS, ERC8004_EXTENSION_ID, ESCROW_CONTRACTS, ESCROW_TIMEOUT_MS, Erc8004Client, type Erc8004ClientOptions, Erc8004LookupError, type Erc8004Network, EscrowClient, type EscrowClientOptions, type EscrowPayment, type EscrowStateResponse, type EscrowStatus, FacilitatorClient, type FacilitatorClientOptions, type FeedbackEntry, type FeedbackParams, type FeedbackRequest, type FeedbackResponse, HEALTH_FILTERS, type HonoMiddlewareOptions, type IdentityByOwnerResponse, type IdentityMetadataResponse, type IdentityTotalSupplyResponse, MAX_SEARCH_LEN, type MetadataEntryParam, OPERATOR_ABI, OPERATOR_ABI_CREATE3, PAYMENT_INFO_TYPEHASH, type PaymentAcceptance, type PaymentMiddlewareOptions, type PaymentPayloadV2, type PaymentRequirementResolver, type PaymentRequirements, type PaymentRequirementsOptions, type PaymentRequirementsV2, type ProofOfPayment, type RefundRequest, type RefundStatus, type RegisterAgentRequest, type RegisterAgentResponse, type RegisterJobResponse, type RegisterJobStatus, RegistrationPendingError, type ReputationResponse, type ReputationSummary, type RequestRefundOptions, type ResourceInfoV2, type SettleRequest, type SettleRequestV2, type SettleResponse, type SettleResponseWithProof, TIER_FILTERS, TIER_TIMINGS, USDC_DOMAIN_NAME, type VerifiedPaymentState, type VerifyRequest, type VerifyRequestV2, type VerifyResponse, X402_CORS_HEADERS, X402_HEADER_NAMES, ZERO_ADDRESS, buildErc8004PaymentRequirements, buildPaymentRequirements, buildSettleRequest, buildSettleRequestV2, buildVerifyRequest, buildVerifyRequestV2, canRefundEscrow, canReleaseEscrow, create402Response, createHonoMiddleware, createPaymentMiddleware, epochToDate, escrowTimeRemaining, extractPaymentFromHeaders, getCorsHeaders, getEscrowContractsByChainId, getEscrowSupportedChainIds, isAlive, isEscrowExpired, isEscrowSupportedOnChain, isRegisterJobTerminal, parsePaymentHeader, wireNetwork };
2750
+ export { type AdvancedAuthorizationResult, AdvancedEscrowClient, type AdvancedEscrowClientOptions, type AdvancedEscrowContracts, type AdvancedEscrowTaskTier, type AdvancedPaymentInfo, type AdvancedTransactionResult, type AgentId, type AgentIdentity, type AgentRegistration, type AgentRegistrationFile, type AgentService, type AtomStats, BASE_MAINNET_CONTRACTS, BazaarClient, type BazaarClientOptions, type BazaarDiscoverOptions, type BazaarDiscoverResponse, type BazaarRegisterOptions, type BazaarResource, type CreateEscrowOptions, DEPOSIT_LIMIT_USDC, type DiscoveryAccepts, type DiscoveryCuration, type DiscoveryHealth, type DiscoveryHealthStatus, type DiscoveryListOptions, type DiscoveryPagination, type DiscoveryRegisterOptions, type DiscoveryResource, type DiscoveryResponse, type DiscoverySource, type DiscoveryStats, type DiscoveryTier, type Dispute, type DisputeOutcome, ERC8004_CONTRACTS, ERC8004_EXTENSION_ID, ESCROW_CONTRACTS, ESCROW_TIMEOUT_MS, Erc8004Client, type Erc8004ClientOptions, Erc8004LookupError, type Erc8004Network, EscrowClient, type EscrowClientOptions, type EscrowPayment, type EscrowStateResponse, type EscrowStatus, FacilitatorClient, type FacilitatorClientOptions, type FeedbackEntry, type FeedbackParams, type FeedbackRequest, type FeedbackResponse, HEALTH_FILTERS, type HonoMiddlewareOptions, type IdentityByOwnerResponse, type IdentityMetadataResponse, type IdentityTotalSupplyResponse, MAX_SEARCH_LEN, type MetadataEntryParam, OPERATOR_ABI, OPERATOR_ABI_CREATE3, PAYMENT_INFO_TYPEHASH, type PaymentAcceptance, type PaymentMiddlewareOptions, type PaymentPayloadV2, type PaymentRequirementResolver, type PaymentRequirements, type PaymentRequirementsOptions, type PaymentRequirementsV2, type PrepareRelayFeedbackRequest, type PrepareRelayFeedbackResponse, type ProofOfPayment, RELAYED_FEEDBACK_NETWORKS, type RefundRequest, type RefundStatus, type RegisterAgentRequest, type RegisterAgentResponse, type RegisterJobResponse, type RegisterJobStatus, RegistrationPendingError, type RelayAuthorizationParams, type ReputationResponse, type ReputationSummary, type RequestRefundOptions, type ResourceInfoV2, type SettleRequest, type SettleRequestV2, type SettleResponse, type SettleResponseWithProof, type SubmitRelayFeedbackRequest, TIER_FILTERS, TIER_TIMINGS, USDC_DOMAIN_NAME, type VerifiedPaymentState, type VerifyRequest, type VerifyRequestV2, type VerifyResponse, X402_CORS_HEADERS, X402_HEADER_NAMES, ZERO_ADDRESS, buildErc8004PaymentRequirements, buildPaymentRequirements, buildSettleRequest, buildSettleRequestV2, buildVerifyRequest, buildVerifyRequestV2, canRefundEscrow, canReleaseEscrow, create402Response, createHonoMiddleware, createPaymentMiddleware, epochToDate, escrowTimeRemaining, extractPaymentFromHeaders, getCorsHeaders, getEscrowContractsByChainId, getEscrowSupportedChainIds, isAlive, isEscrowExpired, isEscrowSupportedOnChain, isRegisterJobTerminal, parsePaymentHeader, supportsRelayedFeedback, wireNetwork };
@@ -1385,6 +1385,152 @@ declare function wireNetwork(network: string): string;
1385
1385
  * reaches the wire. Use 'base'.
1386
1386
  */
1387
1387
  type Erc8004Network = 'ethereum' | 'base' | 'polygon' | 'arbitrum' | 'optimism' | 'celo' | 'bsc' | 'monad' | 'avalanche' | 'scroll' | 'skale-base' | 'base-mainnet' | 'ethereum-sepolia' | 'base-sepolia' | 'polygon-amoy' | 'arbitrum-sepolia' | 'optimism-sepolia' | 'celo-sepolia' | 'avalanche-fuji' | 'skale-base-sepolia' | 'solana' | 'solana-devnet';
1388
+ /**
1389
+ * Networks where the facilitator serves the RELAYED feedback rail, i.e. where
1390
+ * Execution Market has deployed a `FeedbackDelegate` and the facilitator
1391
+ * verified it on-chain (code present, and its `REPUTATION_REGISTRY()` reads
1392
+ * back that network's registry).
1393
+ *
1394
+ * Anywhere else `POST /feedback/evm/prepare` answers 400 — and it should. An
1395
+ * invented delegate address would send a type-4 transaction to an account with
1396
+ * no code behind it, and in the EVM a `.call()` to an address with no code
1397
+ * RETURNS SUCCESS. The failure would look exactly like a rating that rated
1398
+ * nobody.
1399
+ *
1400
+ * `avalanche` is absent and is not waiting to join: the C-Chain rejects the
1401
+ * transaction type itself (`-32000 transaction type not supported`), so there
1402
+ * is nothing to deploy against. Anchor the rating on a chain that supports
1403
+ * EIP-7702; the payment stays where it was made.
1404
+ */
1405
+ declare const RELAYED_FEEDBACK_NETWORKS: readonly Erc8004Network[];
1406
+ /**
1407
+ * Whether `network` serves the rater-authored feedback rail.
1408
+ *
1409
+ * Lets a caller route without paying a round trip for a 400. The facilitator
1410
+ * re-checks the delegate on-chain on every request regardless — this list is a
1411
+ * routing hint, never the authority.
1412
+ */
1413
+ declare function supportsRelayedFeedback(network: string): boolean;
1414
+ /**
1415
+ * An EIP-7702 authorization, as a wallet produces it.
1416
+ *
1417
+ * Needed only the first time a rater rates: it points their EOA at the
1418
+ * `FeedbackDelegate`. Once delegated, `prepare` answers `delegated: true` and
1419
+ * the submission carries no authorization at all.
1420
+ */
1421
+ interface RelayAuthorizationParams {
1422
+ /**
1423
+ * Chain the authorization is for.
1424
+ *
1425
+ * `0` is EIP-7702's wildcard and is valid on EVERY chain — a far broader
1426
+ * grant than pinning this one. Send the chain id `prepare` returned.
1427
+ */
1428
+ chainId: number;
1429
+ /**
1430
+ * The delegate the account is pointed at. Must be the address `prepare`
1431
+ * offered; the facilitator refuses anything else before it pays for a
1432
+ * transaction.
1433
+ */
1434
+ address: string;
1435
+ /** The rater account's nonce at the moment the authorization executes */
1436
+ nonce: number;
1437
+ yParity: number;
1438
+ r: string;
1439
+ s: string;
1440
+ }
1441
+ /**
1442
+ * Request body for `POST /feedback/evm/prepare`.
1443
+ *
1444
+ * `rater` is the address that will appear on-chain as the author, which is the
1445
+ * whole point of this rail.
1446
+ */
1447
+ interface PrepareRelayFeedbackRequest {
1448
+ x402Version: 1 | 2;
1449
+ network: Erc8004Network;
1450
+ feedback: FeedbackParams & {
1451
+ rater: string;
1452
+ };
1453
+ }
1454
+ /**
1455
+ * Response from `POST /feedback/evm/prepare`.
1456
+ *
1457
+ * Everything the rater has to sign so the CHAIN records them as the author
1458
+ * while the facilitator pays the gas.
1459
+ */
1460
+ interface PrepareRelayFeedbackResponse {
1461
+ success: boolean;
1462
+ /** The `FeedbackDelegate` the rater's EOA must be delegated to */
1463
+ delegate?: string;
1464
+ /** Registry calldata the rater is authorising, hex-encoded */
1465
+ data?: string;
1466
+ /**
1467
+ * The value the rater's signature must recover against.
1468
+ *
1469
+ * **The EIP-191 envelope is already applied here.** A holder of a raw key
1470
+ * signs this directly as a prehash (viem's `sign({ hash })`, ethers'
1471
+ * `signingKey.sign`). A WALLET must not be handed this value: `personal_sign`
1472
+ * applies the envelope itself, so it gets wrapped twice and recovers an
1473
+ * address that is not the rater. Wallets sign {@link signingPayload}.
1474
+ */
1475
+ digest?: string;
1476
+ /**
1477
+ * The same hash with the envelope still OFF — what a wallet signs.
1478
+ *
1479
+ * `keccak256('\x19Ethereum Signed Message:\n32' || signingPayload)` is
1480
+ * exactly {@link digest}, so a client can check the two against each other
1481
+ * rather than rebuilding the preimage from `data`.
1482
+ *
1483
+ * Requires facilitator v1.95.0+. Older facilitators omit it; a client that
1484
+ * needs it should fail loudly rather than fall back to signing `digest`
1485
+ * through a wallet, which produces a well-formed signature that authorises
1486
+ * nobody.
1487
+ */
1488
+ signingPayload?: string;
1489
+ /**
1490
+ * Unix seconds after which the authorisation is void. Short on purpose:
1491
+ * relaying is permissionless, so a signed authorisation is live in the wild
1492
+ * until it expires.
1493
+ */
1494
+ deadline?: number;
1495
+ /** Single-use value binding this authorisation. Echo it back on submit */
1496
+ nonce?: string;
1497
+ /**
1498
+ * Whether the account is already delegated. When `false` the submission MUST
1499
+ * carry an `authorization`.
1500
+ */
1501
+ delegated: boolean;
1502
+ /** The account nonce to put in the EIP-7702 authorization, when needed */
1503
+ accountNonce?: number;
1504
+ chainId: number;
1505
+ error?: string;
1506
+ network: Erc8004Network;
1507
+ }
1508
+ /**
1509
+ * Request body for `POST /feedback/evm/submit`.
1510
+ *
1511
+ * The feedback parameters are not redundant with `prepare`: the facilitator
1512
+ * rebuilds the registry calldata from them and requires the rater's signature
1513
+ * to cover exactly that. It does not relay calldata it was handed.
1514
+ */
1515
+ interface SubmitRelayFeedbackRequest {
1516
+ x402Version: 1 | 2;
1517
+ network: Erc8004Network;
1518
+ feedback: FeedbackParams & {
1519
+ rater: string;
1520
+ };
1521
+ /** The deadline `prepare` returned */
1522
+ deadline: number;
1523
+ /** The single-use nonce `prepare` returned */
1524
+ nonce: string;
1525
+ /**
1526
+ * The rater's signature. It must recover to `rater` over `digest` — so
1527
+ * either a raw-key prehash signature over `digest`, or a wallet
1528
+ * `personal_sign` over `signingPayload`. Not `personal_sign` over `digest`.
1529
+ */
1530
+ signature: string;
1531
+ /** Required only when `prepare` answered `delegated: false` */
1532
+ authorization?: RelayAuthorizationParams;
1533
+ }
1388
1534
  /**
1389
1535
  * Proof of payment returned when settling with ERC-8004 extension
1390
1536
  */
@@ -1871,6 +2017,14 @@ declare class Erc8004Client {
1871
2017
  *
1872
2018
  * Requires proof of payment for authorized feedback submission.
1873
2019
  *
2020
+ * @deprecated On this route the facilitator is the AUTHOR: the registry
2021
+ * records `msg.sender`, and that is the facilitator's wallet — which can also
2022
+ * revoke what it wrote. On the networks in {@link RELAYED_FEEDBACK_NETWORKS}
2023
+ * use {@link Erc8004Client.prepareRelayedFeedback} +
2024
+ * {@link Erc8004Client.submitRelayedFeedback} instead, which record the RATER
2025
+ * as author. This route still works and is not going away without notice: it
2026
+ * is the only one available where no `FeedbackDelegate` is deployed.
2027
+ *
1874
2028
  * @param request - Feedback request with agent ID, value, and proof
1875
2029
  * @returns Feedback response with transaction hash
1876
2030
  *
@@ -1898,6 +2052,71 @@ declare class Erc8004Client {
1898
2052
  * ```
1899
2053
  */
1900
2054
  submitFeedback(request: FeedbackRequest): Promise<FeedbackResponse>;
2055
+ /**
2056
+ * Ask the facilitator what the rater must sign to author a rating.
2057
+ *
2058
+ * Step 1 of the rater-authored rail. Writes nothing on-chain and costs
2059
+ * nothing: it reads the delegate, the rater's delegation state and their
2060
+ * account nonce, then hands back a digest, a deadline and a single-use nonce.
2061
+ *
2062
+ * Why this exists: the ERC-8004 Reputation Registry records `msg.sender` as
2063
+ * the author, and the deployed implementation has no delegation path — no
2064
+ * `giveFeedbackWithSignature`, no ERC-2771 forwarder. So a rating the
2065
+ * facilitator relays the ordinary way is a rating attributed to the
2066
+ * FACILITATOR. EIP-7702 fixes it without touching the registry: the rater
2067
+ * delegates their own EOA to the `FeedbackDelegate` and the transaction is
2068
+ * sent TO THE RATER'S ADDRESS, so the registry sees the rater while the
2069
+ * facilitator pays.
2070
+ *
2071
+ * What to do with the answer:
2072
+ * 1. Produce the rater's signature. **Which value you sign depends on how you
2073
+ * sign it**, and getting it wrong yields a well-formed signature that
2074
+ * authorises nobody:
2075
+ * - raw key: sign `digest` as a **prehash**. It already carries the
2076
+ * EIP-191 envelope.
2077
+ * - wallet: `personal_sign` over `signingPayload`. `personal_sign` adds the
2078
+ * envelope itself, so signing `digest` with it wraps the value TWICE and
2079
+ * recovers a stranger — the only symptom is `relay_bad_signature`.
2080
+ * 2. If `delegated` is `false`, also produce an EIP-7702 authorization over
2081
+ * `(chainId, delegate, accountNonce)`.
2082
+ * 3. Hand both to {@link submitRelayedFeedback} with the SAME feedback
2083
+ * parameters, `deadline` and `nonce`.
2084
+ *
2085
+ * @param request - Network, rater address and feedback parameters
2086
+ * @returns Everything needed to sign, including whether an EIP-7702
2087
+ * authorization is still required
2088
+ *
2089
+ * @example
2090
+ * ```ts
2091
+ * const prep = await erc8004.prepareRelayedFeedback({
2092
+ * x402Version: 1,
2093
+ * network: 'base',
2094
+ * feedback: { agentId: 18896, value: 95, tag1: 'quality', rater: raterAddress },
2095
+ * });
2096
+ * // prep.delegated === false -> an EIP-7702 authorization is required
2097
+ * ```
2098
+ */
2099
+ prepareRelayedFeedback(request: PrepareRelayFeedbackRequest): Promise<PrepareRelayFeedbackResponse>;
2100
+ /**
2101
+ * Relay a rater-authored rating; the facilitator pays the gas.
2102
+ *
2103
+ * Step 2 of the rater-authored rail. The on-chain record that comes out of it
2104
+ * has the RATER as `msg.sender`, so `getClients(agentId)` shows the rater
2105
+ * rather than the facilitator.
2106
+ *
2107
+ * Pass back the same feedback parameters, `deadline` and `nonce` that
2108
+ * {@link prepareRelayedFeedback} returned. They are not redundant: the
2109
+ * facilitator rebuilds the registry calldata from them and requires the
2110
+ * rater's signature to cover exactly that.
2111
+ *
2112
+ * `authorization` is required only when `prepare` answered
2113
+ * `delegated: false`. One that names a different delegate than the one
2114
+ * `prepare` offered is refused before any gas is spent.
2115
+ *
2116
+ * @param request - Feedback parameters plus the rater's signature
2117
+ * @returns Feedback response with the transaction hash
2118
+ */
2119
+ submitRelayedFeedback(request: SubmitRelayFeedbackRequest): Promise<FeedbackResponse>;
1901
2120
  /**
1902
2121
  * Revoke previously submitted feedback
1903
2122
  *
@@ -2528,4 +2747,4 @@ declare class AdvancedEscrowClient {
2528
2747
  private sendViaAdapter;
2529
2748
  }
2530
2749
 
2531
- export { type AdvancedAuthorizationResult, AdvancedEscrowClient, type AdvancedEscrowClientOptions, type AdvancedEscrowContracts, type AdvancedEscrowTaskTier, type AdvancedPaymentInfo, type AdvancedTransactionResult, type AgentId, type AgentIdentity, type AgentRegistration, type AgentRegistrationFile, type AgentService, type AtomStats, BASE_MAINNET_CONTRACTS, BazaarClient, type BazaarClientOptions, type BazaarDiscoverOptions, type BazaarDiscoverResponse, type BazaarRegisterOptions, type BazaarResource, type CreateEscrowOptions, DEPOSIT_LIMIT_USDC, type DiscoveryAccepts, type DiscoveryCuration, type DiscoveryHealth, type DiscoveryHealthStatus, type DiscoveryListOptions, type DiscoveryPagination, type DiscoveryRegisterOptions, type DiscoveryResource, type DiscoveryResponse, type DiscoverySource, type DiscoveryStats, type DiscoveryTier, type Dispute, type DisputeOutcome, ERC8004_CONTRACTS, ERC8004_EXTENSION_ID, ESCROW_CONTRACTS, ESCROW_TIMEOUT_MS, Erc8004Client, type Erc8004ClientOptions, Erc8004LookupError, type Erc8004Network, EscrowClient, type EscrowClientOptions, type EscrowPayment, type EscrowStateResponse, type EscrowStatus, FacilitatorClient, type FacilitatorClientOptions, type FeedbackEntry, type FeedbackParams, type FeedbackRequest, type FeedbackResponse, HEALTH_FILTERS, type HonoMiddlewareOptions, type IdentityByOwnerResponse, type IdentityMetadataResponse, type IdentityTotalSupplyResponse, MAX_SEARCH_LEN, type MetadataEntryParam, OPERATOR_ABI, OPERATOR_ABI_CREATE3, PAYMENT_INFO_TYPEHASH, type PaymentAcceptance, type PaymentMiddlewareOptions, type PaymentPayloadV2, type PaymentRequirementResolver, type PaymentRequirements, type PaymentRequirementsOptions, type PaymentRequirementsV2, type ProofOfPayment, type RefundRequest, type RefundStatus, type RegisterAgentRequest, type RegisterAgentResponse, type RegisterJobResponse, type RegisterJobStatus, RegistrationPendingError, type ReputationResponse, type ReputationSummary, type RequestRefundOptions, type ResourceInfoV2, type SettleRequest, type SettleRequestV2, type SettleResponse, type SettleResponseWithProof, TIER_FILTERS, TIER_TIMINGS, USDC_DOMAIN_NAME, type VerifiedPaymentState, type VerifyRequest, type VerifyRequestV2, type VerifyResponse, X402_CORS_HEADERS, X402_HEADER_NAMES, ZERO_ADDRESS, buildErc8004PaymentRequirements, buildPaymentRequirements, buildSettleRequest, buildSettleRequestV2, buildVerifyRequest, buildVerifyRequestV2, canRefundEscrow, canReleaseEscrow, create402Response, createHonoMiddleware, createPaymentMiddleware, epochToDate, escrowTimeRemaining, extractPaymentFromHeaders, getCorsHeaders, getEscrowContractsByChainId, getEscrowSupportedChainIds, isAlive, isEscrowExpired, isEscrowSupportedOnChain, isRegisterJobTerminal, parsePaymentHeader, wireNetwork };
2750
+ export { type AdvancedAuthorizationResult, AdvancedEscrowClient, type AdvancedEscrowClientOptions, type AdvancedEscrowContracts, type AdvancedEscrowTaskTier, type AdvancedPaymentInfo, type AdvancedTransactionResult, type AgentId, type AgentIdentity, type AgentRegistration, type AgentRegistrationFile, type AgentService, type AtomStats, BASE_MAINNET_CONTRACTS, BazaarClient, type BazaarClientOptions, type BazaarDiscoverOptions, type BazaarDiscoverResponse, type BazaarRegisterOptions, type BazaarResource, type CreateEscrowOptions, DEPOSIT_LIMIT_USDC, type DiscoveryAccepts, type DiscoveryCuration, type DiscoveryHealth, type DiscoveryHealthStatus, type DiscoveryListOptions, type DiscoveryPagination, type DiscoveryRegisterOptions, type DiscoveryResource, type DiscoveryResponse, type DiscoverySource, type DiscoveryStats, type DiscoveryTier, type Dispute, type DisputeOutcome, ERC8004_CONTRACTS, ERC8004_EXTENSION_ID, ESCROW_CONTRACTS, ESCROW_TIMEOUT_MS, Erc8004Client, type Erc8004ClientOptions, Erc8004LookupError, type Erc8004Network, EscrowClient, type EscrowClientOptions, type EscrowPayment, type EscrowStateResponse, type EscrowStatus, FacilitatorClient, type FacilitatorClientOptions, type FeedbackEntry, type FeedbackParams, type FeedbackRequest, type FeedbackResponse, HEALTH_FILTERS, type HonoMiddlewareOptions, type IdentityByOwnerResponse, type IdentityMetadataResponse, type IdentityTotalSupplyResponse, MAX_SEARCH_LEN, type MetadataEntryParam, OPERATOR_ABI, OPERATOR_ABI_CREATE3, PAYMENT_INFO_TYPEHASH, type PaymentAcceptance, type PaymentMiddlewareOptions, type PaymentPayloadV2, type PaymentRequirementResolver, type PaymentRequirements, type PaymentRequirementsOptions, type PaymentRequirementsV2, type PrepareRelayFeedbackRequest, type PrepareRelayFeedbackResponse, type ProofOfPayment, RELAYED_FEEDBACK_NETWORKS, type RefundRequest, type RefundStatus, type RegisterAgentRequest, type RegisterAgentResponse, type RegisterJobResponse, type RegisterJobStatus, RegistrationPendingError, type RelayAuthorizationParams, type ReputationResponse, type ReputationSummary, type RequestRefundOptions, type ResourceInfoV2, type SettleRequest, type SettleRequestV2, type SettleResponse, type SettleResponseWithProof, type SubmitRelayFeedbackRequest, TIER_FILTERS, TIER_TIMINGS, USDC_DOMAIN_NAME, type VerifiedPaymentState, type VerifyRequest, type VerifyRequestV2, type VerifyResponse, X402_CORS_HEADERS, X402_HEADER_NAMES, ZERO_ADDRESS, buildErc8004PaymentRequirements, buildPaymentRequirements, buildSettleRequest, buildSettleRequestV2, buildVerifyRequest, buildVerifyRequestV2, canRefundEscrow, canReleaseEscrow, create402Response, createHonoMiddleware, createPaymentMiddleware, epochToDate, escrowTimeRemaining, extractPaymentFromHeaders, getCorsHeaders, getEscrowContractsByChainId, getEscrowSupportedChainIds, isAlive, isEscrowExpired, isEscrowSupportedOnChain, isRegisterJobTerminal, parsePaymentHeader, supportsRelayedFeedback, wireNetwork };