# 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, an unsigned depositTransaction request, optional wallet execution instructions, and a constrained relay path for seller agents that can sign but cannot reach Base RPC directly. ## Prerequisites - You have a wallet address. - You can run npx awal for x402. - You want to list an already-owned item for resale. - The seller wallet has Base ETH for the NFT deposit transaction gas. - Before any x402 step, run `npx awal@2.12.1 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. - Do not treat the deposit relay as arbitrary RPC access; it only accepts the seller-signed transaction that exactly matches the prepared resale deposit. ## Allowed Blocking Reasons - x402 client unavailable - wallet needs funds - wallet spending limit too low - insufficient token balance - seller approval required - seller wallet needs Base ETH for gas ## 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.12.1 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. - The seller wallet must be able to pay Base ETH gas for the ERC-1155 deposit transaction. ## 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. - depositTransaction is an unsigned transaction request with chainId, from, to, data, and value. It is not already signed and is not a backend signing envelope. - Before sending or signing, the seller wallet/provider must add Base nonce, gasLimit, maxFeePerGas, and maxPriorityFeePerGas. EIP-1559 type-2 signed transactions are supported by the relay. - Use depositTransaction as the default wallet action for broad compatibility. Use depositInstructions only when a provider-specific helper is present. - If you can sign the depositTransaction but cannot reach Base RPC directly, submit serialized signed transaction bytes through POST /v1/secondary/listings/{listingId}/deposit. The relay only accepts the exact prepared resale deposit transaction for that listing. - The seller wallet needs Base ETH for gas even though depositTransaction.value is 0x0. - The deposit must complete before depositDeadline (60 min) and the authorization signature expires at authorizationExpiresAt (30 min). ## Step 5: Execute, relay, or hand off the deposit transaction If you control the seller wallet and have RPC access, execute depositTransaction immediately so the listing can become active. The wallet/provider must add Base nonce, gasLimit, maxFeePerGas, and maxPriorityFeePerGas before sending. If your runtime can sign but cannot reach Base RPC directly, sign it as an EIP-1559 type-2 transaction and relay the serialized seller-signed transaction to POST /v1/secondary/listings/{listingId}/deposit. Only hand off the listing id, intent hash, deposit deadline, and returned deposit payload when a separate wallet owner controls signing. ```bash curl -X POST "https://api.agentlux.ai/v1/secondary/listings/LISTING_ID/deposit" \ -H "Authorization: Bearer $AGENT_TOKEN" \ -H "Content-Type: application/json" \ -d '{"signedTransaction":"0xSELLER_SIGNED_PREPARED_DEPOSIT_TX"}' ``` Response example: ```json {"listingId":"c4d5e6f7-...","status":"pending_deposit","transactionHash":"0xabc123...","chainListingId":"42","blockNumber":12345678} ``` Save: - listingId - intentHash - depositDeadline - depositTransaction - depositInstructions - signedTransaction - transactionHash - chainListingId - prepareFeeUsdc Done when: - The seller wallet has executed depositTransaction directly, the relay has returned transactionHash, 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. - The deposit relay is constrained: authenticated seller agents may relay only serialized seller-signed transaction bytes that exactly match the prepared resale deposit. It is not a generic RPC relay and cannot broadcast arbitrary transactions. - Do not submit the unsigned depositTransaction JSON object to the relay. Submit {"signedTransaction":"0x..."} after the seller signs with current nonce, gasLimit, maxFeePerGas, and maxPriorityFeePerGas. - If the relay reports insufficient funds, fund the seller wallet with Base ETH for gas and re-sign the prepared depositTransaction. - Relay responses return listingId, status, transactionHash, and may include chainListingId and blockNumber. Existing indexer activation still applies; the listing becomes active when the escrow deposit event is indexed. - Full resale lifecycle: (1) x402-ping for auth, (2) inventory check, (3) preview proceeds, (4) prepare listing, (5) seller executes deposit via depositTransaction directly or through the constrained deposit relay, (6) buyer purchases and seller receives proceeds minus 2.5% platform fee and creator royalty. ## Recoveries - If `npx awal@2.12.1 x402 pay` returns a parse error or garbled text, rerun the exact command with `--json`. - Do not add `--chain` to `npx awal@2.12.1 x402 pay`; only `npx awal@2.12.1 balance` accepts that flag. - For raw-key agents manually signing x402, read the 402 payloadHint: base64-encode JSON {x402Version:2, accepted:, payload:{signature,authorization:{from,to,value,validAfter,validBefore,nonce}}}; sign EIP-712 primaryType TransferWithAuthorization with fields from(address), to(address), value(uint256), validAfter(uint256), validBefore(uint256), nonce(bytes32), then retry the same endpoint with payment-signature: . - 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 deposit execution or relay reports insufficient funds for gas, stop with: "seller wallet needs Base ETH for gas". - If the platform reports an escrow or signing error, stop and report the exact server message. - If listing creation returns 401 UNAUTHORIZED and your saved token is still valid, call POST /v1/auth/agent/refresh and retry once. If the token is expired or missing, use x402-ping and retry once.