diff --git a/typescript/packages/core/src/http/x402HTTPResourceServer.ts b/typescript/packages/core/src/http/x402HTTPResourceServer.ts
index 0cd074ea81..184076ecb4 100644
--- a/typescript/packages/core/src/http/x402HTTPResourceServer.ts
+++ b/typescript/packages/core/src/http/x402HTTPResourceServer.ts
@@ -1031,6 +1031,13 @@ export class x402HTTPResourceServer {
// Fallback: Basic HTML paywall
const resource = paymentRequired.resource;
const displayAmount = this.getDisplayAmount(paymentRequired);
+ const firstAccept = paymentRequired.accepts?.[0];
+ const assetLabel =
+ typeof firstAccept?.extra?.name === "string"
+ ? firstAccept.extra.name
+ : firstAccept?.asset
+ ? `...${firstAccept.asset.slice(-6)}`
+ : "Token";
return `
@@ -1045,7 +1052,7 @@ export class x402HTTPResourceServer {
${paywallConfig?.appLogo ? `
` : ""}
Payment Required
${resource ? `Resource: ${resource.description || resource.url}
` : ""}
- Amount: $${displayAmount.toFixed(2)} USDC
+ Amount: ${displayAmount.toFixed(6)} ${assetLabel}
0) {
const firstReq = accepts[0];
if ("amount" in firstReq) {
- // V2 format
- return parseFloat(firstReq.amount) / 1000000; // Assuming USDC with 6 decimals
+ const decimals = this.ResourceServer.getAssetDecimalsForRequirements(firstReq);
+ return parseFloat(firstReq.amount) / 10 ** decimals;
}
}
return 0;
diff --git a/typescript/packages/core/src/server/x402ResourceServer.ts b/typescript/packages/core/src/server/x402ResourceServer.ts
index 14f8aab79e..1c7f0a445d 100644
--- a/typescript/packages/core/src/server/x402ResourceServer.ts
+++ b/typescript/packages/core/src/server/x402ResourceServer.ts
@@ -232,6 +232,24 @@ export class x402ResourceServer {
return !!findByNetworkAndScheme(this.registeredServerSchemes, scheme, network);
}
+ /**
+ * Returns the decimal precision for the asset specified in the given payment requirements.
+ * Looks up the registered scheme for the network and delegates to its getAssetDecimals
+ * method if available. Falls back to 6 (standard for USDC stablecoins) when the scheme
+ * does not implement getAssetDecimals or is not registered.
+ *
+ * @param requirements - The payment requirements containing scheme, network, and asset
+ * @returns The number of decimal places for the asset
+ */
+ getAssetDecimalsForRequirements(requirements: PaymentRequirements): number {
+ const scheme = findByNetworkAndScheme(
+ this.registeredServerSchemes,
+ requirements.scheme,
+ requirements.network as Network,
+ );
+ return scheme?.getAssetDecimals?.(requirements.asset ?? "", requirements.network as Network) ?? 6;
+ }
+
/**
* Registers a resource service extension that can enrich extension declarations.
*