Andromeda
Search
⌃K

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.
The contract supports modules to extend its functionality.
Ado_type: auction

InstantiateMsg

Rust
pub struct InstantiateMsg {
pub modules: Option<Vec<Module>>,
}
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.

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.
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

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 token 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 token 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 token 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 token contract.

AndrRecieve

Uses the modules feature.
The rest of the executes can be found in the AndrReceive 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 token 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 token/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.

AndrQuery

A set of base queries common to all Andromeda ADOs. Check AndrQuery.