Panda RAFFLE 🐼

Panda Raffles take place on the 16th of every month. Each Panda HODL owned will be the equivalent of one ticket in the raffle. Tickets will then be weighted by the length of time the owner has owned the NFT. The winner picking code can be found here.

July

Rekt Chicken #4146
Floor 680 STARS

June

Cryptonium #1270
Floor 3.2K STARS

May

Chilled Kids #2121
Floor 985 STARS

Past winners

DATE $STARS address NFT
July 2024 Rekt Chicken #4146
June 2024 arc.stars Cryptonium #1270
May 2024 massive-membrane.stars Chilled Kids #2121

Google sheet winner picker code:


function pickWeightedWinner() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  const dataRange = sheet.getDataRange();
  const values = dataRange.getValues();
  
  let weights = [];
  const now = new Date();

  for (let i = 1; i < values.length; i++) {
    const entryDate = new Date(values[i][0]);
    const ageDays = (now - entryDate) / (1000 * 60 * 60 * 24);
    const weight = Math.max(1, ageDays);
    weights.push(weight);
  }
  
  const winnerIndex = weightedRandomSelect(weights) + 1;
  Logger.log(`The winner is: ${values[winnerIndex][1]}`);
  sheet.getRange('Z1').setValue(`Winner: ${values[winnerIndex][1]}`);
}

function weightedRandomSelect(weights) {
  const totalWeight = weights.reduce((a, b) => a + b, 0);
  let threshold = Math.random() * totalWeight;
  
  for (let i = 0; i < weights.length; i++) {
    threshold -= weights[i];
    if (threshold <= 0) return i;
  }
  
  return -1; // Should not reach here
}