Theme

Auction House

Manage Auction Houses

Introduction

On the previous page, we went through the various settings of an Auction House. So now, let’s see how we can use these settings to create and update Auction Houses.

We'll also talk about different ways of fetching Auction House. Lastly, we'll go see how to withdraw funds from the Auction House fee and treasury accounts.

Create Auction Houses

An Auction House can be created with all the settings discussed in the previous page. The created Auction House account is referred to as an Auction House Instance.

JS SDK

Let's go through an example of using the Metaplex JS SDK to create an Auction House. Note that by default the current identity is used as the authority of the Auction House. Moreover, by default SOL will be set as the treasuryMint. Lastly, helper accounts discussed in the last page will be automatically generated by the Auction House, but they can also be set manually while Auction House creation.

const auctionHouseSettings = await metaplex
    .auctionHouse()
    .create({
        sellerFeeBasisPoints: 500 // 5% fee
        authority: metaplex.identity(),
        requireSignOff: true,
        canChangeSalePrice: true,
        hasAuctioneer: true, // to enable auctioneer
        auctioneerAuthority: metaplex.identity(),
    });

Auction House Account

Now that we’ve created an Auction House instance, let’s see what data is stored inside it.

Firstly, it stores all the settings that we have already discussed. In addition to these settings, the Auction House account stores a creator field, which points to the address of the wallet used to create the Auction House instance.

Lastly, the Auction House instance also stores some PDA bumps, which are used to derive the addresses of the PDA accounts.

When building with PDAs, it is common to store the bump seed in the account data itself. This allows developers to easily validate a PDA without having to pass in the bump as an instruction argument.

JS SDK

The Auction House account model can be explored in the API References of the AuctionHouse model.

Here’s a small code example showcasing some of the Auction House attributes.

const { auctionHouse } = await metaplex.auctionHouse().create({...});

auctionHouse.address;                   // The public key of the Auction House account              
auctionHouse.auctionHouseFeeAccount;    // The public key of the Auction House Fee account
auctionHouse.feeWithdrawalDestination;  // The public key of the account to withdraw funds from Auction House fee account
auctionHouse.treasuryMint;              // The mint address of the token to be used as the Auction House currency
auctionHouse.authority;                 // The public key of the Auction House authority
auctionHouse.creator;                   // The public key of the account used to create the Auction House instance
auctionHouse.bump;                      // The `Bump` of the Auction House instance
auctionHouse.feePayerBump;              // The `Bump` of the fee account
auctionHouse.treasuryBump;              // The `Bump` of the treasury account
auctionHouse.auctioneerAddress;         // he public key of the `Auctioneer` account

Fetch Auction Houses

Once created, the Auction House instance can be fetched. An Auction House can be uniquely identified by its PDA account address or a combination of its creator address and the treasury mint address.

JS SDK

An Auction House can be fetched using two ways:

  1. By address: using the Auction House address
  2. By creator and mint: using the combination of the creator address and the treasury mint. Note that when the Auction House has Auctioneer enabled, the auctioneerAuthority is also required in addition to the creator and the mint.
// by address
const auctionHouse = await metaplex
    .auctionHouse()
    .findByAddress({ address: new PublicKey("Gjwc...thJS") });

// by creator and mint
// in this example, we assume that the Auction House
// does not have Auctioneer enabled
const auctionHouse = await metaplex
    .auctionHouse()
    .findByCreatorAndMint({
        creator: new PublicKey("Gjwc...thJS"),
        treasuryMint: new PublicKey("DUST...23df")
    });

Update Settings

As in the case of Candy Machine, once an Auction House instance is created, you can update most of its settings later on as long as you are the authority of the Auction House instance. The following settings can be updated: authority, sellerFeeBasisPoints, requiresSignOff, canChangeSalePrice, feeWithdrawalDestination, treasuryWithdrawalDestination, auctioneerScopes.

As we've already discussed, the authority of the Auction House is one of the settings that can be updated, as long as the current authority is the signer and the address of the new authority is mentioned.

JS SDK

To update the settings, we need the full model in order to compare the current data with the provided data. For instance, if you only want to update the feeWithdrawalDestination, you need to send an instruction that updates the data whilst keeping all other properties the same.

Also, by default, feeWithdrawalDestination and the treasuryWithdrawalDestination are set to metaplex.identity(), ie., the same wallet which is set as the authority and the creator by default.

import { Keypair } from "@solana/web3.js";

const currentAuthority = Keypair.generate();
const newAuthority = Keypair.generate();
const newFeeWithdrawalDestination = Keypair.generate();
const newTreasuryWithdrawalDestination = Keypair.generate();
const auctionHouse = await metaplex
    .auctionHouse()
    .findByAddress({...});

const updatedAuctionHouse = await metaplex
    .auctionHouse()
    .update({
        auctionHouse,
        authority: currentAuthority,
        newAuthority: newAuthority.address,
        sellerFeeBasisPoints: 100,
        requiresSignOff: true,
        canChangeSalePrice: true,
        feeWithdrawalDestination: newFeeWithdrawalDestination,
        treasuryWithdrawalDestination: newTreasuryWithdrawalDestination
    });

Withdraw Funds

We have discussed in the previous page about the different helper accounts of Auction House. These are the Fee Account and the Treasury Account.

Funds from both these accounts can be transferred back to "destination" wallets. These withdrawal destination accounts can be set by the Auction House authority.

JS SDK

Here's a code snippet which transfers funds.

  1. Auction House Fee Wallet to the Fee Withdrawal Destination Wallet.
  2. Transfers funds from Auction House Treasury Wallet to the Treasury Withdrawal Destination Wallet.

In both the cases, The Auction House from which the funds are being transferred and the amount of funds to withdrawn need to be specified. This amount can either be in SOL or in the SPL token used by the Auction House as a currency.

// withdraw funds from fee account
await metaplex
    .auctionHouse()
    .withdrawFromFeeAccount({
        auctionHouse,
        amount: 5
    });

// withdraw funds from treasury account
await metaplex
    .auctionHouse()
    .withdrawFromTreasuryAccount({
        auctionHouse,
        amount: 10
    });

Conclusion

At this point we've gone over the Auction House settings, the data an Auction House instance stores and how to create and update this data. However, we still don't know how assets are traded on Auction Houses. We'll talk about this in the next page.

Previous
Auction House Settings