Skip to content

Commit b3d6d97

Browse files
committed
fix(paywall): replace hardcoded USDC label with dynamic token name
Read token name from firstRequirement.extra.name with a neutral "Token" fallback instead of hardcoding "USDC". Aligns with #1926 which takes the same approach for the server-side fallback paywall. Affected display strings: payment header, testnet prompt, balance display, amount row, insufficient balance error message. This PR was prepared with the assistance of a coding agent and reviewed by Ryan R. Fox (an actual human) before submission.
1 parent 9a67807 commit b3d6d97

4 files changed

Lines changed: 13 additions & 8 deletions

File tree

go/http/evm_paywall_template.go

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

python/x402/http/paywall/evm_paywall_template.py

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

typescript/packages/http/paywall/src/evm/EvmPaywall.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export function EvmPaywall({ paymentRequired, onSuccessfulResponse }: EvmPaywall
5050

5151
const network = firstRequirement.network;
5252
const tokenAddress = firstRequirement.asset as `0x${string}`;
53+
const tokenName = (firstRequirement.extra?.name as string) || "Token";
5354
const chainName = getNetworkDisplayName(network);
5455
const testnet = isTestnetNetwork(network);
5556

@@ -145,7 +146,7 @@ export function EvmPaywall({ paymentRequired, onSuccessfulResponse }: EvmPaywall
145146
const balance = await getTokenBalance(publicClient, address, tokenAddress);
146147

147148
if (balance === 0n) {
148-
throw new Error(`Insufficient balance. Make sure you have USDC on ${chainName}`);
149+
throw new Error(`Insufficient balance. Make sure you have ${tokenName} on ${chainName}`);
149150
}
150151

151152
setStatus("Creating payment signature...");
@@ -199,11 +200,11 @@ export function EvmPaywall({ paymentRequired, onSuccessfulResponse }: EvmPaywall
199200
<h1 className="title">Payment Required</h1>
200201
<p>
201202
{paymentRequired.resource?.description && `${paymentRequired.resource.description}.`} To
202-
access this content, please pay ${amount} {chainName} USDC.
203+
access this content, please pay ${amount} {tokenName}.
203204
</p>
204205
{testnet && (
205206
<p className="instructions">
206-
Need {chainName} USDC?{" "}
207+
Need {tokenName} on {chainName}?{" "}
207208
<a href="https://faucet.circle.com/" target="_blank" rel="noopener noreferrer">
208209
Get some <u>here</u>.
209210
</a>
@@ -261,13 +262,17 @@ export function EvmPaywall({ paymentRequired, onSuccessfulResponse }: EvmPaywall
261262
<span className="payment-label">Available balance:</span>
262263
<span className="payment-value">
263264
<button className="balance-button" onClick={() => setHideBalance(prev => !prev)}>
264-
{formattedBalance && !hideBalance ? `$${formattedBalance} USDC` : "••••• USDC"}
265+
{formattedBalance && !hideBalance
266+
? `$${formattedBalance} ${tokenName}`
267+
: `••••• ${tokenName}`}
265268
</button>
266269
</span>
267270
</div>
268271
<div className="payment-row">
269272
<span className="payment-label">Amount:</span>
270-
<span className="payment-value">${amount} USDC</span>
273+
<span className="payment-value">
274+
${amount} {tokenName}
275+
</span>
271276
</div>
272277
<div className="payment-row">
273278
<span className="payment-label">Network:</span>

typescript/packages/http/paywall/src/evm/gen/template.ts

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)