Skip to content

Instantly share code, notes, and snippets.

@yubrew
Created June 13, 2022 20:18
Show Gist options
  • Save yubrew/3fa1375fe9b2e2193a1b4ba7783e85f0 to your computer and use it in GitHub Desktop.
Save yubrew/3fa1375fe9b2e2193a1b4ba7783e85f0 to your computer and use it in GitHub Desktop.
Generate `nft_metadata_gen` metadata files. Creates weighted rarity metadata files ready for upload
# create Stargaze Austin POAP NFT
require 'json'
starting_number = 1
# declare all attributes and variations
attributes = [
"food_and_drink",
"landmark",
"activity",
]
food_and_drink = {
'Crispy fried gulf oysters': 0.05,
'Buttermilk biscuits':0.05,
'Cowboy ribeye': 0.1,
'Tomahawk ribeye': 0.05,
'Franklin bbq brisket': 0.125,
'Avocado margarita': 0.02,
'Real deal holyfield':0.005,
'Migas at trudys':0.005,
'Cochinita pibil':0.005,
'Jalapeño kolaches': 0.005,
'Josies enchiladas': 0.02,
'Chicken fried steak': 0.1,
'Dinosaur ribs':0.1,
'Pulled pork':0.05,
'Chili con carne':0.05,
'Texas chili':0.025,
'Filet mignon':0.025,
'Cheeseburger':0.05,
'Frito pie':0.005,
'Glazed donuts':0.05,
'Frozen custard':0.05,
'Whiskey': 0.01,
'Uchi': 0.005,
'Valentinas':0.005,
'P Terrys':0.005,
'Round Rock Donuts':0.005,
'LA BBQ': 0,005,
}
sights = {
'Mount Bonnell':50,
'The Driskill':50,
'Congress Ave Bridge': 50,
'The Ritz Building': 50,
'South Congress Ave': 50,
'I Love You So Much': 50,
'Circuit of the Americas': 50,
'Treaty Oak': 50,
'Victory Grill':50,
'Barton Springs': 50,
'Green Pastures': 50,
'Laguna Gloria': 50,
'Moonlight towers': 50,
'Royal Arch Masonic Lodge': 50,
'360 Bridge': 50,
'UT Austin Tower': 50,
'Texas State Capital': 50,
'Watermelon Island': 50,
'Snake Island': 50,
'Cathedral of Junk': 50,
'Umlauf Skulptur Garden': 50,
'Harry Ransom Center': 50,
}
activity = {
'Trading NFTs':50,
'Watching Marketplace Trades':50,
'Checking Collection Floor':30,
'Prepping NFT Collection For Launch':1,
'Chilling By The Pool':50,
'Refresh Party Gdoc':100,
'Stargazing':5,
'Eating':50,
'Drinking':50,
'Conversating':50,
'Chillin':30,
'Relaxing':30,
'Melting':5,
'Making New Friends':50,
'Doing bad kid stuff':15,
'Repping Stargaze Punks':15,
'Cryptotwitter':40,
'Discord':40,
'Telegram':20,
'Checking crypto':25,
'Building something cool':10,
'Bat watching':10,
'Waiting in line':10,
'Concert on Red River':10,
'SXSW':5,
}
image = {
'ipfs://bafybeidl57fjmtz2gi2yv3y2gjtluvejmzjyynwhurv5usxv6rkhwprouy/1.png':1,
'ipfs://bafybeidl57fjmtz2gi2yv3y2gjtluvejmzjyynwhurv5usxv6rkhwprouy/2.png':1,
}
# output json per metadata entry
# wrs = -> { food_and_drink.max_by { |_, weight| rand ** (1.0/weight) }.first }
food_wrs = -> { food_and_drink.max_by { |_, weight| rand ** (food_and_drink.values.sum/weight) }.first }
sights_wrs = -> { sights.max_by { |_, weight| rand ** (sights.values.sum/weight) }.first }
activity_wrs = -> { activity.max_by { |_, weight| rand ** (activity.values.sum/weight) }.first }
image_wrs = -> { image.max_by { |_, weight| rand ** (image.values.sum/weight) }.first }
2_000.times.each_with_index{|i|
tempH = {
"name"=>"Stargaze Austin POAP##{i+1}",
"location"=>"Austin, TX",
"date"=>"2022-06-09 to 2022-06-10",
"image"=> image_wrs.call.to_s,
"attributes" =>[
{"trait_type"=>"food_and_drink","value"=>food_wrs.call.to_s},
{"trait_type"=>"landmark","value"=>sights_wrs.call.to_s},
{"trait_type"=>"activity","value"=>activity_wrs.call.to_s},
]
}
# p tempH.to_json
File.open("metadata/#{i+1}", 'w') do |f|
f.write(tempH.to_json)
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment