Andromeda
Ask or search…
K
Comment on page

Auction

Introduction

The Auction ADO is a smart contract that allows performing custom auctions on NFTs. The owner can send an NFT to this contract with the required messages to start an auction on it. Once the auction has started, users can place bids on the token until the auction expires. The highest bid will win the auction, sending the funds to the seller and receiving the token in return.
This ADO allows creating English Auctions.
The contract supports modules to extend its functionality.
Ado_type: auction

InstantiateMsg

Rust
JSON
pub struct InstantiateMsg {
pub modules: Option<Vec<Module>>,
pub kernel_address: String,
pub owner: Option<String>,
}
{
"kernel_address":"andr1...",
"owner":"andr1..."
}
Name
Type
Description
modules
Option<Vec<Module>>
An optional vector of Andromeda Modules that can be attached to the contract. "rates" and "address-list" modules can be added.
kernel_address
String
Contract address of the kernel contract to be used for AMP messaging. Kernel contract address can be found in our deployed contracts.
owner
Option<String>
Optional address to specify as the owner of the ADO being created. Defaults to the sender if not specified.

ExecuteMsg

ReceiveNft

Receives a token from a SendNft and starts an auction based on the given parameters in the StartAuction struct.
The auction information can be modified before it has started but is immutable after that.
Only the NFT owner can send the NFT and start the auction.
This message is not called by the user on this ADO, but is the case that handles receiving NFTs from a CW721 ADO.
Rust
pub struct Cw721ReceiveMsg {
pub sender: String,
pub token_id: String,
pub msg: Binary,
}
pub enum ExecuteMsg {
ReceiveNft(Cw721ReceiveMsg)
In order to start an auction you need to define the message of the Cw721ReceiveMsg as a Cw721HookMsg.

StartAuction

You need to get the base64 encoded representation of the JSON message and attach it as the msgwhen sending.
Rust
JSON
pub enum Cw721HookMsg {
StartAuction {
start_time: u64,
duration:u64,
coin_denom: String,
min_bid: Option<Uint128>
whitelist: Option<Vec<Addr>>,
}
}
{
"start_auction": {
"start_time": 1663334970211,
"duration": 900000,
"coin_denom": "uandr",
"min_bid":"300",
"whitelist": ["andr1...", "andr1...", ...]
}
}
Name
Type
Description
start_time
u64
Start time in milliseconds since epoch.
duration
u64
Duration in milliseconds from the start_time.
coin_denom
String
The native coin denomination to do the auction in.
min_bid
Option<Uint128>
The minimum bid that can be placed on the auctioned token.
whitelist
Option<Vec<Addr>>
Optional list of addresses to whitelist for the auction. If None, auction is public.
start_time should not be a time in the past.

UpdateAuction

Updates the information of an auction.
Only the owner of the auction can execute UpdateAuction.
An auction can be updated only if it has not started yet.
Rust
JSON
pub enum ExecuteMsg {
UpdateAuction {
token_id: String,
token_address: String,
start_time: u64,
duration: u64,
coin_denom: String,
min_bid: Option<Uint128>
whitelist: Option<Vec<Addr>>,
}
}
{
"update_auction": {
"token_id":"token_001",
"token_address":"andr1...",
"start_time": 1663334970211,
"duration": 900000,
"coin_denom": "uusd",
"min_bid":"400",
"whitelist": ["andr1...", "andr1...", ...]
}
}
start_time should not be a time in the past.
Name
Type
Description
token_id
String
The Id of the NFT that is being auctioned.
token_address
String
The address of the NFT contract.
start_time
u64
Start time in milliseconds since epoch.
duration
u64
Duration in milliseconds from the start_time.
coin_denom
String
The native coin denomination to do the auction in.
min_bid
Option<Uint128>
The minimum bid that can be placed on the auctioned token.
whitelist
Option<Vec<Addr>>
Optional list of addresses to whitelist for the auction. If None, auction is public.

CancelAuction

Only the owner of the auction can execute CancelAuction.
An auction cannot be canceled after it has started.
Cancels the auction of a token.
Rust
JSON
pub enum ExecuteMsg {
CancelAuction {
token_id: String,
token_address: String,
}
}
{
"cancel_auction": {
"token_id":"token_001",
"token_address":"andr1..."
}
}
Name
Type
Description
token_id
String
The Id of the NFT in the auction to be cancelled.
token_address
String
The address of the NFT contract.

PlaceBid

Places a bid for the auction for the given NFT Id. The bid must be sent as native funds along with this message. The previous largest bid gets automatically sent back to the bidder when they are outbid.
The following criteria must be met for the bid to be placed:
  • The NFT is currently under auction
  • The sender's bid is higher than the highest bid
  • The sender does not currently hold the highest bid
  • The sender is not the token owner
Rust
JSON
pub enum ExecuteMsg {
PlaceBid {
token_id: String,
token_address:String,
}
}
{
"place_bid": {
"token_id": "token_001",
"token_address":"andr1..."
}
}
Name
Type
Description
token_id
String
The Id of the NFT to place a bid on.
token_address
String
The address of the NFT contract.

Claim

Sends the winner of the auction the NFT and the funds to the NFT owner when the auction has finished. Anyone is allowed to execute this message.
Can only be done when the end_time has been passed. If there were no bids placed, the original owner retains the token.
Rust
JSON
pub enum ExecuteMsg {
Claim {
token_id: String,
token_address:String,
},
}
{
"claim": {
"token_id": "token_001",
"token_address":"andr1..."
}
}
Name
Type
Description
token_id
String
The Id of the token that was auctioned.
token_address
String
The address of the NFT contract.

Base Executes

Uses the modules feature.
The rest of the execute messages can be found in the ADO Base section.

QueryMsg

LatestAuctionState

Queries the most recent auction for the given token (either ongoing, complete, or not started yet).
Rust
JSON
pub enum QueryMsg {
#[returns(AuctionStateResponse)]
LatestAuctionState {
token_id: String,
token_address:String,
},
}
{
"latest_auction_state": {
"token_id": "token_001",
"token_address":"andr1..."
}
}
Name
Type
Description
token_id
String
The Id of the NFT that we want to query the auction of.
token_address
String
The address of the NFT contract.

AuctionStateResponse

Rust
JSON
pub struct AuctionStateResponse {
pub start_time: Expiration,
pub end_time: Expiration,
pub high_bidder_addr: String,
pub high_bidder_amount: Uint128,
pub auction_id: Uint128,
pub coin_denom: String,
pub is_cancelled:bool,
pub min_bid: Option<Uint128>,
pub whitelist: Option<Vec<Addr>>,
}
{
"auction_state_response": {
"start_time": { "at_time": 1672764083954000000 },
"end_time": { "at_time": 1672773083954000000 },
"high_bidder_addr": "andr1...",
"high_bidder_amount": "50",
"auction_id": "0",
"coin_denom": "uandr",
"claimed": false,
"min_bid":"300",
"whitelist": ["andr1...", "andr1...", ...]
}
}
Name
Type
Description
start_time
The start of the auction.
end_time
The end of the auction.
high_bidder_addr
String
The address of the highest bidder.
high_bidder_amount
Uint128
The amount of the highest bid.
auction_id
Uint128
The Id of the auction.
coin_denom
String
The denom the auction is in.
is_cancelled
bool
Whether or not the auction has been cancelled.
min_bid
Option<Uint128>
The minimum bid that can be placed on the auctioned token.
whitelist
Option<Vec<Addr>>
The whitelisted addresses if they were specified at time of creation.

AuctionState

Gets the auction state for a particular auction_id.
Each Auction has an auction_id which starts at 1 and increments every new auction.
To get the auction_id of a particular token, use LatestAuctionState
Rust
JSON
pub enum QueryMsg {
#[returns(AuctionStateResponse)]
AuctionState {
auction_id: Uint128,
},
}
{
"auction_state": {
"auction_id": "1"
}
}
Name
Type
Description
auction_id
Uint128
The auction Id.

Response

Bids

Gets the bids for a given auction.
Rust
JSON
pub enum QueryMsg {
#[returns(BidsResponse)]
Bids {
auction_id: Uint128,
start_after: Option<u64>,
limit: Option<u64>,
order_by: Option<OrderBy>,
},
}
{
"bids":{
"auction_id": "4",
"start_after": 700,
"limit": 25
}
}
Name
Type
Description
auction_id
Uint128
The auction Id.
start_after
Option<u64>
Optional parameter to specify which bid to start after. If none specified index 0 will be used.
limit
Option<u64>
Optional parameter to specify how many bids to query. If none specified a default limit of 10 is used.
order_by
Option<OrderBy>
Optional parameter to specify the order of the bids being queries. Default is Ascending.
pub enum OrderBy {
Asc,
Desc,
}

BidsResponse

Rust
JSON
pub struct BidsResponse {
pub bids: Vec<Bid>,
}
{
"bids_response": {
"bids": [
{
"bidder": "andr1...",
"amount": "500",
"timestamp": "60"
}
]
}
}
Name
Type
Description
bids
Vec<Bid>
The retrieved bids.

Bid

The state for a particular bid is stored in a basic struct.
pub struct Bid {
pub bidder: String,
pub amount: Uint128,
pub timestamp: Timestamp,
}
Name
Type
Text
bidder
String
The address of the bidder.
amount
Uint128
The amount of funds bid.
timestamp
TimeStamp
The time of the bid.

AuctionIds

Queries the auction Ids for a given token.
Rust
JSON
pub enum QueryMsg {
#[returns(AuctionIdsResponse)]
AuctionIds {
token_id: String,
token_address:String
}
}
{
"auction_ids": {
"token_id": "token_001",
"token_address":"andr1..."
}
}
Name
Type
Description
token_id
String
The Id of the token/NFT.
token_address
String
The address of the NFT contract.

AuctionIdsResponse

Rust
JSON
pub struct AuctionIdsResponse {
pub auction_ids: Vec<Uint128>,
}
{
"auction_ids_response": {
"auction_ids": ["1", "3", ... ]
}
}
Name
Type
Description
auction_ids
Vec<Uint128>
The auction Ids.

AuctionInfosForAddress

Gets all of the auction infos for a given token address.
Rust
JSON
pub enum ExecuteMsg {
#[returns(AuctionInfo)]
AuctionInfosForAddress {
token_address: String,
start_after: Option<String>,
limit: Option<u64>,
}
}
{
"auction_infos_for_address":{
"token_address":"andr1...",
"start_after":"3",
"limit": 15
}
}
Name
Type
Description
token_address
String
The address of the token contract
start_after
Option<String>
Optional parameter to specify which AuctionInfo to start from. If none specified index 0 will be used.
limit
Option<u64>
Optional parameter to specify how many AuctionInfo to query. If none specified a default limit of 10 is used. The maximum limit is 30.

AuctionInfosForAddressResponse

Returns a vector of AuctionInfo defined below.
Rust
JSON
pub struct AuctionInfo {
pub auction_ids: Vec<Uint128>,
pub token_address: String,
pub token_id: String,
}
{
"auction_info" {
"auction_ids": ["0","1",...],
"token_address":"andr1...",
"token_id":"token_001"
}
}
Name
Type
Description
auction_ids
Vec<Uint128>
The Ids of the auctions that use the specified token_address
token_address
String
The address of the token contract.
token_id
String
The Id of the token that was auctioned.

IsCancelled

Checks if the specified aution was cancelled.
Rust
JSON
pub enum QueryMsg {
#[returns(bool)]
IsCancelled {
token_id: String,
token_address: String,
},
}
{
"is_cancelled":{
"token_id":"token_001",
"token_address":"andr1..."
}
}
Name
Type
Description
token_id
String
The Id of the token that was auctioned.
token_address
String
The address of the token contract.
Returns a true if the auction has been cancelled and false otherwise.

IsClosed

Checks if the specified auction has been closes. Returns true only if the auction has been cancelled, the token has been claimed, or the end time has expired.
Rust
JSON
pub enum QueryMsg {
#[returns(bool)]
IsClosed {
token_id: String,
token_address: String,
}
}
{
"is_closed":{
"token_id":"token_001",
"token_address":"andr1..."
}
}
Name
Type
Description
token_id
String
The Id of the token that was auctioned.
token_address
String
The address of the token contract.
Returns a true if the auction has been cancelled and false otherwise.

IsClaimed

Checks if the NFT has been claimed after the auction has concluded.
Rust
JSON
pub enum QueryMsg {
#[returns(bool)]
IsClaimed {
token_id: String,
token_address: String,
}
}
{
"is_claimed":{
"token_id":"token_001",
"token_address":"andr1..."
}
}
Name
Type
Description
token_id
String
The Id of the token that was auctioned.
token_address
String
The address of the token contract.
Returns a true if the NFT has been claimed and false otherwise.

Base Queries

The rest of the query messages can be found in the ADO Base section.