SDK for Solbids Layer 2 Bidding System on Solana
npm install solbids-layer2-sdkA comprehensive TypeScript SDK for interacting with the Solbids Layer 2 bidding system on Solana.
``bash`
npm install @solbids/layer2-sdkor
yarn add @solbids/layer2-sdk
`typescript
import { SolbidsSDK } from "@solbids/layer2-sdk";
import { Connection, PublicKey } from "@solana/web3.js";
import { WalletAdapter } from "@solana/wallet-adapter-base";
// Initialize SDK with wallet address only
const connection = new Connection("https://api.devnet.solana.com");
const walletAddress = new PublicKey("..."); // User's wallet address
const sdk = new SolbidsSDK(connection, walletAddress);
// Build transaction to buy bids
const ownerPublicKey = new PublicKey("..."); // Platform owner's public key
const transaction = await sdk.buyBids(10, ownerPublicKey);
// Sign, send, and confirm with priority fee
const signature = await sdk.signAndSendTransaction(
transaction,
wallet, // Wallet adapter with signTransaction method
300000 // Priority fee in micro-lamports
);
console.log("Transaction:", signature);
// Check bid balance (read-only, no transaction needed)
const balance = await sdk.getBidBalance(ownerPublicKey);
console.log("Bid balance:", balance);
`
- ✅ Buy bid credits (Layer 2 bidding)
- ✅ Place bids on auctions
- ✅ Create auctions (Standard Token, Token-2022, pNFT, Core NFT)
- ✅ Claim assets as auction winner (all asset types)
- ✅ Withdraw assets (all asset types)
- ✅ Register and manage owners
- ✅ Create and manage products
- ✅ Manage auction lifecycle (start, end)
- ✅ Admin operations (initialize, pause, update config, claim fees)
- ✅ Query auction, product, owner, and user data
- ✅ Get vault balances (owner and admin fee vaults)
- ✅ Bid package system (create discount packages, bulk purchases)
- ✅ Full TypeScript support
- ✅ Automatic asset type detection
- ✅ Complete contract method coverage (41 methods total)
`typescript
import { SolbidsSDK } from "@solbids/layer2-sdk";
import { Connection, PublicKey } from "@solana/web3.js";
const connection = new Connection("https://api.devnet.solana.com");
const walletAddress = new PublicKey("..."); // User's wallet address
const sdk = new SolbidsSDK(connection, walletAddress);
`
Note: The SDK only needs the wallet address for initialization. Transaction signing is handled separately via signAndSendTransaction().
#### buyBids(bidCount: number, ownerKey: PublicKey)
Build a transaction to purchase bid credits from a specific platform/owner at regular price.
Parameters:
- bidCount: Number of bids to purchaseownerKey
- : REQUIRED - Platform/owner's public key (the wallet that registered as owner)
Returns: Promise - Transaction object (not signed or sent)
`typescript
const ownerPublicKey = new PublicKey("..."); // Platform owner's public key
const transaction = await sdk.buyBids(10, ownerPublicKey);
// Then sign, send, and confirm
const signature = await sdk.signAndSendTransaction(transaction, wallet, 300000);
`
#### buyBidsWithPackage(ownerKey: PublicKey, packageId: string)
Build a transaction to purchase bid credits using a discount package.
Parameters:
- ownerKey: REQUIRED - Platform/owner's public keypackageId
- : Package ID (created by the owner)
Returns: Promise - Transaction object (not signed or sent)
`typescript
const ownerPublicKey = new PublicKey("..."); // Platform owner's public key
const transaction = await sdk.buyBidsWithPackage(ownerPublicKey, "package-1");
// Then sign, send, and confirm
const signature = await sdk.signAndSendTransaction(transaction, wallet, 300000);
`
#### getBidBalance(ownerKey: PublicKey, userKey?: PublicKey)
Get user's current bid balance.
Parameters:
- ownerKey: REQUIRED - Platform/owner's public keyuserKey
- : Optional - User's public key (defaults to SDK wallet address)
`typescriptYou have ${balance} bids
const ownerPublicKey = new PublicKey("..."); // Platform owner's public key
const balance = await sdk.getBidBalance(ownerPublicKey);
console.log();`
#### getUser(ownerKey: PublicKey, userKey?: PublicKey)
Get user account data.
Parameters:
- ownerKey: REQUIRED - Platform/owner's public keyuserKey
- : Optional - User's public key (defaults to SDK wallet address)
`typescript`
const ownerPublicKey = new PublicKey("..."); // Platform owner's public key
const user = await sdk.getUser(ownerPublicKey);
console.log("User data:", user);
#### placeBid(auctionCreator: PublicKey, auctionId: string | Uint8Array, bidCount: number)
Place bids on an auction. Uses correct PDA derivation matching the contract.
Parameters:
- auctionCreator: Auction creator's public keyauctionId
- : Auction ID (string or Uint8Array)bidCount
- : Number of bids to place
Returns: Promise - Transaction object (not signed or sent)
`typescript
const auctionCreator = new PublicKey("...");
const transaction = await sdk.placeBid(auctionCreator, "auction-123", 3);
// Then sign, send, and confirm
const signature = await sdk.signAndSendTransaction(transaction, wallet, 300000);
`
#### createProduct(productId: string, name: string, description: string, imageUrls: string[], category: string, tags: string[], metadata: string, ownerKey?: PublicKey)
Build a transaction to create a product.
Parameters:
- productId: Product ID (string)name
- : Product namedescription
- : Product descriptionimageUrls
- : Array of image URLs (max 5)category
- : Product categorytags
- : Array of tags (max 10)metadata
- : Additional metadata (JSON string)ownerKey
- : Optional - Owner's public key (defaults to SDK wallet address)
Returns: Promise - Transaction object (not signed or sent)
`typescript
const transaction = await sdk.createProduct(
"product-1",
"My Product",
"Product description",
["https://example.com/image1.jpg"],
"Category",
["tag1", "tag2"],
JSON.stringify({ custom: "data" })
);
const signature = await sdk.signAndSendTransaction(transaction, wallet, 300000);
`
#### updateProduct(productId: string | Uint8Array, creator: PublicKey, name?: string, description?: string, imageUrls?: string[], category?: string, tags?: string[], metadata?: string)
Build a transaction to update a product.
Parameters:
- productId: Product ID (string or Uint8Array)creator
- : Product creator's public keyname
- : Optional - Product namedescription
- : Optional - Product descriptionimageUrls
- : Optional - Array of image URLscategory
- : Optional - Product categorytags
- : Optional - Array of tagsmetadata
- : Optional - Additional metadata
Returns: Promise - Transaction object (not signed or sent)
`typescript
const transaction = await sdk.updateProduct(
"product-1",
creatorPublicKey,
"Updated Name",
"Updated Description"
);
const signature = await sdk.signAndSendTransaction(transaction, wallet, 300000);
`
#### deactivateProduct(productId: string | Uint8Array, creator: PublicKey)
Build a transaction to deactivate a product.
Parameters:
- productId: Product ID (string or Uint8Array)creator
- : Product creator's public key
Returns: Promise - Transaction object (not signed or sent)
`typescript`
const transaction = await sdk.deactivateProduct("product-1", creatorPublicKey);
const signature = await sdk.signAndSendTransaction(transaction, wallet, 300000);
#### getProduct(creator: PublicKey, productId: string | Uint8Array)
Get product data.
Returns: Product account data or null if not found
`typescript`
const product = await sdk.getProduct(creatorPublicKey, "product-1");
#### getAllProducts()
Get all products.
Returns: Array of all products
`typescript`
const products = await sdk.getAllProducts();
#### createAuction(auctionId: string, productId: string, productCreator: PublicKey, startTime: Date, endTime: Date, startingPrice: number, bidIncrement: number, bidTimeExtension: number, assetMint: PublicKey, assetAmount?: number, reservePrice?: number, buyNowPrice?: number, ownerKey?: PublicKey)
Build a transaction to create an auction. Auto-detects asset type (Standard Token, Token-2022, pNFT, or Core NFT) and routes to the appropriate method.
Parameters:
- auctionId: Auction ID (string)productId
- : Product ID (string)productCreator
- : Product creator's public keystartTime
- : Auction start time (Date)endTime
- : Auction end time (Date)startingPrice
- : Starting price in SOLbidIncrement
- : Bid increment in SOLbidTimeExtension
- : Time extension per bid in secondsassetMint
- : Asset mint address (or Core asset address for Core NFTs)assetAmount
- : Optional - Asset amount (default: 1, used for tokens)reservePrice
- : Optional - Reserve price in SOLbuyNowPrice
- : Optional - Buy now price in SOLownerKey
- : Optional - Owner's public key (defaults to SDK wallet address)
Returns: Promise - Transaction object (not signed or sent)
`typescript
const transaction = await sdk.createAuction(
"auction-1",
"product-1",
productCreatorPublicKey,
new Date(Date.now() + 60000), // Start in 1 minute
new Date(Date.now() + 3600000), // End in 1 hour
1.0, // Starting price: 1 SOL
0.1, // Bid increment: 0.1 SOL
60, // Time extension: 60 seconds per bid
assetMintPublicKey,
1, // Asset amount (1 for NFTs)
0.5, // Reserve price: 0.5 SOL (optional)
10.0 // Buy now price: 10 SOL (optional)
);
const signature = await sdk.signAndSendTransaction(transaction, wallet, 300000);
`
#### createAuctionStandard(...) / createAuctionPNFT(...) / createAuctionCoreNFT(...)
Explicit methods for creating auctions with specific asset types. Use createAuction() for automatic detection, or these methods for explicit control.
`typescript
// Standard Token or Token-2022
const transaction = await sdk.createAuctionStandard(
"auction-1",
"product-1",
productCreatorPublicKey,
startTime,
endTime,
1.0,
0.1,
60,
assetMintPublicKey,
1,
0.5,
10.0,
assetInfo, // AssetInfo from detectAssetType()
ownerKey
);
// pNFT
const transaction = await sdk.createAuctionPNFT(
"auction-1",
"product-1",
productCreatorPublicKey,
startTime,
endTime,
1.0,
0.1,
60,
assetMintPublicKey,
1,
0.5,
10.0,
assetInfo, // AssetInfo from detectAssetType()
ownerKey
);
// Core NFT
const transaction = await sdk.createAuctionCoreNFT(
"auction-1",
"product-1",
productCreatorPublicKey,
startTime,
endTime,
1.0,
0.1,
60,
coreAssetPublicKey, // Core asset address (not a mint)
0.5,
10.0,
ownerKey
);
`
#### startAuction(auctionCreator: PublicKey, auctionId: string | Uint8Array)
Build a transaction to start an auction (activate it).
Parameters:
- auctionCreator: Auction creator's public keyauctionId
- : Auction ID (string or Uint8Array)
Returns: Promise - Transaction object (not signed or sent)
`typescript`
const transaction = await sdk.startAuction(
auctionCreatorPublicKey,
"auction-1"
);
const signature = await sdk.signAndSendTransaction(transaction, wallet, 300000);
#### endAuction(auctionCreator: PublicKey, auctionId: string | Uint8Array)
Build a transaction to end an auction.
Parameters:
- auctionCreator: Auction creator's public keyauctionId
- : Auction ID (string or Uint8Array)
Returns: Promise - Transaction object (not signed or sent)
`typescript`
const transaction = await sdk.endAuction(auctionCreatorPublicKey, "auction-1");
const signature = await sdk.signAndSendTransaction(transaction, wallet, 300000);
#### getAuction(auctionCreator: PublicKey, auctionId: string | Uint8Array)
Get auction data.
Returns: Auction account data or null if not found
`typescript`
const auction = await sdk.getAuction(auctionCreatorPublicKey, "auction-1");
console.log("Current highest bid:", auction.highestBid.toString());
console.log("Status:", auction.status);
#### getAllAuctions()
Get all auctions.
Returns: Array of all auctions
`typescript`
const auctions = await sdk.getAllAuctions();
#### claimAsset(auctionCreator: PublicKey, auctionId: string | Uint8Array, assetMint: PublicKey)
Build a transaction to claim asset as auction winner. Auto-detects asset type and routes to the appropriate method.
Parameters:
- auctionCreator: Auction creator's public keyauctionId
- : Auction ID (string or Uint8Array)assetMint
- : Asset mint address (or Core asset address for Core NFTs)
Returns: Promise - Transaction object (not signed or sent)
`typescript
const transaction = await sdk.claimAsset(
auctionCreatorPublicKey,
"auction-1",
assetMintPublicKey
);
const signature = await sdk.signAndSendTransaction(transaction, wallet, 300000);
`
Note: The SDK automatically detects the asset type (Standard Token, Token-2022, pNFT, or Core NFT) and routes to the appropriate contract method. You don't need to specify the asset type manually.
#### buyNow(auctionCreator: PublicKey, auctionId: string | Uint8Array, assetMint?: PublicKey)
Build a transaction to buy an asset at the buy-now price. Auto-detects asset type and routes to the appropriate method.
Parameters:
- auctionCreator: Auction creator's public keyauctionId
- : Auction ID (string or Uint8Array)assetMint
- : Optional - Asset mint address (or Core asset for Core NFTs). If not provided, will use auction's stored asset_mint.
Returns: Promise - Transaction object (not signed or sent)
Note: This method is only available when:
- The auction has a buyNowPrice set
- The auction has started
- The auction has not ended
- The asset has not been claimed
`typescript
const transaction = await sdk.buyNow(
auctionCreatorPublicKey,
"auction-1",
assetMintPublicKey // Optional - auto-detected from auction if not provided
);
const signature = await sdk.signAndSendTransaction(transaction, wallet, 300000);
`
Note: The SDK automatically detects the asset type (Standard Token, Token-2022, pNFT, or Core NFT) and routes to the appropriate contract method. You don't need to specify the asset type manually.
#### withdrawAsset(auctionCreator: PublicKey, auctionId: string | Uint8Array, assetMint?: PublicKey)
Build a transaction to withdraw asset back to creator when auction ended without a winner. Auto-detects asset type and routes to the appropriate method.
Parameters:
- auctionCreator: Auction creator's public keyauctionId
- : Auction ID (string or Uint8Array)assetMint
- : Optional - Asset mint address (or Core asset for Core NFTs). If not provided, will use auction's stored asset_mint.
Returns: Promise - Transaction object (not signed or sent)
`typescript
const transaction = await sdk.withdrawAsset(
auctionCreatorPublicKey,
"auction-1",
assetMintPublicKey // Optional - auto-detected from auction if not provided
);
const signature = await sdk.signAndSendTransaction(transaction, wallet, 300000);
`
Note: The SDK automatically detects the asset type (Standard Token, Token-2022, pNFT, or Core NFT) and routes to the appropriate contract method. You don't need to specify the asset type manually.
#### registerOwner(name: string, description: string, website: string, contactEmail: string, bidPrice: number, ownerKey?: PublicKey)
Build a transaction to register as a platform owner.
Parameters:
- name: Owner namedescription
- : Owner descriptionwebsite
- : Website URLcontactEmail
- : Contact emailbidPrice
- : Price per bid in SOLownerKey
- : Optional - Owner's public key (defaults to SDK wallet address)
Returns: Promise - Transaction object (not signed or sent)
`typescript
const transaction = await sdk.registerOwner(
"My Platform",
"Platform description",
"https://example.com",
"contact@example.com",
0.1 // Bid price in SOL
);
const signature = await sdk.signAndSendTransaction(transaction, wallet, 300000);
`
#### updateOwner(ownerKey: PublicKey, name?: string, description?: string, website?: string, contactEmail?: string)
Build a transaction to update owner information.
Parameters:
- ownerKey: Owner's public keyname
- : Optional - Owner namedescription
- : Optional - Owner descriptionwebsite
- : Optional - Website URLcontactEmail
- : Optional - Contact email
Returns: Promise - Transaction object (not signed or sent)
`typescript
const transaction = await sdk.updateOwner(
ownerPublicKey,
"Updated Name",
"Updated Description"
);
const signature = await sdk.signAndSendTransaction(transaction, wallet, 300000);
`
#### getOwner(ownerKey: PublicKey)
Get owner account data.
Returns: Owner account data or null if not found
`typescript`
const owner = await sdk.getOwner(ownerPublicKey);
#### getAllOwners()
Get all owners (fetches all program accounts).
Returns: Array of all owners with publicKey and ownerKey included
`typescriptOwner: ${owner.name} - Key: ${owner.ownerKey.toString()}
const owners = await sdk.getAllOwners();
owners.forEach((owner) => {
console.log();`
});
#### getOwnerVaultBalance(ownerKey: PublicKey)
Get owner vault balance in SOL.
Returns: Balance in SOL
`typescriptVault balance: ${balance} SOL
const balance = await sdk.getOwnerVaultBalance(ownerPublicKey);
console.log();`
#### claimOwnerFunds(amount: number, ownerKey?: PublicKey)
Build a transaction to claim funds from owner vault.
Parameters:
- amount: Amount to claim in SOL (0 = claim all)ownerKey
- : Optional - Owner's public key (defaults to SDK wallet address)
Returns: Promise - Transaction object (not signed or sent)
`typescript
const transaction = await sdk.claimOwnerFunds(1.5); // Claim 1.5 SOL, or 0 for all
const signature = await sdk.signAndSendTransaction(transaction, wallet, 300000);
`
Owners can create discount packages to offer bulk bid purchases at reduced prices.
#### createBidPackage(packageId: string, bidCount: number, discountedPrice: number, ownerKey: PublicKey)
Build a transaction to create a bid package with a discount.
Parameters:
- packageId: Unique package identifier (max 50 characters)bidCount
- : Number of bids in the packagediscountedPrice
- : Discounted price in SOLownerKey
- : Owner's public key
Returns: Promise - Transaction object (not signed or sent)
Note: The original price is automatically calculated based on the owner's regular bid price.
`typescript
const transaction = await sdk.createBidPackage(
"package-1",
1000, // 1000 bids
0.85, // 0.85 SOL (discounted from regular price)
ownerPublicKey
);
const signature = await sdk.signAndSendTransaction(transaction, wallet, 300000);
`
#### updateBidPackage(packageId: string, ownerKey: PublicKey, bidCount?: number, discountedPrice?: number, isActive?: boolean)
Build a transaction to update an existing bid package.
Parameters:
- packageId: Package identifierownerKey
- : Owner's public keybidCount
- : Optional - New bid countdiscountedPrice
- : Optional - New discounted price in SOLisActive
- : Optional - Whether the package is active
Returns: Promise - Transaction object (not signed or sent)
`typescript
const transaction = await sdk.updateBidPackage(
"package-1",
ownerPublicKey,
1000, // New bid count
0.80, // New discounted price
true // Active status
);
const signature = await sdk.signAndSendTransaction(transaction, wallet, 300000);
`
#### getBidPackage(ownerKey: PublicKey, packageId: string)
Get bid package data.
Parameters:
- ownerKey: Owner's public keypackageId
- : Package identifier
Returns: Bid package data or null if not found
`typescriptPackage: ${package.bidCount} bids for ${package.discountedPrice} SOL
const package = await sdk.getBidPackage(ownerPublicKey, "package-1");
console.log();Original price: ${package.originalPrice} SOL
console.log();Active: ${package.isActive}
console.log();`
#### getAllBidPackages(ownerKey: PublicKey)
Get all bid packages for a specific owner.
Parameters:
- ownerKey: Owner's public key
Returns: Array of all bid packages
`typescript${pkg.packageId}: ${pkg.bidCount} bids for ${pkg.discountedPrice} SOL
const packages = await sdk.getAllBidPackages(ownerPublicKey);
packages.forEach((pkg) => {
console.log();`
});
#### getActiveBidPackages(ownerKey: PublicKey)
Get all active bid packages for a specific owner.
Parameters:
- ownerKey: Owner's public key
Returns: Array of active bid packages
`typescript`
const activePackages = await sdk.getActiveBidPackages(ownerPublicKey);
#### initialize(authority: PublicKey, feePercentage: number)
Build a transaction to initialize the contract.
Parameters:
- authority: Authority public keyfeePercentage
- : Fee percentage (0-100)
Returns: Promise - Transaction object (not signed or sent)
`typescript
const transaction = await sdk.initialize(authorityPublicKey, 5); // 5% fee
const signature = await sdk.signAndSendTransaction(transaction, wallet, 300000);
`
#### updateConfig(newAuthority?: PublicKey | null, newFeePercentage?: number | null)
Build a transaction to update contract configuration.
Parameters:
- newAuthority: Optional - New authority public key (null to keep current)newFeePercentage
- : Optional - New fee percentage (0-100, null to keep current)
Returns: Promise - Transaction object (not signed or sent)
`typescript
const transaction = await sdk.updateConfig(
newAuthorityPublicKey, // or null to keep current
6 // or null to keep current
);
const signature = await sdk.signAndSendTransaction(transaction, wallet, 300000);
`
#### emergencyPause(paused: boolean)
Build a transaction to emergency pause/unpause the contract.
Parameters:
- paused: Whether to pause (true) or unpause (false)
Returns: Promise - Transaction object (not signed or sent)
`typescript
const transaction = await sdk.emergencyPause(true); // Pause contract
const signature = await sdk.signAndSendTransaction(transaction, wallet, 300000);
`
#### claimAdminFees(amount: number)
Build a transaction to claim admin fees.
Parameters:
- amount: Amount to claim in SOL (0 = claim all)
Returns: Promise - Transaction object (not signed or sent)
`typescript
const transaction = await sdk.claimAdminFees(0); // Claim all admin fees
const signature = await sdk.signAndSendTransaction(transaction, wallet, 300000);
`
#### getConfig()
Get contract configuration.
Returns: Config account data or null if not found
`typescript`
const config = await sdk.getConfig();
console.log("Fee percentage:", config.feePercentage);
console.log("Authority:", config.authority.toString());
console.log("Paused:", config.paused);
#### getAdminFeeVaultBalance()
Get admin fee vault balance in SOL.
Returns: Balance in SOL
`typescriptAdmin fee vault balance: ${balance} SOL
const balance = await sdk.getAdminFeeVaultBalance();
console.log();`
#### signAndSendTransaction(transaction: Transaction, wallet: WalletInterface, priorityFeeMicroLamports?: number, options?: TransactionOptions)
Sign, send, and confirm a transaction with priority fee.
Parameters:
- transaction: Transaction object to sign and sendwallet
- : Wallet interface with publicKey and signTransaction methodpriorityFeeMicroLamports
- : Priority fee in micro-lamports (default: 300000)options
- : Optional transaction options (skipPreflight, commitment)
Returns: Promise - Transaction signature
`typescript`
const signature = await sdk.signAndSendTransaction(
transaction,
wallet,
300000, // Priority fee
{ skipPreflight: false }
);
The SDK also exports utility functions:
`typescript
import {
// PDA helpers
getConfigPDA,
getOwnerPDA,
getProductPDA,
getAuctionPDA,
getUserPDA,
getBidPDA,
getBidPackagePDA,
getOwnerVaultPDA,
getAdminFeeVaultPDA,
getEscrowTokenAccountPDA,
getEscrowAuthorityPDA,
// ID generators
generateProductId,
generateAuctionId,
generateBidId,
// Conversions
solToLamports,
lamportsToSol,
// Asset detection
detectAssetType,
detectTokenProgram,
detectPNFT,
detectCoreNFT,
TOKEN_2022_PROGRAM_ID,
TOKEN_METADATA_PROGRAM_ID,
MPL_CORE_PROGRAM_ID,
AssetInfo,
} from "@solbids/layer2-sdk";
`
`typescript
import { SolbidsSDK } from "@solbids/layer2-sdk";
import { Connection, PublicKey } from "@solana/web3.js";
const connection = new Connection("https://api.devnet.solana.com");
const sdk = new SolbidsSDK(connection, walletAddress);
// 1. Buy bids from a platform
const ownerPublicKey = new PublicKey("..."); // Platform owner's public key
const buyBidsTx = await sdk.buyBids(20, ownerPublicKey);
const buyBidsSig = await sdk.signAndSendTransaction(buyBidsTx, wallet, 300000);
// 2. Check balance
const balance = await sdk.getBidBalance(ownerPublicKey);
console.log(You have ${balance} bids);
// 3. Place bid on auction
const auctionCreator = new PublicKey("...");
const placeBidTx = await sdk.placeBid(auctionCreator, "auction-1", 5);
const placeBidSig = await sdk.signAndSendTransaction(
placeBidTx,
wallet,
300000
);
// 4. Check auction status
const auction = await sdk.getAuction(auctionCreator, "auction-1");
console.log("Current highest bid:", auction.highestBid.toString());
// 5. Optionally, buy now if available
if (auction.buyNowPrice && auction.buyNowPrice > 0) {
const buyNowTx = await sdk.buyNow(auctionCreator, "auction-1", assetMint);
const buyNowSig = await sdk.signAndSendTransaction(buyNowTx, wallet, 300000);
}
// 6. If you win, claim the asset
if (auction.winner?.equals(walletAddress)) {
const claimTx = await sdk.claimAsset(auctionCreator, "auction-1", assetMint);
const claimSig = await sdk.signAndSendTransaction(claimTx, wallet, 300000);
}
`
`typescript
import { SolbidsSDK } from "@solbids/layer2-sdk";
import { Connection, PublicKey } from "@solana/web3.js";
const connection = new Connection("https://api.devnet.solana.com");
const sdk = new SolbidsSDK(connection, walletAddress);
// 1. Create a product
const createProductTx = await sdk.createProduct(
"product-1",
"My NFT",
"A cool NFT",
["https://example.com/image.jpg"],
"Art",
["digital", "art"],
JSON.stringify({ collection: "My Collection" })
);
const productSig = await sdk.signAndSendTransaction(
createProductTx,
wallet,
300000
);
// 2. Create an auction (auto-detects asset type)
const assetMint = new PublicKey("..."); // Your NFT mint address
const createAuctionTx = await sdk.createAuction(
"auction-1",
"product-1",
walletAddress, // Product creator
new Date(Date.now() + 60000), // Start in 1 minute
new Date(Date.now() + 3600000), // End in 1 hour
1.0, // Starting price: 1 SOL
0.1, // Bid increment: 0.1 SOL
60, // Time extension: 60 seconds
assetMint,
1, // Asset amount (1 for NFTs)
0.5, // Reserve price (optional)
10.0 // Buy now price (optional)
);
const auctionSig = await sdk.signAndSendTransaction(
createAuctionTx,
wallet,
300000
);
// 3. Start the auction (optional - auction will auto-activate at start_time)
const startTx = await sdk.startAuction(walletAddress, "auction-1");
const startSig = await sdk.signAndSendTransaction(startTx, wallet, 300000);
`
`typescript
import { detectAssetType, AssetInfo } from "@solbids/layer2-sdk";
const assetMint = new PublicKey("...");
const assetInfo: AssetInfo = await detectAssetType(connection, assetMint);
console.log("Asset type:", assetInfo.type); // 'standard' | 'token2022' | 'pnft' | 'core_nft'
console.log("Is NFT:", assetInfo.isNFT);
console.log("Is Token-2022:", assetInfo.isToken2022);
console.log("Is pNFT:", assetInfo.isPNFT);
console.log("Is Core NFT:", assetInfo.isCoreNFT);
if (assetInfo.isPNFT) {
console.log("Metadata:", assetInfo.metadata?.toString());
console.log("Edition:", assetInfo.edition?.toString());
}
`
The SDK supports all Solana asset types:
- Standard SPL Token - Regular fungible tokens and NFTs
- SPL Token-2022 - Enhanced token program with additional features
- pNFT (Programmable NFT) - NFTs with royalties and programmable features
- MPL Core NFT - Metaplex Core NFTs
All methods automatically detect the asset type and use the appropriate contract method. The SDK handles all asset type detection internally - you only need to use the main methods (createAuction(), claimAsset(), withdrawAsset(), buyNow()).
Core Methods (Auto-detect asset type):
- buyBids() - Purchase bid credits at regular pricebuyBidsWithPackage()
- - Purchase bid credits using discount packageregisterOwner()
- - Register as platform ownerupdateOwner()
- - Update owner informationcreateProduct()
- - Create a productupdateProduct()
- - Update product informationdeactivateProduct()
- - Deactivate a productcreateAuction()
- - Create auction (auto-detects asset type: Standard, Token-2022, pNFT, or Core NFT)createAuctionStandard()
- - Create standard token auction (explicit method)createAuctionPNFT()
- - Create pNFT auction (explicit method)createAuctionCoreNFT()
- - Create Core NFT auction (explicit method)startAuction()
- - Start/activate an auctionendAuction()
- - End an auctionplaceBid()
- - Place bids on an auctionbuyNow()
- - Buy asset at buy-now price (auto-detects asset type)claimAsset()
- - Claim asset as winner (auto-detects asset type)withdrawAsset()
- - Withdraw asset back to creator (auto-detects asset type)claimOwnerFunds()
- - Claim funds from owner vaultclaimAdminFees()
- - Claim admin feesinitialize()
- - Initialize the contractupdateConfig()
- - Update contract configurationemergencyPause()
- - Pause/unpause the contractcreateBidPackage()
- - Create discount bid packageupdateBidPackage()
- - Update bid package
Note: The main methods (createAuction(), claimAsset(), withdrawAsset(), buyNow()) automatically detect asset type. Use the explicit methods (createAuctionStandard(), createAuctionPNFT(), createAuctionCoreNFT()) only if you need explicit control over the asset type.
- getConfig() - Get contract configurationgetOwner()
- - Get owner account datagetAllOwners()
- - Get all ownersgetUser()
- - Get user account datagetBidBalance()
- - Get user's bid balancegetOwnerVaultBalance()
- - Get owner vault balancegetAdminFeeVaultBalance()
- - Get admin fee vault balancegetProduct()
- - Get product datagetAllProducts()
- - Get all productsgetAuction()
- - Get auction datagetAllAuctions()
- - Get all auctionsgetBidPackage()
- - Get bid package datagetAllBidPackages()
- - Get all bid packages for an ownergetActiveBidPackages()
- - Get active bid packages for an owner
Total: 41 methods - Complete coverage of all contract functionality
Note: The main public API focuses on auto-detecting methods. Specific asset type methods (like claimAssetPNFT, withdrawAssetPNFT`, etc.) are internal and not part of the public API.
Current version: 3.1.0
This version includes:
- All contract methods fully implemented (41 total)
- Bid package system with discount pricing
- Support for all asset types (Standard, Token-2022, pNFT, Core NFT)
- Automatic asset type detection in main methods
- Simplified public API - only main auto-detect methods exposed
- Complete query methods for all account types
- Full TypeScript support
MIT