Smart Contracts

ProductClank Arena uses smart contracts on Base network to manage auctions securely and transparently on-chain.

ProductClankerAuction Contract

The main auction contract handles all auction logic:

Contract Details

  • Network: Base (Ethereum L2)
  • Solidity Version: 0.8.20+
  • Token: USDC (ERC-20)
  • Standards: OpenZeppelin contracts

Key Features

  • USDC-Based Bidding: All bids in USDC
  • Configurable Duration: Default 24 hours, adjustable
  • Reserve Price: Minimum bid requirement
  • Bid Increments: Minimum percentage increase
  • Time Buffer: Extends auction on late bids
  • Automatic Refunds: Previous bidders refunded when outbid
  • Whitelisted Settlers: Authorized addresses can settle
  • Pausable: Can pause in emergencies

Contract Functions

Core Functions

// Create a new auction
function createAuction(uint256 tokenId, uint256 startTime, uint256 endTime)

// Place a bid
function bid(uint256 tokenId, uint256 amount, string memory campaignId, string memory name)

// Settle an auction
function settleAuction(uint256 tokenId)

// Get auction details
function getAuction(uint256 tokenId) returns (Auction memory)

Admin Functions

// Update auction duration
function setDuration(uint40 duration)

// Update reserve price
function setReservePrice(uint256 reservePrice)

// Update min bid increment
function setMinBidIncrementPercentage(uint8 percentage)

// Update time buffer
function setTimeBuffer(uint40 timeBuffer)

// Pause/unpause contract
function pause()
function unpause()

Contract Security

Security Features

  • ReentrancyGuard: Prevents reentrancy attacks
  • Ownable: Only owner can update parameters
  • Pausable: Can pause in case of emergency
  • SafeMath: Safe arithmetic operations
  • Access Control: Whitelisted settlers for settlement

Bid Validation

  • Bid must exceed current highest bid
  • Bid must meet minimum increment
  • Bidder must have sufficient USDC balance
  • Bidder must have approved contract spending
  • Auction must be active

Events

event AuctionCreated(uint256 tokenId, uint256 startTime, uint256 endTime);
event AuctionBid(uint256 tokenId, address bidder, uint256 amount, bool extended, uint256 endTime, string campaignId, string name);
event AuctionSettled(uint256 tokenId, address winner, uint256 amount, string campaignId, string name);
event DurationUpdated(uint256 duration);
event ReservePriceUpdated(uint256 reservePrice);

Interacting with the Contract

Using wagmi/viem

import { useWriteContract, useWaitForTransactionReceipt } from 'wagmi'
import { parseUnits } from 'viem'

// Approve USDC spending
const { writeContract: approve } = useWriteContract()

await approve({
  address: USDC_ADDRESS,
  abi: erc20Abi,
  functionName: 'approve',
  args: [AUCTION_CONTRACT_ADDRESS, parseUnits('1000', 6)]
})

// Place a bid
const { writeContract: bid } = useWriteContract()

await bid({
  address: AUCTION_CONTRACT_ADDRESS,
  abi: auctionAbi,
  functionName: 'bid',
  args: [tokenId, bidAmount, campaignId, bidderName]
})

Contract Storage

The contract uses structured storage:

  • Auction Storage: Auction data structure
  • Settings: Configurable parameters
  • Bidder Names: Mapping of addresses to names
  • Whitelist: Authorized settler addresses

Deployment

Contract deployment process:

  1. Compile contract with Solidity compiler
  2. Deploy to Base network
  3. Verify contract on block explorer
  4. Initialize with settings (duration, reserve price, etc.)
  5. Set treasury and USDC token address
  6. Add whitelisted settlers

Contract Addresses

Note: Contract addresses are network-specific. Check the deployment documentation for current addresses on Base mainnet and testnet.