📜 [專欄新文章] Gas Efficient Card Drawing in Solidity
✍️ Ping Chen
📥 歡迎投稿: https://medium.com/taipei-ethereum-meetup #徵技術分享文 #使用心得 #教學文 #medium
Assign random numbers as the index of newly minted NFTs
Scenario
The fun of generative art NFT projects depends on randomness. The industry standard is “blind box”, where both the images’ serial number and the NFTs’ index are predetermined but will be shifted randomly when the selling period ends. (They call it “reveal”) This approach effectively solves the randomness issue. However, it also requires buyers to wait until the campaign terminates. What if buyers want to know the exact card right away? We’ll need a reliable onchain card drawing solution.
The creator of Astrogator🐊 isn’t a fan of blind boxes; instead, it thinks unpacking cards right after purchase is more interesting.
Spec
When initializing this NFT contract, the creator will determine the total supply of it. And there will be an iterable function that is randomly picking a number from the remaining pool. The number must be in range and must not collide with any existing ones.
Our top priority is accessibility/gas efficiency. Given that gas cost on Ethereum is damn high nowadays, we need an elegant algorithm to control gas expanse at an acceptable range.
Achieving robust randomness isn’t the primary goal here. We assume there’s no strong financial incentive to cheat, so the RNG isn’t specified. Implementers can bring their own source of randomness that they think is good enough.
Implementation
Overview
The implementation is pretty short and straightforward. Imagine there’s an array that contains all remaining(unsold) cards. When drawIndex() is called, it generates a (uniform) random seed to draw a card from the array, shortens the array, and returns the selected card.
Algorithm
Drawing X cards from a deck with the same X amount of cards is equal to shuffling the deck and dealing them sequentially. It’s not a surprise that our algorithm is similar to random shuffling, and the only difference is turning that classic algo into an interactive version.
A typical random shuffle looks like this: for an array with N elements, you randomly pick a number i in (0,N), swap array[0] and array[i], then choose another number i in (1,N), swap array[1] and array[i], and so on. Eventually, you’ll get a mathematically random array in O(N) time.
So, the concept of our random card dealing is the same. When a user mints a new card, the smart contract picks a number in the array as NFT index, then grabs a number from the tail to fill the vacancy, in order to keep the array continuous.
Tweak
Furthermore, as long as the space of the NFT index is known, we don’t need to declare/initialize an array(which is super gas-intensive). Instead, assume there’s such an array that the n-th element is n, we don’t actually initialize it (so it is an array only contains “0”) until the rule is broken.
For the convenience of explanation, let’s call that mapping cache. If cache[i] is empty, it should be interpreted as i instead of 0. On the other hand, when a number is chosen and used, we’ll need to fill it up with another unused number. An intuitive method is to pick a number from the end of the array, since the length of the array is going to decrease by 1.
By doing so, the gas cost in the worst-case scenario is bound to be constant.
Performance and limitation
Comparing with the normal ascending index NFT minting, our random NFT implementation requires two extra SSTORE and one extra SLOAD, which cost 12600 ~ 27600 (5000+20000+2600) excess gas per token minted.
Theoretically, any instantly generated onchain random number is vulnerable. We can restrict contract interaction to mitigate risk. The mitigation is far from perfect, but it is the tradeoff that we have to accept.
ping.eth
Gas Efficient Card Drawing in Solidity was originally published in Taipei Ethereum Meetup on Medium, where people are continuing the conversation by highlighting and responding to this story.
👏 歡迎轉載分享鼓掌
同時也有155部Youtube影片,追蹤數超過89萬的網紅PAPAYA 電腦教室,也在其Youtube影片中提到,► 內容綱要 00:00 開場白 02:06 修改中文顯示問題 02:34 簡報背景與標題設定 03:41 新增 Topic (主題) 05:04 子標題版面配置 06:20 動畫路徑設定 07:06 將 PPT 簡報轉成 Prezi 09:07 堆疊式簡報 10:54 Story Blocks 圖...
「story elements」的推薦目錄:
- 關於story elements 在 Taipei Ethereum Meetup Facebook 的精選貼文
- 關於story elements 在 Jessie Chung锺潔希 Facebook 的最佳貼文
- 關於story elements 在 WE5 - Shibaland Facebook 的精選貼文
- 關於story elements 在 PAPAYA 電腦教室 Youtube 的精選貼文
- 關於story elements 在 ウマヅラビデオ Youtube 的最佳解答
- 關於story elements 在 Square Enix Youtube 的精選貼文
- 關於story elements 在 Story Elements Part 1: Characters, Setting, and Events 的評價
- 關於story elements 在 Story Elements for Kids: What Is a Setting? - YouTube 的評價
- 關於story elements 在 Story Elements- Teaching Tips | Reading anchor charts ... 的評價
story elements 在 Jessie Chung锺潔希 Facebook 的最佳貼文
小帮手:
【云剧场🤩线上观剧】✨✨✨
✨Cloud Theatre, enjoy theatre online!✨
🌟星音符为您诚意打造《红楼梦》话剧,根据史实与原著改编
——让您深刻体验古典名著的艺术魅力🤩13场演出场场满座,好评如潮!
💝演出购票处 Cloud Theatre :
https://www.cloudtheatre.com/my/shows/the-bream-of-red-mansions/
此次在云剧场上演,票券收入100%捐作抗疫物资❤️
🌹中国古代四大名著之首《红楼梦》话剧🌹
💥必看10大重点💥
✨《红楼梦》在大马首度以话剧演出
✨《红楼梦》根据史实和原著改编
✨知名艺人锺洁希与多位资深演员同台,演员阵容多达26人
✨男主角为全球万里挑一的林霆坚,为寻找贾宝玉剧组发动了全球《寻找贾宝玉》的活动
✨最新3D科技绝美LED背景视觉影像
✨星音符特邀美籍音乐制作人为《红楼梦》话剧操刀,由女主角锺洁希演唱插曲《黑夜将残的炉光》,并与男主角林霆坚深情对唱主题曲《心念》
✨逼真的音效与专业背景音乐配搭
✨精致的古风道具布置
✨精美雅致大气有诚意的古代服装
✨《红楼梦》话剧票券收入100%捐作抗疫物资
🌷由锺洁希领衔主演女主角——出淤泥而不染的林黛玉,💘男主角为全球万里挑一,犹如贾宝玉再现的——林霆坚。为您演绎一场刻骨铭心、至真至爱、荡气回肠的爱情故事❤
📅演出日期:
🤩『第一场』18/09/2021 (六) 8:00p.m. (GMT+8) 【供48小时内观看】
🤩『第二场』27/09/2021 (一) 8:00p.m. (GMT+8) 【供48小时内观看】
🗨 [ 此剧语言为中文,备有中英文字幕]
📲【询问联络】03-55690139 (Ann) https://bit.ly/3yyzYJk
《红楼梦》话剧——谁为情种?
❤眼空蓄泪泪空垂,暗洒闲抛却为谁~
Cloud Theatre, enjoy theatre online! ✨✨✨
The play “The Dream of Red Mansions” was met with overwhelming response, selling out tickets to 13 full houses!
Ticketing platform: Cloud Theatre
https://www.cloudtheatre.com/my/shows/the-bream-of-red-mansions/
🤩100% of the proceeds from the tickets will be donated as Covid-19 medical supplies. Together, let’s do our part and show our love!
🌹 “The Dream of Red Mansions”, an adaptation of the most celebrated classical Chinese novel! 🌹
💥10 reasons why you must watch: 💥
✨This marks the first public performance of the stage play “The Dream of Red Mansions” in Malaysia.
✨ “The Dream of Red Mansions” is based on the original historical novel.
✨Well-known artist Jessie Chung takes the stage with 26 experienced actors.
✨Lead actor Terry Lim, a one-in-a-million actor who portrays Jia Baoyu, was chosen through a worldwide search for a Jia Baoyu lookalike.
✨Stage backdrops created through the latest 3D technology for stunning, lifelike environments.
✨Symphony Theatre invited an American composer to create the soundtrack for “The Dream of Red Mansions,” while lead actress Jessie Chung performed the soundtrack song “A Dying Light in the Dark” and the theme song, “Hearts Apart”—an emotional duet—with lead actor Terry Lim.
✨Accompanied by realistic sound effects and professional background music.
✨Stage design incorporates exquisite ancient Chinese elements and props.
✨Actors wear elegant, refined, majestic and authentic period costumes.
✨100% of the proceeds from the tickets will be donated as Covid-19 medical supplies. Together, let’s do our part and show our love!
🌷Jessie Chung takes the stage as lead actress, portraying the pure and unadulterated Lin Daiyu, while Terry Lim, the lead actor, was chosen out of a ton of applicants from around the world. Come and enjoy a performance of an unforgettable, passionate, and heart-rending love story.
📅Performance Dates:
🤩 First performance:
Saturday, September 18, 2021, 8:00 p.m. (GMT+8)
🤩 Second performance:
Monday, September 27, 2021, 8:00 p.m. (GMT+8)
🗨 (Performed in Mandarin, with Mandarin and English subtitles available.)
📲 Contact us: 03-55690139 (Ann) https://bit.ly/3yyzYJk
“The Dream of Red Mansions,” calling all lovers…❤
“Vain are all these idle tears, tears shed secretly—for whom?”
story elements 在 WE5 - Shibaland Facebook 的精選貼文
WE5 ONLINE STORY BOOK 2021-
P.10 Around June or July 2010, 🐷🐷🐷🐷 finally finished their vaccinations and could do walks with Papa & Mama! We often paid visits to the doggy park located next to the Sheung Wan promenade and made a lot of furry friends there!
.
In October 2010 I eventually got a new job, as Assistant Manager in an Italian Restaurant in Elements. The Italian Restaurant Manager liked my professionals very much, but my salary range had reached the company limit and he knew I have difficulties for livings, therefore he paid me extra from his own pocket. Thank you Sir!
.
P.10 差不多在2010年的年中,🐷🐷🐷🐷終於打齊預防針,可以跟阿豬爸、阿豬媽一起外出散步!以前經常到家附近的上環海濱狗狗公園放空,也認識到很多朋友仔!但之後再搬屋後就沒有再去過了。
.
在2010年的10月終於找到公作,在圓方的一家意大利餐廳當副經理。因為當時我的薪酬已經是餐廳可以給予的上限,而意大利經理很賞識我且知道我有困難,所以他每個月自己掏荷包補貼我,感激🙇🏻♂️
🤠
.
大家記得戴口罩😷勤洗手🤲🏻🚿留家抗疫💪🏻
Stay Home Stay Safe & Healthy & Happy!
Wear Mask 😷 Wash Ur Hands 🤲🏻🚿
🤠
*拍照前請先打招呼詢問一下哦
*拍照前請先注意交通安全哦
*狗狗上廁所時請不要拍照哦
*我清理和拿著狗狗便便時請不要拍照哦
*摸狗狗前請先問一下
*我們鼓勵人與人之間應該多聯繫
*打個招呼拍拍照何樂而不為
*PleaseGreet&AskBeforeYouSnap
*PleasePayAttentionToTrafficBeforeYouSnap
*PleaseDoNotSnapWhenDoggiesPeeAndPoo
*PleaseDoNotSnapWhenAmCleaningAndCarryingTheirPoops
*PleaseAskBeforeYouPat
*WeEncourageHumanEngagement
*NothingToLooseToSayHi
🤠
#WE5 #Shibaland #Shibainus #shibas #ShibaGang #GrandpaDogTraining #Grandpa狗噏 #DogTraining #MutualRespect #WE5ShibaFamily
#多尊重少包容 #文明旅遊 #柴犬 #HKShibas #ShibaFamily
#HKShibas #柴犬香港
#DiscoverHongKong #DogsofInstagram #DogPhotography #WE5Story
#GrandpaPhotoGraphy
#LoveWillKeepUsTogether
#只要不投降就是成功 #不要棄養 #AwesomeHongKong @hk_dog_owners
story elements 在 PAPAYA 電腦教室 Youtube 的精選貼文
► 內容綱要
00:00 開場白
02:06 修改中文顯示問題
02:34 簡報背景與標題設定
03:41 新增 Topic (主題)
05:04 子標題版面配置
06:20 動畫路徑設定
07:06 將 PPT 簡報轉成 Prezi
09:07 堆疊式簡報
10:54 Story Blocks 圖形範本
12:44 簡報發布與分享
► 練習檔下載
載點一 https://tinyurl.com/yzymreu2
載點二 https://share.weiyun.com/Ll3SQoIq
► 影片中操作的工具連結 / 軟體版本
Prezi 官網 https://prezi.com/
► Papaya 電腦教室 - 會員專區 (加入後可觀看會員專區的影片喔)
加入頻道會員 https://tinyurl.com/sxt3d2b
會員專區影片目錄 https://tinyurl.com/y6mvo38a
► 小額贊助 Papaya 電腦教室
ECPay: https://p.ecpay.com.tw/A1B71E8
Paypal: https://www.buymeacoffee.com/papayaclass
► Papaya 剪輯影片所使用的軟體 / 素材來源
Camtasia Studio https://www.techsmith.com/video-editor.html
Adobe After Effects https://www.adobe.com/products/aftereffects/
Adobe Audition https://www.adobe.com/products/audition.html
Keynote https://www.apple.com/tw/keynote
Envato Elements https://elements.envato.com
Vecteezy https://www.vecteezy.com
簡報文稿:維基百科
#記得打開影片的CC字幕喔 #Prezi #簡報 #沉浸式簡報
story elements 在 ウマヅラビデオ Youtube 的最佳解答
遂に満を持してウマヅラビデオ単独書籍『シン・人類史』が発売決定!Amazonにて絶賛予約受付中!!⬇️⬇️
超古代から未来までを網羅し、全てがひとつに繋がる都市伝説本!真実は裏から見なければ見えてこない。ぜひ本書を手に取り闇に葬られた真の歴史を探求してください!↓↓↓
https://amzn.to/37BNAIm
🔥メンバーシップ『Club99』へこちらから加入できます。真実を追い求める方へ🔥
https://www.youtube.com/channel/UCvral4FSI9dOOUV-yRloawA/join
🚨否メンディーの公式LINEスタンプが完成しました!🚨https://store.line.me/stickershop/product/13067419/ja
☆ちょっとでも面白いなと思ったらチャンネル登録よろしく☆
http://youtube.com/subscription_center?add_user=umaduravideo
_____________________________________________________________________
◆メンバーのTwitter!!繋がれちゃうからね?いいね?◆
☆ウマヅラ
https://twitter.com/umaduravideo_
☆ベーコン
https://twitter.com/amuse_bacon
☆否メンディー
https://twitter.com/inainainamen
_____________________________________________________________________
※我々が話すことはあくまで都市伝説であり、実際に起きてることとは限りません。真実は皆さんで追ってください。また誹謗中傷を目的としてこの動画は制作されておりません。また使用している素材はすべて引用であり著作権を侵害する目的でこの動画を制作しておりません。
#ウマヅラビデオ #都市伝説 #ウマズラ
素材の引用URL
Adobe Stock
https://stock.adobe.com/jp/
Story Block Video
https://www.videoblocks.com/videos
Motion Elements
https://www.motionelements.com/ja/video
♩♫ Royalty Free Music - "The Last Battle" - Epic & Dramatic Action Trailer Score | No Copyright ♫♩
https://youtu.be/qvR21sKXWmA
Brand X Music - Entrada [Epic Music - Epic Vocal Driving Mysterious]
https://youtu.be/daTGZ2Y65is
Frost - HOVATOFF
https://youtu.be/AfoymNGHLxE
Arms Dealer - Anno Domini Beats
https://youtu.be/9_qCIRNn1G4?list=PLkcoF0DPnOMMnE13dWpWjz8NaL0FDDYwG
White Hats - Wayne Joneshttps://youtu.be/VcZmSNhxC4o?list=PLkcoF0DPnOMNYQ9cqIosdTMTG6ubyijvm
Music Atelier Amacha
http://amachamusic.chagasi.com/music_kurakunagaitunnel.html
DOVA-SYNDROME
https://dova-s.jp
効果音ラボ
https://soundeffect-lab.info/sound/machine/
story elements 在 Square Enix Youtube 的精選貼文
The original FINAL FANTASY IV comes to life with updated graphics and audio as a 2D pixel remaster!
The Kingdom of Baron sent their elite airship fleet, the Red Wings, to attack the surrounding countries. Distressed by his mission, Cecil, a dark knight and captain of the Red Wings, decides to fight against the tyrannical Baron with his trusted friend and his paramour at his side.
Witness the dramatic story and dynamic battles in this fourth installment of the FINAL FANTASY series!
Available individually or as part of a bundle on Steam.
*Full bundle will be available upon launch of FINAL FANTASY VI
*These games are newly developed remaster editions based on the original titles. Some of the changes and additional elements found in other remakes of these games are not included.
FINAL FANTASY IV pixel remaster is available now!
• Steam®: https://store.steampowered.com/app/11...
• AppStore: https://apps.apple.com/us/app/final-f...
• Google Play: https://play.google.com/store/apps/de...
• Amazon Appstore: http://www.amazon.com/dp/B09D2Y1CHH
story elements 在 Story Elements- Teaching Tips | Reading anchor charts ... 的推薦與評價
Jan 11, 2017 - Find resources for teaching story elements to kindergarten, first, second, and third grade students including books and hands-on activities. ... <看更多>
story elements 在 Story Elements Part 1: Characters, Setting, and Events 的推薦與評價
... <看更多>