跳到主要內容

Stake-for-Bid and Stake-for-Offer: Bringing NFT Auctions and Conditional Offers Into the Protocol

Robert Mao
BlockchainStake-for-XNFTProtocol PrimitivesState Machine

Trading NFTs or digital license assets on a conventional blockchain often involves two uncomfortable compromises.

First, listing an NFT may require signing setApprovalForAll(marketplaceContract, true), giving an external contract permission to transfer every NFT you own in that collection. Alternatively, the NFT itself moves into an auction escrow contract. A marketplace vulnerability or compromised frontend can then put those assets at risk.

Second, entering an English auction usually means transferring funds into the auction contract. When someone outbids you, your funds may remain there until you pay Gas to call withdraw(). Refund handling also introduces contract complexity, including potential reentrancy and denial-of-service failures.

This second article in the Stake-for-X series explores a different design in @ocap/ledger-core. ArcBlock combines asset-native listings through IAssetState.marketListing, Stake-for-Bid with O(1) automatic refunds, and Stake-for-Offer with on-chain attribute predicates in a shared trading layer that does not require external escrow contracts.

1. A Listing Is Part of the Asset's Own State

Why do separate NFT marketplaces need their own order infrastructure, off-chain signed orders such as those used by Seaport, and broad on-chain approvals?

The underlying ledger generally has no native concept of a listing. It understands asset transfers, so marketplace rules must be implemented in contracts above it.

In @ocap/ledger-core, IAssetState.marketListing is an embedded property of each on-chain asset, or Universal NFT:

  1. The seller retains ownership until settlement. Whether listed at a fixed price or put up for auction, the NFT remains under its owner's DID account. Listing requires neither a transfer to third-party escrow nor a setApprovalForAll approval.
  2. ArcSpace applications and other frontends share the same listings. A creator's ArcSpace, a specialized application, or an AI agent can read IAssetState.marketListing directly from on-chain state and initiate atomic settlement. It does not need to synchronize a marketplace's private order database.
  3. Tiered promotion commissions are built in through EscalatingPromoterTier[]. The primitive can calculate promoterBps from a transaction amount or cumulative sales volume. The protocol enforces promoterDid !== buyerDid && promoterDid !== sellerDid to prevent the buyer or seller from claiming the promoter role in the same trade. Different frontends can thus participate in a shared trading pool with protocol-enforced commission settlement.

Fragmented external escrow marketplaces compared with shared native listings in IAssetState.marketListing

2. Timestamp-Driven Sales and O(1) Refunds Through Stake-for-Bid

As discussed in Retiring blockHeight and the Protobuf Burden, ArcBlock's blockless streaming confirmation model, 100% Instant Settle, removes dependence on blockHeight. That choice also simplifies auction state machines.

IAssetState.marketListing supports three sale modes driven by the deterministic timestamp txTimestampSeconds.

Fixed-Price Atomic Settlement: FIXED_PRICE

The buyer submits a settlement instruction that meets the listing price. One atomic state transition transfers official tokens, allocates creator royalties and promotion commissions, and transfers NFT ownership, with millisecond-scale finality.

Linear Dutch Auctions: DUTCH_AUCTION

A conventional Dutch auction often advances in steps imposed by block intervals. Here, the effective price is a linear function of the deterministic transaction timestamp, t = txTimestampSeconds, over [startTimeSeconds, endTimeSeconds], with integer rounding:

Price(t) = startPrice - floor( (startPrice - endPrice) * (t - startTime) / (endTime - startTime) )

No external oracle or scheduled script needs to update the price in on-chain state. When a buyer submits a purchase, the state machine calculates the price for that second and settles the transaction.

ENGLISH_TOP1_AUTO_REFUND: One Bid Slot, Constant-Time Refunds

For English auctions, the key is how Stake-for-Bid locks bid funds.

Rather than maintaining a growing list of bidders awaiting refunds, @ocap/ledger-core keeps one active highest-bid slot in statedb.stake for each auction, derived through deriveExchangeStakeAddress('NFT_AUCTION_BID', listingId).

  • The previous bid is refunded in O(1) time within the same transaction. When Bob submits a valid bid above Alice's current highest bid, one atomic state transition locks Bob's funds in the auction's Stake-for-Bid slot and invokes return_stake to return all of Alice's previous bid directly to her account balance.
  • Outbid bidders have no refund backlog or manual withdrawal. Alice receives her funds as part of the transaction that outbids her. The state tree retains a single O(1) stake slot rather than an expanding refund queue, removing the need for batch refund processing.
  • A 300-second anti-sniping window is built in: antiSnipeWindowSeconds = 300s. If a new highest bid arrives less than 300 seconds before endTimeSeconds, the state machine extends the deadline by 300 seconds, allowing human bidders and AI agents time to respond.

Timestamp-driven linear Dutch auctions and Stake-for-Bid English auctions with one-slot O(1) automatic refunds

3. Stake-for-Offer: Buy Offers With Structured On-Chain Predicates

A useful digital marketplace needs more than seller listings. It also needs unsolicited buyer offers: a buyer can commit funds for an asset even when its owner has not listed it, and an eligible holder can accept.

In @ocap/ledger-core, the buyer calls createNftBuyOffer to lock funds in a Stake-for-Offer slot in statedb.stake. Before acceptance, cancelNftBuyOffer lets the buyer cancel and recover the entire amount.

The protocol supports three progressively broader targeting modes:

Offer TargetOn-Chain Matching RuleTypical Commerce or Agent Scenario
1. A specific asset
(targetAssetDid)
Exact match against the NFT's unique DIDA particular artwork, numbered software license, or domain-name NFT
2. A factory or collection
(targetFactoryDid)
Any qualifying asset minted by the specified NFTFactoryA collection-wide offer to acquire any eligible pass within a set budget
3. Structured attributes and usable state
(attributePredicates + requireUnconsumed)
Deterministic evaluation against IAssetState.data, using eq, neq, in, gte, lte, and existsAny collectible matching color == 'yellow' && species == 'dragon', or an unconsumed compute card with requireUnconsumed: true and remainingBalance >= 100

The third mode, on-chain attribute and usable-state predicate offers, addresses a particularly important settlement problem.

On many conventional chains, NFT traits live in JSON stored on IPFS or a centralized server. An on-chain contract cannot directly determine whether an item is common or legendary, or whether a prepaid card still has its advertised balance. A seller might drain a card immediately before accepting an offer, leaving the buyer with an empty NFT shell: a front-running state-drain attack.

In @ocap/ledger-core, structured asset attributes and consumption state reside in IAssetState.data. When a seller calls acceptNftBuyOffer, the protocol atomically evaluates attributePredicates and requireUnconsumed at settlement time. Locked Stake-for-Offer funds are released to the seller, and the asset transfers to the buyer, only if its actual on-chain state satisfies the buyer's conditions at that moment. An exhausted card or mismatched asset fails the state-machine check.

Targeted NFT buy offers and atomic settlement using Stake-for-Offer and on-chain attributePredicates

Keep Listings in the Protocol and Asset Control With the Owner

With IAssetState.marketListing, Stake-for-Bid, and Stake-for-Offer in the ledger protocol, marketplace operations become a small set of deterministic state transitions. External escrow contracts, proxy layers, and separate signed-order infrastructure no longer need to implement those operations, and the transitions avoid external-contract reentrancy.

Sellers retain control until settlement. Outbid bidders receive automatic refunds. Buyers can require usable asset state at the exact moment of exchange.

The next article, the third in the Stake-for-X series, examines Stake-for-Card, Stake-for-Credit, and Stake-for-Distributor: how fungible balances, credit lines, and a cross-brand distribution network with refundable admission stakes fit inside an NFT policy shell.