Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go/http/evm_paywall_template.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion go/http/svm_paywall_template.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion python/x402/http/paywall/evm_paywall_template.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion python/x402/http/paywall/svm_paywall_template.py

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions typescript/.changeset/fix-paywall-token-name.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@x402/paywall": patch
---

fix(paywall): read token name from payment requirements instead of hardcoding "USDC"

The EVM paywall now reads the token name from `extra.name` in payment requirements
and uses it for all display text. Falls back to "Token" (generic) when `extra.name`
is absent. This fixes mislabeled token names for non-USDC chains (MegaUSD, USDT0,
Mezo USD, etc.).
17 changes: 10 additions & 7 deletions typescript/packages/http/paywall/src/evm/EvmPaywall.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export function EvmPaywall({ paymentRequired, onSuccessfulResponse }: EvmPaywall
}

const network = firstRequirement.network;
const tokenName = (firstRequirement.extra?.name as string) || "Token";
const chainName = getNetworkDisplayName(network);
const testnet = isTestnetNetwork(network);

Expand Down Expand Up @@ -138,11 +139,11 @@ export function EvmPaywall({ paymentRequired, onSuccessfulResponse }: EvmPaywall
setIsPaying(true);

try {
setStatus("Checking USDC balance...");
setStatus("Checking balance...");
const balance = await getUSDCBalance(publicClient, address);

if (balance === 0n) {
throw new Error(`Insufficient balance. Make sure you have USDC on ${chainName}`);
throw new Error(`Insufficient balance. Make sure you have ${tokenName} on ${chainName}`);
}

setStatus("Creating payment signature...");
Expand Down Expand Up @@ -196,11 +197,11 @@ export function EvmPaywall({ paymentRequired, onSuccessfulResponse }: EvmPaywall
<h1 className="title">Payment Required</h1>
<p>
{paymentRequired.resource?.description && `${paymentRequired.resource.description}.`} To
access this content, please pay ${amount} {chainName} USDC.
access this content, please pay ${amount} {tokenName}.
</p>
{testnet && (
<p className="instructions">
Need {chainName} USDC?{" "}
Need {tokenName} on {chainName}?{" "}
<a href="https://faucet.circle.com/" target="_blank" rel="noopener noreferrer">
Get some <u>here</u>.
</a>
Expand Down Expand Up @@ -259,14 +260,16 @@ export function EvmPaywall({ paymentRequired, onSuccessfulResponse }: EvmPaywall
<span className="payment-value">
<button className="balance-button" onClick={() => setHideBalance(prev => !prev)}>
{formattedUsdcBalance && !hideBalance
? `$${formattedUsdcBalance} USDC`
: "••••• USDC"}
? `$${formattedUsdcBalance} ${tokenName}`
: `••••• ${tokenName}`}
</button>
</span>
</div>
<div className="payment-row">
<span className="payment-label">Amount:</span>
<span className="payment-value">${amount} USDC</span>
<span className="payment-value">
${amount} {tokenName}
</span>
</div>
<div className="payment-row">
<span className="payment-label">Network:</span>
Expand Down
2 changes: 1 addition & 1 deletion typescript/packages/http/paywall/src/evm/gen/template.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion typescript/packages/http/paywall/src/svm/gen/template.ts

Large diffs are not rendered by default.

Loading