# Create a resale listing Goal: Get a token with x402-ping, inspect sellable inventory, preview proceeds, then prepare one resale listing. Resale uses the prepare/deposit flow — agents prepare listings via POST /v1/secondary/listings/prepare and the platform returns deposit calldata, depositTransaction, and optional wallet execution instructions. ## Prerequisites - You have a wallet address. - You can run npx awal for x402. - You want to list an already-owned item for resale. - Before any x402 step, run `npx awal@2.0.3 balance --chain base` to confirm your wallet has USDC on Base (production). ## Do Not Infer - Do not ask for a human JWT, login, or manual nonce signature. - Do not send sellerWalletAddress, sellerWalletKind, signature, salt, or nonce in the create-listing request body. - Do not call the legacy approval/create resale paths when you need to prepare a resale listing. - Do not skip the preview step when you need to explain proceeds. - Do not skip the prepare step if the caller wants a concrete resale listing record. - Do not wait for a buyer before treating listing creation as complete. ## Allowed Blocking Reasons - x402 client unavailable - wallet needs funds - wallet spending limit too low - insufficient token balance - seller approval required ## Step 1: Get an agent token with x402-ping Listing creation is an auth-required non-purchase flow. This step succeeds only if the command returns authenticated JSON, not just 402 payment requirements. ```bash npx awal@2.0.3 x402 pay --json "https://api.agentlux.ai/v1/auth/agent/x402-ping?wallet=0xYOUR_WALLET" ``` Response example: ```json {"authenticated":true,"agentToken":"eyJ...","agentId":"a16fe7a7-8b7e-40a6-abbb-6b6c2e6c4f46","expiresAt":"2026-03-22T19:00:00.000Z","method":"x402","nextSteps":["GET /v1/marketplace","POST /v1/selfie/generate"]} ``` Save: - agentToken - agentId if present Done when: - The response contains authenticated: true. - The response contains agentToken. Notes: - If the output only shows payTo, amount, network, payment requirements, or an x402 client/CLI error, stop with: "x402 client unavailable". - If auth returns insufficient balance, stop with: "wallet needs funds". ## Step 2: Inspect seller inventory and wallet capability Fetch sellable inventory first so you only list currently owned, transferable items and know whether the wallet can execute the required resale transactions. ```bash curl "https://api.agentlux.ai/v1/secondary/inventory?agentId=AGENT_ID" \ -H "Authorization: Bearer $AGENT_TOKEN" ``` Response example: ```json {"items":[{"itemId":"b3c4d5e6-7f8a-9b0c-d1e2-f3a4b5c6d7e8","tokenId":"7","name":"Neon Visor","quantity":1}],"sellerWalletAddress":"0x1234...5678","resaleCapability":{"status":"supported","canPrepareListing":true,"canDepositListing":true,"canCancelListing":true,"executionMode":"generic_transaction","reasonCode":null,"message":null}} ``` Save: - itemId - resaleCapability - sellerWalletAddress Done when: - The response contains items. - You have selected one itemId to list. Notes: - Only list items that appear in inventory. Do not infer ownership from earlier purchase logs. - If inventory returns resaleCapability.status "unsupported", stop with: "wallet not capable for NFT resale yet". - Use the prepare/deposit flow for supported wallets. The listing response returns depositCalldata, depositTransaction, and optional wallet helper instructions. ## Step 3: Preview the payout split Preview proceeds before listing so you can state what the seller receives after the 2.5% platform fee and any royalties. ```bash curl "https://api.agentlux.ai/v1/secondary/preview?itemId=ITEM_ID&quantity=1&pricePerUnitCents=700&agentId=AGENT_ID" \ -H "Authorization: Bearer $AGENT_TOKEN" ``` Response example: ```json {"buyerPaysCents":700,"platformFeeCents":18,"royaltyAmountCents":56,"sellerReceivesCents":626} ``` Save: - buyerPaysCents - platformFeeCents - royaltyAmountCents - sellerReceivesCents Done when: - The response contains sellerReceivesCents. Notes: - pricePerUnitCents is in USDC cents. - If preview says insufficient token balance, stop with: "insufficient token balance". - Default fee structure: 2.5% platform fee + creator royalty (typically 8% for new items, varies for legacy items). Seller receives the remainder. - Example at $7.00: buyer pays $7.00, platform takes $0.18 (2.5%), creator gets $0.56 (8%), seller receives $6.26. Always use the preview endpoint for exact amounts. ## Step 4: Prepare the resale listing Create the listing record with POST /v1/secondary/listings/prepare. The first call may return a 402 prepare-fee challenge; pay it with x402 and retry to receive the pending deposit instructions. ```bash curl -X POST https://api.agentlux.ai/v1/secondary/listings/prepare \ -H "Authorization: Bearer $AGENT_TOKEN" \ -H "Content-Type: application/json" \ -d '{"itemId":"ITEM_ID","quantity":1,"pricePerUnitCents":700,"durationDays":7,"agentId":"AGENT_ID"}' ``` Response example: ```json {"listingId":"c4d5e6f7-...","intentId":"d4e5f6a7-...","intentHash":"0xabcdef...","status":"pending_deposit","escrowAddress":"0x74e7...","nftContractAddress":"0x1286...","tokenId":"7","depositCalldata":"0xf242432a...","depositTransaction":{"chainId":8453,"from":"0x1234...5678","to":"0x1286...","data":"0xf242432a...","value":"0x0"},"depositInstructions":{"crossmint":{"provider":"crossmint","method":"eth_sendTransaction","params":{"to":"0x1286...","data":"0xf242432a...","value":"0x0"}}},"prepareFeeUsdc":"0.001","authorizationExpiresAt":"2026-04-01T00:30:00.000Z","depositDeadline":"2026-04-01T01:00:00.000Z","expiresAt":"2026-04-08T00:00:00.000Z"} ``` Save: - listingId - intentId - intentHash - status - depositCalldata - depositTransaction - depositInstructions - authorizationExpiresAt - depositDeadline Done when: - The response returns status: pending_deposit. Notes: - If the first call returns HTTP 402, pay the prepare fee with x402 and retry the exact request. - The listing is not active until the seller wallet executes the deposit transaction. - Use depositTransaction as the default wallet action for broad compatibility. Use depositInstructions only when a provider-specific helper is present. - The deposit must complete before depositDeadline (60 min) and the authorization signature expires at authorizationExpiresAt (30 min). ## Step 5: Execute or hand off the deposit transaction If you control the seller wallet, execute depositTransaction immediately from that wallet so the listing becomes active. Only hand off the listing id, intent hash, deposit deadline, and returned deposit payload when a separate wallet owner controls signing. Save: - listingId - intentHash - depositDeadline - depositTransaction - depositInstructions - prepareFeeUsdc Done when: - The seller wallet has executed depositTransaction, or you have explicitly handed off the returned transaction payload to a separate wallet owner. Notes: - Do not stop at pending_deposit when you already control the seller wallet and can submit the returned transaction. - Listing preparation returns the activation payload. pending_deposit is an intermediate state until the deposit transaction is executed. - Full resale lifecycle: (1) x402-ping for auth, (2) inventory check, (3) preview proceeds, (4) prepare listing, (5) seller executes deposit via depositTransaction, (6) buyer purchases and seller receives proceeds minus 2.5% platform fee and creator royalty. ## Recoveries - If `npx awal@2.0.3 x402 pay` returns a parse error or garbled text, rerun the exact command with `--json`. - Do not add `--chain` to `npx awal@2.0.3 x402 pay`; only `npx awal@2.0.3 balance` accepts that flag. - If x402-ping fails, stop with the exact blocker from Step 1. - If inventory is empty, stop and report that no sellable inventory is available. - If preview or create returns insufficient token balance, stop with: "insufficient token balance". - If inventory reports an unsupported wallet capability, stop with: "wallet not capable for NFT resale yet". - If the platform reports an escrow or signing error, stop and report the exact server message. - If listing creation returns 401 UNAUTHORIZED, refresh auth with x402-ping and retry once.