D
DEPLOYR
← Build Ideas
FhenixPrivacyadvancedabout 2 weeks

Sealed-bid auction with FHE

Everyone bids encrypted, the chain picks the winner without ever seeing a bid.

Stack: Fhenix CoFHE · Solidity · Base Sepolia

A sealed-bid auction with fully homomorphic encryption (FHE) is an onchain auction where every bid is encrypted before it touches the chain, the contract compares bids without ever decrypting them, and only the winner and clearing price are revealed at the end. You build it on Fhenix CoFHE, the FHE coprocessor that runs live on Ethereum Sepolia, Arbitrum Sepolia, and Base Sepolia today, with mainnet on the roadmap. This is an advanced project, and it is one of the sharpest ways to prove you can write confidential smart contracts that most Solidity developers cannot.

What you are building and who it is for

The product is a first-price or second-price (Vickrey) sealed-bid auction contract. Bidders submit encrypted bids as euint values. The contract runs homomorphic comparisons to track the highest bid and the leading bidder, all on ciphertext. When the auction closes, the contract requests decryption of the winning bid only, and settles onchain. No competitor ever sees a losing bid, and no one, including the auctioneer, can front-run based on bid amounts.

This is for developers targeting confidential DeFi, NFT drops, RWA auctions, MEV-resistant markets, and any use case where visible mempool bids leak strategy. It is also for anyone building toward the FHE and privacy ecosystem forming around Fhenix, Zama, and Inco. If you want to be the developer these teams notice, an end-to-end confidential auction is a strong, legible proof of skill.

Why this positions you as a developer on Fhenix

Most Solidity developers have never touched encrypted types. Writing a working FHE auction forces you to understand the three hard parts of confidential contracts: encrypted arithmetic and comparison, access control on ciphertext, and the asynchronous decryption flow. Fhenix published its FHE Rollup whitepaper in March 2026 and secured a strategic investment from BIPROGY and the Translink Sustainability and Innovation Fund in October 2025, so the ecosystem is funded and growing. Shipping a real confidential dApp now, while the tooling is fresh, is exactly the kind of onchain work that gets you cited, invited, and remembered. See our take on positioning at /insights.

The build path and stack

Start with the official CoFHE Hardhat starter, which ships a Counter.sol example using euint32 and FHE.add. There is also a Foundry mocks package if you prefer Foundry. The core stack is:

  • Contracts: Solidity with import "@fhenixprotocol/cofhe-contracts/FHE.sol"; and encrypted types like euint32, euint128, and ebool.
  • Client SDK: cofhejs for encrypting bids in the browser, and unsealing revealed values.
  • Local testing: the CoFHE mock contracts, a 1:1 drop-in replacement so FHE.decrypt and FHE.sealoutput resolve synchronously in tests.
  • Networks: deploy to Ethereum Sepolia, Arbitrum Sepolia, or Base Sepolia.

Contract logic, step by step

  1. Bid submission. Accept an encrypted bid InEuint128 from the client, convert it with FHE.asEuint128, and store it per bidder. Call FHE.allowThis so the contract can operate on the ciphertext, and FHE.allowSender so the bidder retains access.
  2. Running winner. On each bid, compute an ebool with FHE.gt(newBid, highestBid), then use FHE.select to update the encrypted highestBid and the encrypted winningBidder without branching on plaintext. Never if on a decrypted value mid-auction, that defeats the privacy.
  3. Close and reveal. After the deadline, call FHE.decrypt on the winning bid. Decryption happens off-chain in CoFHE and the plaintext is posted back on-chain in the TaskManager's PlaintextStorage, so this is asynchronous. Poll or use a callback pattern, then settle.
  4. Settlement. Transfer the asset to the winner and, for a Vickrey auction, charge the second-highest encrypted bid, which you track with the same FHE.select pattern.

Frontend

Use cofhejs to encrypt the bid amount client-side before it is ever broadcast. For the reveal, the contract calls FHE.allow to grant the caller permission, then the frontend calls cofhejs.unseal to read the cleartext result. The cofhe-miniapp-template gives you a Base miniapp starting point.

Common pitfalls

  • Assuming encrypted means access-controlled. Privacy is not private by default. If you forget FHE.allowThis or FHE.allow, operations revert or values are unreadable. Access control is explicit on every ciphertext.
  • Branching on ciphertext. You cannot require or if on an ebool directly. Use FHE.select for conditional logic and only decrypt at the very end.
  • Treating decryption as synchronous. In tests with mocks it resolves instantly, but on a live network FHE.decrypt and FHE.sealoutput are async. Design your close-and-settle flow around a callback or polling step, or it will break in production.
  • Gas and ciphertext size. FHE operations are far more expensive than plaintext. Keep the encrypted state minimal, prefer the smallest euint type that fits your bid range, and avoid looping homomorphic comparisons over large arrays.
  • Leaking through metadata. Bid timing, gas, and event logs can leak signal even when amounts are hidden. Think about what your events emit.

How DEPLOYR builds and ships it with you

DEPLOYR builds this with you and gets it deployed to a live testnet under your name and wallet. We scaffold the CoFHE Hardhat or Foundry project, write the encrypted auction contract with the FHE.select winner logic and the async reveal flow, wire up cofhejs on the frontend, and set up the mock-based test suite so you can iterate fast. You end up with a real confidential dApp in your portfolio, verified onchain, plus a build log that shows you did the work. That is the storefront: your deployments, provable, yours.

Because FHE is genuinely advanced, this is the kind of build that separates you from the crowd of tutorial-followers. Start at /build to spec your auction, browse /hackathons for FHE and privacy tracks where this project fits, and read more at /insights.

Airdrops are never guaranteed, and no one can promise you a payout. What we can do is help you ship real, verifiable onchain work that makes you the kind of developer these ecosystems actually look for.

Want this built and shipped?

DEPLOYR gets you a working, deployed version on your own wallet and git, with the walkthrough that makes you the verifiable developer on Fhenix. Build it yourself from here, or have us build it with you.

Build it with us →See DEPLOYR templates

Frequently asked questions

What is a sealed-bid auction with FHE?
It is an onchain auction where every bid is encrypted with fully homomorphic encryption before it hits the chain. The contract compares bids on ciphertext without decrypting them, and only the winner and clearing price are revealed at the end, so no one can see losing bids or front-run.
Which chain and tooling do I use to build it?
You build on Fhenix CoFHE, an FHE coprocessor live on Ethereum Sepolia, Arbitrum Sepolia, and Base Sepolia testnets. Use the CoFHE Hardhat or Foundry starter, import FHE.sol with encrypted types like euint128, and use cofhejs on the frontend. Mainnet is on the roadmap.
How does the contract pick a winner without decrypting bids?
It uses homomorphic comparison. FHE.gt returns an encrypted ebool, and FHE.select updates the encrypted highest bid and winning bidder without branching on plaintext. Only after the auction closes does the contract call FHE.decrypt on the winning bid.
Why is decryption asynchronous and why does it matter?
On a live network FHE.decrypt and FHE.sealoutput resolve asynchronously. Decryption runs off-chain in CoFHE and the plaintext is posted back on-chain. Local mock contracts resolve synchronously, so you must design your close-and-settle flow around a callback or polling step or it will break in production.
What are the biggest pitfalls with FHE auctions?
Forgetting explicit access control (FHE.allowThis, FHE.allow) since privacy is not access-controlled by default; branching on ciphertext instead of using FHE.select; treating decryption as synchronous; high gas from oversized encrypted state; and leaking signal through event logs, timing, or gas.
Does building this get me an airdrop?
No. Airdrops are never guaranteed and no one can promise a payout. Building a working confidential auction proves you can write advanced FHE smart contracts, which positions you as a real onchain developer in the Fhenix and privacy ecosystem, but it is not a guarantee of any reward.

Airdrops are never guaranteed. You are positioning as a builder, not buying a payout.

Contact us