Playbook

BareNFTReserve: Escrow, RandomBuy, and Weak RNG (Barenft Reserve Escrow And Randombuy Entropy)

Owner-only createNewListing, buy, and randomBuy using keccak256(revealNonce, block.difficulty, msg.sender) % 3 — weak RNG, owner-operated marketplace ADR…

Bare Crypto Solidity Marketplace Protocol

Part 3 of 5

BareNFT, reserve escrow, English auction, and NFT-gated BareToken emissions built in Remix IDE with OpenZeppelin v4.1 GitHub imports — no Hardhat/Foundry — covering ADRs, weak RNG, and emergency-power trade-offs.

Bare Crypto Solidity marketplace protocol diagram

Escrow trust, lottery distrust

BareNFTReserve escrows the NFT into the contract and opens prices via owner-only createNewListing; buy settles a fixed listing. randomBuy builds a 'random' triplet of candidate indexes from keccak256(revealNonce, block.difficulty, msg.sender) % 3 — deliberately weak on-chain entropy. That is the heart of Bare Crypto's owner-operated marketplace ADR: trust sits with the operator; chance is a UX sugar the operator tolerates.

Owner ──transfer NFT──> BareNFTReserve (escrow)
  createNewListing(tokenId, price)
        |
        +── buy(tokenId) ──ETH──> seller, NFT──> buyer
        |
        +── randomBuy() ── keccak(nonce, difficulty, sender) % 3
        |
        +── emergency: transferNft / transferFunds

This part locks the reserve escrow model, the weak RNG, and the emergency-power trade-off.

Concepts, defined where they first appear

📦 Escrow listing
NFT is transferred to the contract first; listing opens only when ownerOf is the contract.

📦 Owner-operated marketplace
Listing creation and emergency exits bind to one owner — not permissionless sellers.

📦 Weak on-chain RNG
Pseudo-randomness from difficulty + nonce + sender, influenceable by miners/callers.

📦 Emergency exit
Owner bypass of escrow via transferNft / transferFunds.

Owner-operated escrow is a different product ADR from an OpenSea-like permissionless market; randomBuy adds a chance layer without changing trust.

ADR: owner-operated reserve

Decision: only the owner may createNewListing; the NFT must already sit in the contract. Rationale: Bare Crypto manages vitrine inventory as a single operator and avoids fake listings from a permissionless seller model. Cost: central operator — open/close, set price, closeListing are all owner-gated. This is an 'operator storefront escrow' ADR, not a protocol marketplace.

buy, randomBuy, and the entropy diagram

buy loads the last tokenIdToListing entry, requires msg.value >= price, then seller.transfer and safeTransferFrom. randomBuy comments out the price require; randomId returns three indexes via % 3 and tries until the first successful sale. The entropy source is predictable or miner-influenced — not fair randomness, but a vitrine 'mystery box' UX.

revealNonce ++
keccak256(nonce, block.difficulty, msg.sender)
        |
        v
   index = hash % 3
   [i, i+1, i+2] mod 3
        |
        v
 try listings until sold

Failure: weak RNG, reentrancy, emergency

Immediate seller.transfer(msg.value) in buy/randomBuy is a weak checks-effects-interactions surface; a malicious seller contract can attempt reentrancy. RNG weakness: within the same block a caller can simulate which % 3 bucket they land in. Emergency transferNft/transferFunds exist for incident recovery but drain all escrow if the owner key is compromised. Performance: as tokenIdToListing grows, getLastListingByTokenId costs and history complexity rise.

The mappings that get confused most often

❌ block.difficulty random makes fair NFT distribution
✓ This is weak RNG; it can be mystery UX, never a fair mint/raffle

❌ If the NFT is in escrow, the market is permissionless
✓ If listing creation is owner-only, the product is an operator storefront

❌ Emergency transfer only improves safety
✓ The same door is a rug vector on compromise; without timelock/multisig it is single-point risk

A checklist for auditing your own system

  1. Who can call createNewListing — owner only or any seller?
  2. Is the randomBuy price check active in code or commented out?
  3. Which wallet holds transferNft/transferFunds, and is it multisig?
  4. Can a caller predict randomBuy within the same block?
  5. Which tokenIdToListing entry does the UI treat as current?

What to take away from this part

  1. BareNFTReserve is an owner-operated escrow storefront ADR, not a permissionless marketplace.
  2. randomBuy entropy is deliberately weak — UX sugar, not fair chance.
  3. Emergency powers open recovery and rug with the same key.

If escrow trust lives with the operator, rolling dice is decoration, not protocol.

FAQ

Frequently asked questions

What is Escrow listing?

NFT is transferred to the contract first; listing opens only when ownerOf is the contract.

What is Owner-operated marketplace?

Listing creation and emergency exits bind to one owner — not permissionless sellers.

Is it true that "block.difficulty random makes fair NFT distribution"?

This is weak RNG; it can be mystery UX, never a fair mint/raffle

What does this part lock in?

This part locks the reserve escrow model, the weak RNG, and the emergency-power trade-off. BareNFTReserve escrows the NFT into the contract and opens prices via owner-only createNewListing; buy settles a fixed listing. randomBuy builds a 'random' triplet of candidate indexes from keccak256(revealNonce, block.difficulty, msg.sender) % 3 — deliberately weak on-chain entropy. That is the heart of Bare Crypto's owner-operated marketplace ADR: trust sits with the operator; chance is a UX sugar the operator tolerates.

Engineering Principles Learned

  • A marketplace ADR must clearly separate permissionless sellers from an operator storefront.
  • If on-chain RNG is used, document 'weak / not fair' explicitly.
  • Emergency exits must not sit alone without multisig or timelock.

Continue reading

Continue reading

Next in series

Next in series

Same series

Paylaş