Skip to main content

Overview

The Auction Template contract provides methods to retrieve auction templates that can be used to create dynamic auctions.

List Auction Templates

Fetch all available auction templates for your integrator.
const response = await client.auctionTemplates.listAuctionTemplates();

if (response.status === 200) {
  const templates = response.body.result;
  templates.forEach(template => {
    console.log(`${template.name} (${template.id})`);
    if (template.description) {
      console.log(`  ${template.description}`);
    }
  });
}

Response Schema

{
  id: string;             // Template UUID
  name: string;           // Template name
  description: string | null;  // Optional description
}

Examples

Find Template by Name

const response = await client.auctionTemplates.listAuctionTemplates();

if (response.status === 200) {
  const template = response.body.result.find(
    t => t.name === 'Standard Auction'
  );

  if (template) {
    console.log('Template ID:', template.id);
    console.log('Description:', template.description);
  }
}

Use Template to Create Auction

// First, get available templates
const templatesResponse = await client.auctionTemplates.listAuctionTemplates();

if (templatesResponse.status === 200) {
  const template = templatesResponse.body.result[0];

  // Then create auction using template ID
  const auctionResponse = await client.auctions.createDynamicAuction({
    body: {
      template_id: template.id,
      metadata: {
        token_name: 'My Token',
        token_symbol: 'MTK',
        token_uri: 'ipfs://Qm...',
        user_address: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e'
      },
    },
    query: {
      chainId: 8453, // Base Mainnet
    }
  });

  if (auctionResponse.status === 200) {
    console.log('Auction created with template:', template.name);
  }
}

List Templates with Details

const response = await client.auctionTemplates.listAuctionTemplates();

if (response.status === 200) {
  console.log('Available Templates:\n');

  response.body.result.forEach((template, index) => {
    console.log(`${index + 1}. ${template.name}`);
    console.log(`   ID: ${template.id}`);
    console.log(`   Description: ${template.description || 'N/A'}\n`);
  });
}
Templates are configured by the Long.xyz team for your integrator. Contact support to create custom templates.