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
3 changes: 2 additions & 1 deletion examples/unity-game-x402-gate/.env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Stellar public key (G...) that receives payment. Public — never a secret.
X402_SELLER_ADDRESS=

# Free testnet facilitator key: POST https://channels.openzeppelin.com/testnet/gen
# Free testnet facilitator key: GET https://channels.openzeppelin.com/testnet/gen
# (open it in a browser, or `curl`; a POST here returns 401)
FACILITATOR_API_KEY=

X402_FACILITATOR_URL=https://channels.openzeppelin.com/x402/testnet
Expand Down
10 changes: 9 additions & 1 deletion examples/unity-game-x402-gate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ Fill in `.env`:
- `X402_SELLER_ADDRESS` — a Stellar **public** key (G...) to receive
payment. Public only; no secret involved.
- `FACILITATOR_API_KEY` — free testnet key from
`POST https://channels.openzeppelin.com/testnet/gen`.
`GET https://channels.openzeppelin.com/testnet/gen` (open it in a browser,
or `curl`; a `POST` here returns `401 Unauthorized`).
- `PLAYER_SECRET_KEY` — only needed for `wallet-bridge-smoke`, a throwaway
testnet secret key that will actually pay. **Never use a mainnet key
here.**
Expand All @@ -129,6 +130,13 @@ a payment:
Stellar) — this step is reCAPTCHA-gated and has to be done by a human in
a browser; there's no API around it.

`X402_SELLER_ADDRESS` needs to be a real account too, not just a valid-looking
key: if you generate a fresh keypair for it (rather than pointing at an
already-funded account), it has to be created on-chain (friendbot) and given
the same USDC trustline above before it can receive the SAC transfer —
otherwise `wallet-bridge-smoke` fails simulation with `HostError: Error(Contract, #13)`
("trustline entry is missing for account").

### 2. Run the mocked test suite

```bash
Expand Down
7 changes: 5 additions & 2 deletions examples/unity-game-x402-gate/scripts/wallet-bridge-smoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,11 @@ async function main(): Promise<void> {
console.log(`[smoke] payment accepted. Unlocked loot:`);
console.log(JSON.stringify(payload.loot, null, 2));

const txHashHeader =
response.headers.get("x-payment-response") ?? response.headers.get("settlement-response");
// x402 v2's settlement header is `PAYMENT-RESPONSE`, not the v1 name
// `X-PAYMENT-RESPONSE` (and never `settlement-response`, which isn't a
// real header in either version). See "Settlement Response Delivery" in
// x402-foundation/x402's specs/transports-v2/http.md.
const txHashHeader = response.headers.get("payment-response");
if (txHashHeader) {
console.log(`[smoke] settlement response header: ${txHashHeader}`);
const decoded = tryDecodeBase64Json(txHashHeader);
Expand Down