Sealed Bid Auction Developer Tutorial
Last updated
Was this helpful?
Last updated
Was this helpful?
A first-price sealed-bid auction, also known as a "blind auction", is a type of auction in which all bidders simultaneously submit sealed bids so that no bidder knows the bid of any other participant. The highest bidder pays the price that was submitted. In this tutorial you will learn how to create a cross-chain sealed bid auction dApp with encrypted bids using.
See a live demo ! See the fullstack frontend code implementation .
You will start by configuring your developer environment and then learn how to use SecretPath to enable cross-chain encryption and decryption, using Secret Network as a Confidential Computing Layer (CCL) for the EVM.
To get started, clone the SecretPath tutorials repository:
your Sepolia wallet.
.
.
cd
into sealed-bid-auctions/sealed-bid-contract
Compile the contract
cd
into secret-contract/node:
Install the node dependencies
Set SecretPath parameters:
Upload and instantiate the contract:
Now that you've instantiated a sealed bid contract on Secret Network, it's time to create your first auction item with SecretPath!
cd
into sealed-bid-auctions/evm-contract
:
Install the dependencies
Configure env
Configure SecretPath
Now that you have all of your SecretPath code configured, execute the SecretPath Sepolia public gateway contract to send your auction item to the Secret contract:
Upon successful execution, info about your SecretPath payload will be returned:
Once you have set your bid, execute the bid function:
Upon successful execution, info about your SecretPath payload will be returned. Now let's query your auction item and bids with secret.js.
cd
into sealed-bid-auctions/sealed-bid-contract/node
:
Make sure you have added your Sealed bid contract address and codehash to your env file, and then query the auction item with node query_auction
:
If your auction item was submitted successfully, it should be returned like so:
If the bidding is still open, it will return the message:
If the bidding is closed, it will return the highest bid:
Note that the end user of the application is not exposed to Secret Network and is only working directly in the EVM environment. However, the data is fully protected and cannot be viewed by anyone.
Update the with your Secret Network wallet mnemonic, and rename it ".env" instead of ".env.example"
Open upload.js and configure the SecretPath , , and :
gatewayAddress, gatewayHash, and gatewayPublicKey are needed for instantiating contracts that utilize SecretPath and can be found in the docs . You will always use these same 3 parameters for instantiating a SecretPath-compatible contract on testnet.
Upon successful upload and instantiation, add the contract codehash and address to your .
Configure the with your sealed bid auction contract address and codehash, and rename it ".env" instead of ".env.example".
Open and navigate to , the publicClientAddress
. This is the SecretPath gateway address for .
If you wanted to send messages on another chain, such as Base or Polygon, you would simply update this publicClientAddress with the corresponding address found.
Similarly, there is a SecretPath gateway encryption key, which is on This is used for ChaCha20-Poly1305 Payload encryption and can be found in the docs
Next, configure the auction to your liking (end_time
is the amount of minutes that the auction will be live for), and note the handle
variable, which is the function that is actually being called in the Secret contract that you deployed. You are executing the handle, which executes the in your sealed bid contract.
Now it's time to place an encrypted bid on your listed auction item. Open and adjust the that you want to bid as well as the of the auction item.
NOTE: end_time
is converted from minutes to Secret Network block height π
Now, query the by running node query_bid
:
This is programmed in the of the Sealed Bid contract and can be adjusted to your liking π
NOTE: Be sure to update the for subsequent auction item queries
Congrats! You deployed your very own sealed bid auction contract on Secret Network and used SecretPath to send cross-chain encrypted bids on Sepolia testnet. See the fullstack demo . You now have all of the tools you need to start building your own cross-chain SecretPath contracts on the EVM π
If you have any questions or run into any issues, post them on the and somebody will assist you shortly.