Auctioning App
Deploying an auctioning App using the Andromeda CLI.
If unfamiliar with the steps of deploying an app, go back to the first example where we explain in detail all the different parts of deploying an App.
If any of the messages in this example do not work, you might want to cross reference the messages with the ADO specific section which always contains the latest ADO versions to make sure they are correct. Other than that the logic will remain the same.
Make sure to read the Introduction to Apps before going through building an app.
Defining our App
You can also use a CW20 token as the bidding token. You ca read more about the Auction ADO if you are interested in testing out variations on this App.
For this example, we will be building a simple auction app that holds auction sales on NFTs using a native token for bidding. We only need two components/ADOs:
We will perform the following steps:
Mint an NFT
Send it to auction starting an auction on it
Place bids on the NFT
End the auction
Claim the funds and transfer the NFT to the new owner
The Steps of Deploying an App
We already have an ADODB contract with saved code IDs of the ADOs and Kernel ADO deployed. These addresses can be found in Deployed Contracts section. This means that to deploy an App we only need to instantiate it through the CLI.
You will need the deployed Kernel contract address as it needs to be specified when instantiating any ADO.
Defining the Instantiation Messages
For this app we would need only 2 components:
Although not necessary, if you are unfamiliar with these ADOs, it is suggested to read through each of the them before deploying an app.
Let us first start by representing the instantiation message for each of our ADOs:
Keep in mind that the app takes these messages as base64 encoded.
CW721
Make sure to set the minter as your own address. If you do not change the minter, you will not be able to mint any tokens.
As base64:
Auction
Here we specify which CW721 is permitted to send NFTs to the auction. We reference the CW721 of our app through the name.
As base64:
App
The Kernel address used here might be outdated in the future. Check our deployed contracts to get the latest Kernel or run "chain config" in CLI which will also display the address.
The instantiate_msg
for the cw721 will not be the same for you as you should specify the minter address as your own. Make sure to replace it with the base64 message that you got.
There are several components found here. A simple name for the app, the components of the app itself and a reference to the “Kernel”. Each component of the app provides two values: a name used for referencing for other components within the app, and the base64 encoded instantiation message.
Instantiating the App
If you do not have the CLI downloaded, go to the Introduction to Apps section to get the latest version.
First, let us open the CLI by running andr
in our terminal. We then need to choose the chain we want to deploy on. Run "chain use"
in the CLI and select the testnet that you want to deploy on. For this example I will be using the Andromeda test-net Galileo-3.
If this is the first time using the CLI make sure to run "wallet add <wallet-name>"
in order to create a wallet. Then go to that chain's faucet (usually located in their discord) and request tokens.
We have already uploaded the App ADO to the Andromeda testnet. A simple way to check the latest code id for the App ADO is to query it from the ADODB using the chain you want to use.
In the CLI, while connected to the chain of choice, run:
The code Id to use will be returned.
Now we can instantiate our App. We will be using our wasm command to instantiate our app:
Note that the instantiation message will not be the exact same for you since you will be using a different recipient address.
Do not copy and paste the command below as it will not work. Make sure to make the appropriate changes before running the command.
Replace the <code_id> with the returned code-id for the app ADO.
You will be using the contract addresses that were instantiated for you instead of the ones in this tutorial.
Interacting with the App
Mint Tokens
We will only mint one NFT to auction:
Make sure to replace <your-address> with the address you are using for the owner field.
Start Auction
In order to start an auction on our token, we need to send it to the auction contract with the required message.
The attached message is a start_auction
message to start the auction when the NFT is sent.
You can also add a start time field to specify when the auction should start. Ommitting is means that the auction will begin as soon as the Start Sale message is executed on chain.
The end_time above will be in the past for you and will give an Error. Make sure to check the current epoch time in milliseconds to enter a valid end time.
Place Bids
Now it is time to start placing some bids on our NFT.
You can only place bids once the auction started which in our case is right away.
Dont forget to switch wallets when bidding since the owner cannot bid on their own auctioned NFT. To switch wallets run "wallets use"
then chose the wallet to bid with.
In order to bid on a token, you will need to attach funds to the message equal to the bid amount you want to place. When you run the message, you will be asked "Would you like to add funds to this message?" select yes and input the bid amount you want. An example would be 600uandr .
Let us query the Bids of the auction to see if they match:
Result
After the Auction has concluded, it is time to claim the NFT for the buyer and funds for the seller.
Claim the NFT
The funds will be sent to the seller and the NFT to the winning bid. We can check the NFT owner after claiming by querying our NFT contract:
The returned owner should be the highest bidder.
Conclusion
Congratulations, we have built a fully functioning auctioning App that allows you to auction off your NFTs. Keep in mind that all the apps we build in these examples are highly customizable to satisfy user needs. We can change the accepted funds, add/remove whitelists, and even add more components to our App if needed.