Creating your First NFT Auction House
Last updated
Last updated
In our last guide “Building your First NFT Collection”, we built a simple Andromeda App with one CW721 component and minted some NFTs using the execute messages. In this example, you will create an private NFT auction house for your collection, enabling you to sell them through customized auctions.
To start off, you will be importing our last build into the web-app. To do so, we select “Saved File” in the ADO Builder instead of a Empty Project. Then select the .flex file that you had downloaded previously:
If you haven't exported the last build or gone through the previous example, please follow the steps in the last example again, but stop before publishing the App.
Change the name of the app, and don't forget to update the minter address if you've switched to a different chain or wallet. After that, you can proceed with adding the auction component, which will enable you to auction the NFTs that are minted. Add an “Auction” component to the app and give it a suitable name:
The Auction component has three fields:
Make sure to reference the NFT component correctly "./<component-name>". Since my NFT component is named NFTs, then the reference will be "./NFTs"
Keeping the Authorized token addresses field empty means the auction accepts NFTs from any CW721 ADO. This option is for open auction applications where any user can sell their NFT using your application. In this example, we are going for a private auction intended to just sell your own NFT collection.
Authorized token addresses: The addresses of the CW721 ADOs that are allowed to send NFTs to be auctioned. This is to prevent unwanted NFTs to be sent to the auction by random users. We want our NFT contract that we set up before to be authorized, so we can reference it by its local name "./NFTs"
Authorized Sale Type: Allows us to define a CW20 ADO whose tokens can be set as the bidding token for the NFT sales. This would restrict the CW20 ADOs allowed to be set to the one defined here. In case we just select native, then we can set any CW20 as the purchasing token. Using a native token is always accepted. This will be defined later on when we configure auction parameters. So for now we select the Native option.
Modules: Allows users to add modules to the auction. For now, you do not need any modules, so you can keep it empty.
Modules are currently disabled, but will be available in our next release.
Publish the app to chain so we can start setting up the auctions:
We need to mint the NFTs we are looking to sell. In the CW721 component, select the Batch Mint execute and mint 3 tokens. Once done, publish to chain.
You can download the flex file for the batch minting before publishing to be imported later on.
To start an auction for an NFT, you need to send the NFT to the auction and attach the appropriate message using the SendNft execute message for the CW721 component. This message is similar to a TransferNft (Which transfers ownership of an NFT) message, but is used specifically to send an NFT to another ADO/contract instead of a user address and instructs that ADO/contract to initiate an action, in this case starting an auction.
Select the SendNft execute message:
The first required field is the Recipient Address. This is the address to send the NFT to. In our case, we want to send it to the Auction component in our app.
We can get the address from the assets page under Address in the Auction panel.
Next, you need to provide the token Id of the NFT you want to send. For the first auction, send the first NFT you minted (In my case the token Ids were 1,2,3).
You might notice that the field name here is Token/NFT Name and not Token Id. This is a mistake in our panel that we will be fixing very soon.
Finally you need to select the message to attach along with our NFT. Select “Auction” from the “Custom Message” options, then select “CW721 start auction”:
Here we can configure our auction options:
Specify if we want to use a CW20 token as the bidding token. I will not check the box as I intend to use native.
Specify the coin denom accepted for bidding. Since I am building on the Stargaze chain, and I want to use a native tokens as the bidding token, I will specify ustars.
Specify when the auction starts. This is specified through an epoch time in milliseconds. Selecting none means the auction will start immediately after the message is published. I will use that option.
Specify the end time of the auction as an epoch time in milliseconds. I want the auction to run for 2 hours. Usin the date and time selector, we can easily specify the end time.
Specify the minimum bid accepted. This field is optional. I do not want a minimum bid, so I select No Minimum Bid.
Specify the recipient which is the address to receive the funds from a succesfull NFT sale. I will select none as it will default to my address (The sender of the NFT).
Specify a whitelist of addresses allowed to bid on the NFT. This field is optional. I will not add a whitelist for this example.
Once done with configuring the fields, publish the message to chain. People can now bid on the NFT you just sent to auction (When the specified start time is reached). Since you sent the NFT to the auction component, it will be used to bid on the NFT.
We have succesfully set up one NFT auction. You can do the same for each minted NFT. You can also use the Multi Execute option, to set up multiple messages at a time. This would allow you to send multiple NFTs to the auction in one go.
If you want to try bidding on the NFT you just put up for auction, check our "Using CLI to Interact with Apps" section.
If you want to make a custom interface for users to bid on the NFTs, check out our "Embeddables" guide.
If you are interested in using queries on your App components, check out our Using Queries section to learn about that process.
If you are interested in using CW20 tokens as the bidding token, you can check out the "Auction Using CW20 Tokens" example.
Next, we will be going through building some of the popular dApps in the space starting from an NFT Marketplace App.