📜 [專欄新文章] 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.
👏 歡迎轉載分享鼓掌
同時也有99部Youtube影片,追蹤數超過1萬的網紅KAOHAOCHE Official,也在其Youtube影片中提到,Next K-HOW Album "ZENWAVE" 2021.02.28.SUN. _____________【ZENWAVE】_____________ 專輯製作人 Producer|高浩哲 Kaohaoche 詞曲 Lyricist & Composer|高浩哲 Kaohaoche 編曲 A...
「what is concept art」的推薦目錄:
- 關於what is concept art 在 Taipei Ethereum Meetup Facebook 的最讚貼文
- 關於what is concept art 在 Kiri T Facebook 的精選貼文
- 關於what is concept art 在 Benny Price Fitness Facebook 的最讚貼文
- 關於what is concept art 在 KAOHAOCHE Official Youtube 的最佳貼文
- 關於what is concept art 在 Goresh Youtube 的精選貼文
- 關於what is concept art 在 每天簡單說泰語 Youtube 的最佳解答
what is concept art 在 Kiri T Facebook 的精選貼文
// Medication’s on the shelf
I could use a little help. //
icouldusealittlehelp is one of my personal favourites from Chili T 🌶 . Thanks to @ialannaoj for this concept shoot, and your love and respect for art.
What I wanna say in the song is, I’m not as strong as I’d like to be, I’m too weak to fight my inhibitions, sometimes Im silent when I need to be loud, and I think staying sane is a full time job. I love life, that’s why I hate it so much, does it make sense?
Photographer & Art Director: @ialannaoj
Photo Assistant: @sk.alison
MUA: @makeup_societyxx
Hairstylist: @sing__428
Stylist: @sci_fi_c0c0
Floral: @hanseflower
#chilit
#icouldusealittlehelp co-written by @thedanielchu
Produced by 4AM - @hirsk_ , @thedanielchu and yours truly.
what is concept art 在 Benny Price Fitness Facebook 的最讚貼文
Used this as a reminder to myself today 🧘♂️
-
Many of us use the gym as a way to compensate for an entire day of moving less than we’re meant to by condensing that physical stress into an hour ⏱
-
What few consider is that we also lead considerably more psychologically stressful lives than we’re meant to 😣 and we rarely give ourselves any peace by choice.
—
Caveperson stress factors:
- We’re low on dead animal 🥩
- I’ve lost my cavechild 👶
- There’s a leak in my bamboo roof💧
- Another caveperson is staring at my cavepersons jugs 👀
—
What cavepeople did 90% of the time between killing things or shouting at another pervy caveperson:
- Stare at sky ⛅️
- Stare at birds 🦜
- Stare at another cavepersons jugs 👀
—
Modern stress factors:
- To-Do Lists 📋
- Job Security 💻
- Bills 💸
- Making sure family members have their shit together 🗓
- Trying to remember all 2,000 Facebook friends 🗣
- Trying to remember all 2,000 industry colleagues 👥
- Comparing one’s own life to those on instagram 🏖
- Making sure one’s own life looks good on instagram 😎
- Not getting covid 🤒
- Societal / Parental expectations 😈
- Trying to work out what your cavepartner wants to order from foodpanda tonight 💁♀️
—
What modern people do 90% of the time when they’re not working or in social situations:
- 📲 Scroll through our phone looking for dopamine hits or watch Netflix for a laugh, a thrill or a cry. 😂😱😭 We shove content into our minds for fear of being left with our own thoughts for more than 5 minutes 🤔
—
I’m not a psychologist, but I could talk about the logical benefits of and the reasons to meditate for 3-4 posts. I might just 🤷🏻♂️ ... it’s slightly out of my lane, but I believe in it and I don’t believe enough people package it how I’d want to hear it. For now let’s keep the concept simple.
—
We go to the gym because our days don’t consist of sufficient physical stress. Why wouldn’t we meditate to moderate the excessive levels of psychological stress we’re under? 💆🏻♂️
—
🕰 Make the time. Take your mind to the gym. Train it in the art of thinking about one thing, and let it relax from the other 37 that affect your contentment ☺️
what is concept art 在 KAOHAOCHE Official Youtube 的最佳貼文
Next K-HOW Album "ZENWAVE"
2021.02.28.SUN.
_____________【ZENWAVE】_____________
專輯製作人 Producer|高浩哲 Kaohaoche
詞曲 Lyricist & Composer|高浩哲 Kaohaoche
編曲 Arrangement|Rollmeajointyella , Rayloloo , FORGOTTEN
錄音 Recording|高浩哲 Kaohaoche , Rayloloo
混音 Mixing|Rayloloo , DUSA
視覺設計 Art Direction|吳建龍 FKWU , 朱智顯 Goodboixian
專輯設計 Album Design|吳建龍 FKWU
3D 設計 CG Art | 朱智顯 Goodboixian
動畫導演 CG Director|朱智顯 Goodboixian
標準字設計 Logotype|鄧承忠 Johniizzz
周邊設計Peripheral Design|張傑夫 SUPIGS , 鄧承忠Johniizzz
行銷企劃 Marketing Planning|黃培華 Sunday Huang , 高浩哲 Kaohaoche
活動企劃 Event Planning|高浩哲 Kaohaoche , 黃培華 Sunday Huang , 魯光孟 About Ris
MV導演 Music Video Director|鄒舒斐 SHUFEIZOU
專輯文案 Album Copywriting|古尚恆 Ku Da Yeast
PRESENTED BY HELICREW OFFICIALS
「禪」是梵語「禪那」(ध्यान,dhyāna)的簡稱。原義是靜慮,意即至心一處、靜思觀修。禪可以說是一種基於「靜止」的行為模式。停止才能前進,留空才能增加。透過靜止的冥想,屏除雜念,人們才能鍛煉思維,進而發展智慧。
台灣陷阱饒舌霸主高浩哲K-HOW,繼2019年關注台灣當前青年世代困境的《日頭赤炎炎》專輯後,睽違一年再度推出個人第五張創作專輯《ZENWAVE》。經歷了多年的歌手生涯高低變化,高浩哲走過憤怒、悲傷、狂喜等多種情緒起伏。此次高浩哲選擇跨越外在世俗的直觀執念,以內在的「禪定」出發。不論人世間的爭奪喧噪,將自身的意念得以匯聚成流,高浩哲不再徬徨。生活也好、創作也好,順著自己的節奏即可持續前進。
《ZENWAVE》除了呈現高浩哲的心境轉變,同也體現其耕耘多年的音樂思維之躍升。除了足以代表其音樂風格的808 Trap,不論是80’s帶有Cyberpunk科幻風味的Synth Sound、國際潮流上逐漸嶄露頭角的Drill,甚至是嘗試搖滾、House等跨界曲風。他並不滿足只被定義為一線陷阱歌手。
製作團隊除了海底隊當家製作RAYLO、老夥伴電音唱作人Dusa,此張專輯更是邀來了曾編曲頑童MJ116〈幹大事〉、〈少年董〉等知名單曲,並固定與有著BRIDGE等大勢饒舌歌手的重慶嘻哈廠牌GO$H合作的台灣知名製作人ROLLMEAJOIENTYELLA參與編曲、製作。
從專輯的取樣成音、視覺設計,甚至是MV的造型美術,高浩哲皆大量挪用本土民俗文化,尤其是三太子。對他而言自己好比三太子般對抗權貴階級。為了台灣年輕世代奉獻生命,削肉還母、剔骨還父,最終對抗成功。世代間的衝突和對立,也一直是他關注的議題。
高浩哲用他一貫的暗黑風格,搭配上強而有力的專輯概念、企製團隊。無論成功與否,他早已在這條音樂的不歸路上留下屬於他的記號。
The concept of “Zen” originated from ancient Sanskrit(ध्यान,dhyāna),which means quiet down one’s mind, putting one’s heart into a singular focus. “Zen” can be interpreted as a behavioral pattern based on “tranquility”. One can only move forward by slowing down and earn more by empting out. Through the meditation of tranquility, erasing all the noise inside, that we can strengthen our mind and develop higher intelligence.
Since the album《日頭赤炎炎》focus on the struggle of young generation released in 2019, here comes the fifth album《ZENWAVE》from Taiwanese trap king K-How. After many year’s ups and downs, K-How went through various different emotions, anger, sadness, ecstasy…etc. This time K-How chose to transcend worldly attachment, restart from a inner status of “Zen”, disregarding all the external hustle, leaving only pure mindfulness in his heart, K-How is no longer lost, no matter life or his creations, he goes with his own flow and keep moving forward.
What《ZENWAVE》presented is not only the mental changes of K-How, but also the development of his music aesthetic over the years, except his iconic sounds of trap 808s or synth sound with 80’s cyberpunk characteristic, he even try to combines elements of Rock, House Music into this album, showing that he’s not satisfied with only being a trap music artist.
The all-star production team are comprised of Helicrew’s main producer Raylo, the usual suspect – singer/electronic music producer Dusa Naga, he also invited the well-known Taiwanese hip-hop producer ROLLMEAJOIENTYELLA who’re known for countless award-winning hit songs that he produced for across mandarin hip hop scene, from artists like Taiwan’s hip hop superstar MJ116 to Chinese top hip hop artists like BRIDGE、MACOVERSEAS to participate in the beat-making process.
From album’s sound selection, visual artwork to the subtle details in his music video, K-How implement lots of local folklore culture including imagery of Nezha. who died fighting the upper class and finally succeeded in the confrontation, which K-How symbolized himself as Nezha, sacrificing his life for young generation in Taiwan, expressing the conflict in between different generations and traditional values thru his music.
K-HOW continues his dark style on top of strong album concept, production team, no matter if he succeeds or not, K-HOW’s already leaving marks on this never-returning path.
曲目
01 ROCKSTAR LIFE
02 就是你
03 筋斗雲端
04 媽祖托夢
05 龍蛇混雜
06 就等我出山
07 做鬼也風流
08 切切
09 ZENWAVE
10 ZENAX
11 趴數
12 別人的失敗就是我的快樂
what is concept art 在 Goresh Youtube 的精選貼文
For business inquiries please e-mail: Goresh127@gmail.com (not taking collab requests at this time)
https://twitter.com/Goreshx
Check out the Dokkan & Legends podcast with episodes available on Spotify here: https://t.co/nQyIzqzaHD?amp=1
Huge shoutout to Kuwa for creating the thumbnail for this video. His Twitter can be found here: https://twitter.com/mugenkuwa
Huge thanks to Sora for creating the side art
Sora's Twitter: https://twitter.com/SoraSSB
what is concept art 在 每天簡單說泰語 Youtube 的最佳解答
2019 #台灣文博會 搶先報導!喜歡 #泰國品牌IP 及 #泰國文創設計 的粉絲不容錯過! 更多泰國情報: https://line.me/R/ti/p/%40bxy0128d
影片中介紹的泰國文創設計品牌,整理如下:
1. #HOLEN - https://www.facebook.com/holenhello
HOLEN say Hello! @Creative Expo Taiwan 2019
พลพรรคลิงจั๊กจั๊กและยักษ์รักจริงบุกกรุงไทเป 🇹🇼
ครั้งแรกที่ได้มาพบเพื่อนพ้องน้องพี่ชาวไต้หวัน 😍
ในงานแสดงสินค้าไอเดีย Creative Expo Taiwan
Culture on the Move • Design & Licensing
พบกับความน่ารักมุ้งมิ้ง เต็มตลิ่งทั่วทั้งบาง 😆
หนุมานขอฝากเนื้อฝากตัวด้วยนะขอรับบบ..! 🙏😊❤️
---------------------------------------
🛬 Creative Expo Taiwan 2019 🇹🇼
Place : Taipei Expo Park - Expo Dome
Booth NO. : D1-047
Date : 24-28 April 2019
Say "Hello" to THAI Ramakien Characters! The culture of cute "NARAK" Thailand. Localize your brand to THAI market by using Ramakien Characters! More information : info@holenhello.com ❤️
---------------------------------------
แบรนด์โฮเล่น คนไทยเลิฟ 🇹🇭 ต่างชาติรัก ❤️
#holen #holenhello #thaisouvenirdesign #productofthailand#thaidesign #verythai #thainess #amazingthailand #thaimonkey#hanuman #thailand #taiwan #taipei #creativeexpotaiwan#thaicharacter #characterdesign #characterlicensing#ramakiencharacters #โฮเล่น #ของฝาก #ของที่ระลึก #ของขวัญ #ของแทนคำขอบคุณ #ของฝากเพื่อนต่างชาติ #ไทเป #ไต้หวัน
2. #Kai3 - https://www.facebook.com/kai3studio/
มาออกบูธ ใครอยู่ไต้หวันมาหาหน่อยเร้วว😆😆
We are open booth
at Creative Expo Taiwan
Switch Panda only 6 pcs😎
24-28 April 2019
#switchpanda
3. #xhabition - https://www.facebook.com/xhabition
Xhabition provides design solutions for a wide variety of mediums that frequently overlap. Xhabition specializes in feature Social Media, Interactive Media , web design, Commercial Advertising, Post Production, Visual Effects, and Broadcast Design. We work primarily with clients in the entertainment industry who want something beyond the ordinary. We work closely with our clients so they get exactly what they want from concept and design to execution. Xhabition is committed to quality and excellence in all its endeavors. Our team Creative Director and Art Director has a diverse background in new media design. Working with the international companies for major entertainment clients Such as CBS, FOX and Lifetime TV.
4. Bloody Bunny - https://www.facebook.com/BloodyBunny.2Spot/
BLOODY BUNNY is now at Creative Expo TAIWAN !! Come and be my Friend or Enemy !!
#Bloodybunny #CreativeExpoTaiwan #Taipei
5. Nanami Animation - https://www.facebook.com/nanamistudio/
ผู้เชี่ยวชาญในการสร้างคอนเท้นออนไลน์
สติกเกอร์ไลน์ /webtoon/ ดูแลแฟนเพจ
สนใจติดต่อคุณเฟรนด์ 0831887259
6. Workpoint Entertainment https://www.facebook.com/workpoint
#泰國蒙面歌手 #榴蓮哥
7. #Enterdock https://www.facebook.com/enterdock/
8. #WarbieYama. https://www.facebook.com/warbieyama/
9. Tomogram Studio - https://www.facebook.com/tomogramstudio/
Mondster won Cultural & Creative Award 2019 at Creative Expo Taiwan!
Good job Almondino, walsky and Loucashew.!
10. #Liffolab - https://www.facebook.com/liffolab
💡喜歡這支影片的粉絲們,記得按👍及也可留一句鼓勵團長Ricky的話吧!
🗣記得加入FB粉絲團: https://www.facebook.com/eztalk.Thai
🗣記得加入FB社團,可與其他粉絲互動及獲得更多完整情報:
https://www.facebook.com/groups/eztalk.Thai
🇹🇭更多泰語分享影片,請按「訂閱」及「鈴鐺」,將可第一時間收到影片更新訊息: https://goo.gl/E3kzAK
🇹🇭 IG 上線,字卡隨身帶! 🙏歡迎大家加入~
IG帳號: eztalk.thai
https://www.instagram.com/eztalk.thai/
🇹🇭 想快樂及無壓力的學習道地曼谷腔泰語?!歡迎大家一同來學說泰語,當「 #每天簡單說泰語 」版主Ricky的學弟妹吧!也邀請大家加入Line@好友,可以隨時查詢教學過的單字及句子喔!
https://line.me/R/ti/p/%40bxy0128d