📜 [專欄新文章] 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.
👏 歡迎轉載分享鼓掌
同時也有1部Youtube影片,追蹤數超過9,750的網紅Dainghia25,也在其Youtube影片中提到,New PES 2021 PS4 Option File by PES Universe. It includes fully licensed of Premier League SkyBet Championship LaLiga Santander LaLiga SmartBank Serie...
「random draw number」的推薦目錄:
- 關於random draw number 在 Taipei Ethereum Meetup Facebook 的最佳解答
- 關於random draw number 在 外交部 Ministry of Foreign Affairs, ROC(Taiwan) Facebook 的最佳解答
- 關於random draw number 在 劉恭甫-功夫老師 Facebook 的最佳解答
- 關於random draw number 在 Dainghia25 Youtube 的最讚貼文
- 關於random draw number 在 How to Create Random Number Generator for Raffle Draw ... 的評價
- 關於random draw number 在 Strategy game: draw a random number uniformly between 0 ... 的評價
- 關於random draw number 在 Drawing integers - Random numbers and simple games 的評價
- 關於random draw number 在 c# - Random number generator with different numbers 的評價
random draw number 在 外交部 Ministry of Foreign Affairs, ROC(Taiwan) Facebook 的最佳解答
【年度代表字✖️ #台灣頸枕 得獎名單】
謝謝各位捧油支持2021年送21個頸枕的活動
大家對今年的祝福
小編都聽到了
經過大數據的量化分析 📈
將 ‧ 將 ‧ 將 ‧ 獎🎉🎉🎉
今年的年度代表字就是 #穩
另外
#安 #順 則是緊接在後
小編與大家分享網友集思的好兆頭 🏮
希望今年一整年
大家又安又穩、順~順~順~🎊
(跳)
住海邊的小ben 要公布得獎者啦
原本是20個留言參加獎 ➕ 1位年度代表字優選得主
但是小編眼見外粉私訊轟炸而於心不忍
想說歡慶新年希望大家都開薰
決定讓優選的朋友 加碼❗️加碼❗️再加碼❗️
祝福大家66大順 🧧
現在就來看獲獎名單吧
👉獲得讚數互動最多
1. 李文
2. 廖必煙
3. 廖李小程
👉網友提到次數最多 (最早留言)
1. 劉冠廷
2. 黃榆婷
3. 林祐萱
👉參加獎
郭盈杏、Bobo Wang、Jinjay Wang、劉孟孟、賴婷、Sc Randolph、Luffett Lu Luffett Lu、吳雯琦、陳妙萍、Tom Lee、Irisa Chen、Joyce Lin、洪小綾、林亞米、陳怡妏、Lilian Lee、許婉茹、郭春華、姜惠蘋、Astrid Chuang
麻煩獲獎的朋友務必記得
⛔️1/31(日) 晚上23:59前私訊小ben⛔️
同時提供
1️⃣真實姓名
2️⃣郵寄地址(含6碼郵遞區號)
3️⃣連絡電話
安捏獎品就會自動送上門來
讓你高枕 or 低枕都無憂
也不再坐立難安
💢超過截止時間
頸枕就會跟你 say goodbye (得獎失格)囉
什麼❓你沒有抽到❗️
這次沒有抽到的朋友別擔心
請持續追蹤 ➕ 關注魔法粉絲頁
不定期會有抽♥️好♥️禮♥️的驚喜喔
#頸枕還有哪些特殊用法請告訴小ben
#這次沒有抽中代表下次有機會
.
.
.
Given the overwhelming response to our prize draw, the higher ups have added five more travel pillows to the prize pool and an extra mystery prize!
The winning character for this year was 「穩」(wěn) meaning "stability" and regional peace and stability is definitely high on our wishlist for 2021!
The 20 prizewinners selected at random are as follows:
郭盈杏, Bobo Wang, Jinjay Wang, 劉孟孟, 賴婷, Sc Randolph, Luffett Lu Luffett Lu, 吳雯琦, 陳妙萍, Tom Lee, Irisa Chen, Joyce Lin, 洪小綾, 林亞米, 陳怡妏, Lilian Lee, 許婉茹, 郭春華, 姜惠蘋, Astrid Chuang
.
.
Three early birds were selected for choosing the most popular character/word before the rest of the flock and will receive a travel pillow and a mystery prize each:
1. 劉冠廷
2. 黃榆婷
3. 林祐萱
The top three with the most likes on their comment will receive travel pillows and a mystery prize:
1. 李文
2. 廖必煙
3. 廖李小程
Please send us a private message with your real name, delivery address (with 6 digit zipcode) and a contact telephone number before January 31 to claim your prize.
If we don't receive a message from you within the deadline above, you will forfeit your prize.
random draw number 在 劉恭甫-功夫老師 Facebook 的最佳解答
〈運用遊戲化設計教育產品的十個方法〉
遊戲化設計在很多產品中都可以創造更多的體驗,而同樣也可以運用於教育產品,不管大人與小孩的天性都喜歡遊戲,所以遊戲能幫助學習的興趣和學習動力。以下是我在輔導教育產品或課程設計時常見教育產品中運用遊戲化的10個遊戲元素。
(遊戲元素 1)凝聚
當學習者進入一個團體,會產生團隊合作的關聯,將多位學員組成小隊,鼓勵隊員形成凝聚力
(遊戲元素 2)共識
運用討論來達成團隊共識,可以充分發揮跨界學習的優點。
(遊戲元素 3)競爭
目的是完成任務成為勝利者,每個階段將成績排名作為一種刺激,形成正向競爭,能激發勝利的慾望。
(遊戲元素 4)稀缺
是指學習過程想要得到某樣東西,但是因為太稀少無法立刻獲得,例如限制名額或是限時得到禮物。
(遊戲元素 5)累積
學習者必須在指定的時間內有效採取行動而獲得獎勵,例如連續10日答題,或累計一段打卡時間。
(遊戲元素 6)未知
不知道下一個會是什麼,充滿不確定性,所以很期待,例如“盲盒”或隨機的抽牌。
(遊戲元素 7)失去
給學習者一套規則,如果無法完成,就會失去。例如累積的紀錄與成果。
(遊戲元素 8)使命
讓學習者擁有使命感,這是一種內在驅動因素,例如墜落到荒蕪小島展開冒險重返溫暖的家的英雄之旅。
(遊戲元素 9)積分
積分可以為學習者提供持續的動力,例如修完一節課可以獲得10點,連續10天點數加倍或是得到徽章的機制設計。加入排行榜更可以激發競爭。
(遊戲元素 10)情感
讓學習者持續關注某個東西而產生擁有感,例如積分可兌換食物扶養小寵物的成長。
各位早安,功夫老師鼓勵大家可以在課程演講中或是團體活動中運用10種遊戲元素自由組合搭配,讓你創造無限樂趣。
Ten ways to use gamification to design educational products
Gamification design can create more experiences in many products, and it can also be used in educational products. Regardless of the nature of adults and children, they like games, so games can help learning interest and motivation. The following are 10 game elements that I use gamification in common educational products when I tutor education products or curriculum design.
(Game element 1) Cohesion
When a learner enters a group, there will be a teamwork association, and multiple learners will be formed into teams to encourage team members to form cohesion
(Game Element 2) Consensus
Using discussion to reach team consensus can give full play to the advantages of cross-border learning.
(Game element 3) Competition
The goal is to complete the task and become a winner. At each stage, the ranking of the results is used as a stimulus to form a positive competition and stimulate the desire for victory.
(Game element 4) Scarcity
It means that you want to get something in the learning process, but it is too scarce to get it right away, such as a limited number of places or a limited time to get a gift.
(Game Element 5) Accumulation
Learners must take effective actions within the specified time to be rewarded, such as answering questions for 10 consecutive days, or accumulating a period of check-in time.
(Game Element 6) Unknown
I don't know what the next one will be. It is full of uncertainty, so I look forward to it, such as a "blind box" or a random draw.
(Game Element 7) Lost
Give learners a set of rules, if they can’t complete it, they will lose it. For example, accumulated records and achievements.
(Game Element 8) Mission
Let learners have a sense of mission, which is an internal driving factor, such as falling to a deserted island and embarking on an adventure to return to a warm home.
(Game element 9) Points
Points can provide continuous motivation for learners. For example, you can get 10 points after completing a lesson, double the points for 10 consecutive days, or get a badge. Joining the leaderboard can stimulate competition even more.
(Game Element 10) Emotion
Let learners continue to pay attention to something to have a sense of ownership, such as points can be exchanged for food to support the growth of small pets.
Good morning, everyone, I encourage everyone to use 10 game elements to freely mix and match in lectures or group activities, allowing you to create unlimited fun.
大家早安。
No.4 2021-01-07 劉恭甫-功夫老師
https://jackyliu.net/a21004/
random draw number 在 Dainghia25 Youtube 的最讚貼文
New PES 2021 PS4 Option File by PES Universe. It includes fully licensed of Premier League
SkyBet Championship
LaLiga Santander
LaLiga SmartBank
Serie A TIM
FULL Bundesliga with created players, accurate faces & builds
Kits 2048 Px*
Highest Quality
*V1 is full 2048 so you’re gonna have to choose some things to not import as you won’t have all the space
*for PC it's save folder, replace it to \KONAMI\eFootball PES 2021 SEASON UPDATE\RANDOM NUMBER\
Download Link http://bit.ly/pesuniv2021
Credits to PESUniverse || Support them : https://www.pesuniverse.com
Tutotial
PES 2021 V1 – INSTALL – PS4
1. Download the option file & then navigate to the download destination (downloads or desktop folder usually but this despends on your PC)
2. When downloaded, right click on the file and choose ‘Extract to WEPES’ and the file will extract in a few seconds
3. Insert your USB key into your PC/MAC. Right click on the USB icon and select Format if needed (make sure it is set to FAT32)
4. Now return to the WEPES Folder (the one you just extracted) & right click on the WEPES folder & select ‘copy’ & then return to the USB folder
5. Open up the USB folder (double click to go to the USB root) and simply paste the WEPES folder (right click then select paste)
6. This will now copy over so wait a few minutes. Once complete you should have an open folder on your USB called WEPES
7. Now eject the USB from your PC/MAC & and insert it into your PS4. Follow all the instructions until you can go to Edit Mode.
8. When you first start PES 2021, there will be an import tutorial, just follow the intructions before you proceed with importing the Option File.
9. Once in Edit Mode, navigate to Import/Export and select Import Team.
10. Now select All files (PS4 square button) & select ‘Go to Detailed Settings’ and then press OK (DO NOT TICK ANY BOXES HERE)
11. This will import everything except Bundesliga Players so relax for 5-10 minutes while it does its thing. Once completed, return to the import screen
12. Now select all Bundesliga Teams (do not select Schalke, Bayern & Bayer Leverkusen) National Teams & Brazilian teams ONLY
13. Tick both boxes “Players” & “Overwriting images” & then Import by pressing OK. Return to the main Edit Menu
14. Select Import Competition, select All files (PS4 square button) & Go to Detailed Settings’ and then press OK (DO NOT TICK ANY BOXES HERE)
15. Return to main Edit Menu & go to competition structure, reduce the draw size for the Bundesliga to 18 and swap the teams across from other euros
Sometimes you might get an error, do not worry, simply follow the steps again & reimport
▶ Ủng Hộ Tớ (Donate) :
https://unghotoi.com/dainghia25
https://streamlabs.com/dainghia25
▶ SUBSCRIBE MY CHANNEL : https://goo.gl/VPOrGK
▶ RENUMBER LIKE, SUBSCRIBE AND SHARE MY VIDEO!!!
▶ Fanpage Facebook : https://www.facebook.com/dainghia25gaming
▶ Facebook : https://www.facebook.com/dainghia25
#dainghia25gaming #livestream #dainghia25

random draw number 在 Strategy game: draw a random number uniformly between 0 ... 的推薦與評價
It seems obvious that any optimal strategy for a player is to redraw if the first round is less than some value t and not redraw if the ... ... <看更多>
random draw number 在 Drawing integers - Random numbers and simple games 的推薦與評價
One possibility is to draw real numbers from the uniform distribution on, ... Python's random module has a built-in function randint(a,b) for drawing an ... ... <看更多>
random draw number 在 How to Create Random Number Generator for Raffle Draw ... 的推薦與評價
How to Create Random Number Generator for Raffle Draw (No VBA)This 15-minute video tutorial will show you how to create a RANDOM NUMBER ... ... <看更多>