Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

feat: add settleable mint validation in validateRingTransaction

nirholas4eac7af3aa44
diff --git a/api/_lib/x402/self-facilitator.js b/api/_lib/x402/self-facilitator.js
index eb3f9e230..d1ba4d8f7 100644
--- a/api/_lib/x402/self-facilitator.js
+++ b/api/_lib/x402/self-facilitator.js
@@ -179,6 +179,17 @@ export function validateRingTransaction({ txBase64, requirement, feePayerPubkey,
return { ok: false, reason: `pay_to_not_allowlisted:${payTo.toBase58()}` };
}
+ // The mint must be one the platform actually issues 402s for (USDC, plus
+ // $THREE when configured). The requirement is caller-supplied: without
+ // this pin a junk mint passes every check below — including the
+ // sponsor-funded ATA create — so each call would burn sponsor ATA rent +
+ // fees settling a worthless transfer, repeatable per fresh mint. Fail
+ // closed when no settleable mint is configured at all.
+ const settleableMints = [env.X402_ASSET_MINT_SOLANA, env.THREE_TOKEN_MINT].filter(Boolean);
+ if (!settleableMints.includes(mint.toBase58())) {
+ return { ok: false, reason: `mint_not_settleable:${mint.toBase58()}` };
+ }
+
const expectedReceiverAta = getAssociatedTokenAddressSync(
mint, payTo, false, TOKEN_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID,
);
diff --git a/tests/x402-self-facilitator-settleable.test.js b/tests/x402-self-facilitator-settleable.test.js
index 571e47f91..61f37610f 100644
--- a/tests/x402-self-facilitator-settleable.test.js
+++ b/tests/x402-self-facilitator-settleable.test.js
@@ -22,7 +22,7 @@ import {
createTransferCheckedInstruction,
} from '@solana/spl-token';
-const { verifyRingPayment } = await import('../api/_lib/x402/self-facilitator.js');
+const { verifyRingPayment, validateRingTransaction } = await import('../api/_lib/x402/self-facilitator.js');
const DECIMALS = 6;
const AMOUNT_ATOMIC = 1000n; // 0.001 USDC
@@ -42,6 +42,10 @@ function buildSelfPayPayment({ amount = AMOUNT_ATOMIC } = {}) {
const transferIx = createTransferCheckedInstruction(
sourceAta, mint, destAta, buyer.publicKey, amount, DECIMALS,
);
+ // The facilitator only settles mints the platform issues 402s for (pinned
+ // to the configured env mints after the 2026-07-23 audit); model this
+ // synthetic mint as the configured one.
+ process.env.X402_ASSET_MINT_SOLANA = mint.toBase58();
const message = new TransactionMessage({
payerKey: buyer.publicKey,
recentBlockhash: '11111111111111111111111111111111',
@@ -63,12 +67,16 @@ function buildSelfPayPayment({ amount = AMOUNT_ATOMIC } = {}) {
}
let prevPayTo;
+let prevAssetMint;
beforeEach(() => {
prevPayTo = process.env.X402_PAY_TO_SOLANA;
+ prevAssetMint = process.env.X402_ASSET_MINT_SOLANA;
});
afterEach(() => {
if (prevPayTo === undefined) delete process.env.X402_PAY_TO_SOLANA;
else process.env.X402_PAY_TO_SOLANA = prevPayTo;
+ if (prevAssetMint === undefined) delete process.env.X402_ASSET_MINT_SOLANA;
+ else process.env.X402_ASSET_MINT_SOLANA = prevAssetMint;
});
describe('verifyRingPayment settleability gate', () => {