关于取消Metaplex Auctioneer创建的英式拍卖的技术问题咨询
Great question—let's break this down step by step since auctioneer-managed English auctions have subtle differences from standard Auction House listings.
1. Can You Cancel an English Auction Created via Auctioneer.createSellInstruction?
Yes, you can cancel these listings, but you need to fix two key issues from your failed attempt:
Fixing the AccountOwnedByWrongProgram Error
The error you saw (TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA vs 11111111111111111111111111111111) means you passed an invalid tokenAccount parameter. For cancel instructions, this account must be the seller's actual token account (owned by the official Token program), not a system account or other unrelated address.
Correct Cancel Instruction Parameters
Since English auctions don't use a fixed buyerPrice, you were right to use the u64 maximum value (18446744073709551615n)—this matches the buyerPrice used to create the initial sellerTradeState for the auction. Here's a corrected example of the cancel instruction:
// Reuse accounts from your original createSell call, with critical checks const cancelAccounts = { auctionHouseProgram, wallet: sellerWallet, // Must be the original seller's wallet tokenAccount: sellerTokenAccount, // Verify this is owned by TokenkegQfe... metadata, authority: auctionHouseAuthority, auctionHouse, auctionHouseFeeAccount, sellerTradeState: existingTradeState, // Exact trade state from the initial listing freeSellerTradeState: existingFreeTradeState, auctioneerAuthority, ahAuctioneerPda, programAsSigner, }; const cancelArgs = { buyerPrice: 18446744073709551615n, // Match the value used to create the trade state tokenSize: tokenSizeUsedInCreate, // Must match the token amount from your initial listing }; const cancelIx = Auctioneer.createCancelInstruction(cancelAccounts, cancelArgs);
2. Creating a ListingReceipt for English Auctions
You absolutely can generate a ListingReceipt to track creation/cancel dates and other metadata. To do this:
- Generate the
listingReceiptPDA using seeds:["listing_receipt", auctionHouse.address, sellerTradeState.address] - Include this account as an optional parameter in your original
Auctioneer.createSellInstructioncall.
Example snippet for including the receipt on creation:
import { findListingReceiptPda } from "@metaplex-foundation/mpl-auction-house"; // Generate the receipt PDA const listingReceipt = findListingReceiptPda(auctionHouse.address, sellerTradeState.address); // Add it to your createSell accounts const createSellAccounts = { // ... all your original accounts listingReceipt, }; const createSellIx = Auctioneer.createSellInstruction(createSellAccounts, args);
When you cancel the auction, you can either update this receipt's state to mark it as canceled or create a separate CancelReceipt PDA for audit trails.
3. Fixing "Address Already in Use" Errors When Re-Listing
This error happens because the old sellerTradeState or ListingReceipt accounts from the expired auction are still active and occupying their addresses. To resolve this:
- First confirm the auction has ended (check the
endTimeparameter from your initial listing). - Run the cancel instruction outlined above to close the existing
sellerTradeStateaccount and free up the address. - Once the cancel transaction confirms, you'll be able to create a new English auction for the same token without conflicts.
内容的提问来源于stack exchange,提问作者c4b4d4

