📜 [專欄新文章] 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.
👏 歡迎轉載分享鼓掌
同時也有35部Youtube影片,追蹤數超過9,850的網紅Root's Game Store,也在其Youtube影片中提到,#Root的遊戲心得小舖 #光明與黑暗 #王都巨神 接著16.1的內容 --------------------------------------------------------------------------------------------------------------...
「user scenario」的推薦目錄:
- 關於user scenario 在 Taipei Ethereum Meetup Facebook 的最讚貼文
- 關於user scenario 在 Milton Goh Blog and Sermon Notes Facebook 的精選貼文
- 關於user scenario 在 BorntoDev Facebook 的最佳貼文
- 關於user scenario 在 Root's Game Store Youtube 的精選貼文
- 關於user scenario 在 Root's Game Store Youtube 的最佳解答
- 關於user scenario 在 Root's Game Store Youtube 的最佳解答
- 關於user scenario 在 User Story 和Customer Journey Map « 嫁給RD的UI Designer 的評價
- 關於user scenario 在 37 USER SCENARIO ideas - Pinterest 的評價
- 關於user scenario 在 Angular modules for admin/user scenario - Stack Overflow 的評價
- 關於user scenario 在 What is the difference between Scenario and User Journey? 的評價
- 關於user scenario 在 Http scenario load test - Jagger - GitHub Pages 的評價
user scenario 在 Milton Goh Blog and Sermon Notes Facebook 的精選貼文
I like the following write up and agree with its statements:
What exactly is Pi? In 2009, when Bitcoin was first released, 50 coins could be mined for free every 10 minutes. Most people found it worthless. At the all-time high (ATH), one Bitcoin was worth almost $63,000. When Litecoin was released in 2011, 100 LTC could be mined for free every day. Most people still think that it is worthless. At its ATH, one Litecoin was worth $300. When Ethereum was first released in 2014, 30 ETH could be mined for free every day. At its recent ATH, one Ethereum was worth $4000.
With the development of mobile internet technology, everyone's life is becoming more and more digital. Cryptocurrency is not only an outlet for entrepreneurs or investors, but an era for all! Pi is a free cryptocurrency network that everyone can join. Anyone can start mining by downloading the application of the Picoin official website with their mobile phone. All Picoins are mined by the user themselves. You can click on mining every 24 hours, and it’s completely free, just like original Bitcoin mining, but it's more convenient and simpler than before.
Looking at the growth of Bitcoin and Ethereum, it can be painful. Two huge opportunities have passed. Many people regret missing out!
No problem! You are reading this writeup and you have learned of the 3rd chance, and its name is Pi Network.
Pi Network is a 100% FREE cryptocurrency project of the Stanford University team of doctors. Pi Network was created with cryptocurrency universal to all users around the world, unlike Bitcoin which is difficult to use and difficult to access to most of the population.
Just own a phone and take 10 seconds of attendance every day and persevere. No crashes, no RAM, you can mine cryptocurrency Pi Network automatically, for free every day. Just like Bitcoin and Ethereum when they were first launched.
The Pi Network project is at the end of its testing phase and is preparing to go public on the mainnet (expected this year end). Currently, if you mine alone, you receive 6pi per day, 180 pi per month. I have been mining Pi since 2019, and have accumulated 19k Pi coins.
If at the end of this year, Pi is priced at 1 USD -> You and I have money for coffee. And as time progresses...
If Pi costs 10USD -> You and I have money to spend.
If Pi costs 100USD -> You and I will be wealthy.
….
If Pi costs 0 USD -> You don’t lose any money. You just wasted your time clicking the “mine Pi” button once a day. However, this scenario is unlikely as the current Pi user base has passed 18 million and is growing rapidly. Pi is a project where we are likely to win. The project is FREE at no cost to you!
—————————-
If you are not registered with PI NETWORK, click the following link:
https://minepi.com/miltongohblog
Use my invitation code to access Pi Network app and you will receive 1 Pi coin as a welcome gift!
Invitation code: miltongohblog
user scenario 在 BorntoDev Facebook 的最佳貼文
🔥 สวัสดีเพื่อน ๆ โพสต์นี้แอดมาสรุปพื้นฐานสำคัญในการออกแบบ UX นั่นเองจ้าาา บอกเลยใครสนใจด้านนี้ต้องอ่านกันให้ไว ๆ เลย มาดูกันว่า 5 Step สำคัญในการออกแบบ UX นั้นมีอะไรบ้าง ? ถ้าอยากรู้แล้วไปอ่านกันได้เลยยยย ~
.
🌟 รู้จักผลิตภัณฑ์
ต้องเข้าใจบริบทของผลิตภัณฑ์ให้แน่ชัด มองภาพใหญ่ ๆ ให้แน่ชัดว่าผลิตภัณฑ์นั้นทำขึ้นมาเพื่ออะไร ตอบโจทย์กับสิ่งใดบ้าง แล้วใครบ้างที่จำเป็นต้องใช้ผลิตภัณฑ์เหล่านี้ ศึกษากลยุทธ์ที่สนับสนุนการทำ UX จะกำหนดเป้าหมายให้ชัดเจน
.
🌟 Research
การวิจัยโดยการรวบรวมข้อมูลจากกลุ่มเป้าหมาย เพื่อให้เห็นความต้องการ และความคาดหวังของผู้ใช้ต่อผลิตภัณฑ์ที่แน่ชัด เช่น การเก็บสถิติ สัมภาษณ์ ตรวจสอบพฤติกรรม เป็นต้น เพื่อนำข้อมูลเหล่านั้นมาปรับปรุงผลิตภัณฑ์ของเราให้ตรงตามความต้องการของกลุ่มเป้าหมายให้มากที่สุดนั่นเอง
.
🌟 วิเคราะห์
นำข้อมูลเชิงลึกจากการ Research เพื่อระบุลักษณะของกลุ่มเป้าหมาย เช่น การเก็บ User Personas, การทำ Scenario maps เพื่อเรียนรู้ลักษณะของกลุ่มเป้าหมายในเชิงลึกมากขึ้น เช่น อายุ, อาชีพ, ไลฟ์สไตล์ เป็นต้น เพื่อนำมาวิเคราะห์เพื่อปรับปรุงผลิตภัณฑ์ให้ตรงตามลักษณะของกลุ่มเป้าหมาย
.
🌟 ออกแบบ
เมื่อเรารู้ถึงความต้องการของผู้ใช้อย่างชัดเจนแล้ว ก็ถึงขั้นตอนการออกแบบผลิตภัณฑ์นั่นเอง เช่น
Wireframe จะช่วยให้นักออกแบบสามารถมองเห็นภาพรวม และองค์ประกอบรวม ๆ ของผลิตภัณฑ์นั่นเอง สามารถทำได้โดยการวาดลงบนกระดาษ เป็นวิธีที่ง่ายและรวดเร็ว
Prototype เป็นการสร้างต้นแบบของผลิตภัณฑ์ที่สามารถใช้งานได้เสมือนของจริง ซึ่งมันจะทำให้ผู้ใช้สามารถเข้าใจ และเห็นภาพของผลิตภัณฑ์ได้มากที่สุดนั่นเอง
.
🌟 Validation
เป็นขั้นตอนสำคัญในกระบวนการออกแบบ UX เนื่องจากช่วยให้ทีมเห็นผลลัพธ์ว่าการออกแบบในลักษณะใดเข้ากับผู้ใช้มากที่สุดนั่นเอง โดยการนำผลิตภัณฑ์ไปทดลองใช้งานจริงกับผู้ใช้นั่นเอง จากนั้นก็จะรับ Feedback จากผู้ใช้ และนำมาปรับปรุงเพื่อสร้างเป็นผลิตภัณฑ์ที่สมบูรณ์นั่นเอง
.
หากใครมีอะไรเพิ่มเติมคอมเมนต์ไว้ด้านล่างได้เลยนะ ถ้าชอบโพสต์นี้ฝากกดไลก์ กดแชร์เพื่อเป็นกำลังใจให้แอดด้วยน้าาาา 😍
.
borntoDev - 🦖 สร้างการเรียนรู้ที่ดีสำหรับสายไอทีในทุกวัน
user scenario 在 Root's Game Store Youtube 的精選貼文
#Root的遊戲心得小舖 #光明與黑暗 #王都巨神
接著16.1的內容
---------------------------------------------------------------------------------------------------------------
成為這個頻道的會員並獲得獎勵:
https://www.youtube.com/channel/UC3hy3XtCogcAyxt-ahy8EyA/join
Tubebuddy是一個很好用的工具,有在經營YT的應該都要使用
它可以讓你看到一些YT後台隱藏的訊息
例如自己和其他頻道的流量,還有設定的關鍵字,我自己也有在使用
使用下面的連結安裝的話,我可以得到一點獎勵
在此推薦給正在經營或是有興趣經營YT的朋友們
https://www.tubebuddy.com/RootTsou
有的影片沒辦法營利,廣告費會被拿走
歡迎贊助本頻道,協助頻道經營
贊助方法一:使用Paypal:
paypal.me/RootTsou
贊助方法二:使用歐付寶,這個方法適用於「沒有信用卡」時:
https://payment.opay.tw/Broadcaster/Donate/23C60821C8C8F340A6FDCDD40F6AEE38
感謝您的贊助!
你 / 妳 想成為Youteber來增加被動收入嗎?
歡迎參考我的簡介喔,下面有詳細介紹
https://www.youtube.com/user/RootTsou/about
也歡迎幫我點讚、分享和訂閱喔 ️
點擊影片右下方的頭像可以訂閱我,或是結束時P4主角的頭像
如果有訂閱的話請「一定」要開啟小鈴鐺
這樣我上傳新影片的時候才會收到通知~
但就算這樣還是有可能會漏掉通知
這時候請加入Discord,會有機器人通知最新影片上傳!
Discord位置:
https://discord.com/invite/z6m3SWe
巴哈姆特小屋:
https://home.gamer.com.tw/homeindex.php?owner=prettysamy
Twitch頻道:
https://www.twitch.tv/roottsou_game
粉絲團網址:
t.me/Root_Tsou
巴哈姆特往日遊戲版的Facebook專頁:
https://www.facebook.com/groups/Baha.OldGames
(優質社團歡迎加入 ww)
Facebook (Root Tsou):
https://www.facebook.com/root.tsou
電子郵件信箱:
shining383@gmail.com
![post-title](https://i.ytimg.com/vi/Nr4tAAOsEDU/hqdefault.jpg?sqp=-oaymwEbCKgBEF5IVfKriqkDDggBFQAAiEIYAXABwAEG&rs=AOn4CLBqRiyQfnjOxharOcJasURBpBF7GA)
user scenario 在 Root's Game Store Youtube 的最佳解答
#Root的遊戲心得小舖 #光明與黑暗 #王都巨神
終於快破關了
中途網路又卡,所以我重開了數據機
---------------------------------------------------------------------------------------------------------------
成為這個頻道的會員並獲得獎勵:
https://www.youtube.com/channel/UC3hy3XtCogcAyxt-ahy8EyA/join
Tubebuddy是一個很好用的工具,有在經營YT的應該都要使用
它可以讓你看到一些YT後台隱藏的訊息
例如自己和其他頻道的流量,還有設定的關鍵字,我自己也有在使用
使用下面的連結安裝的話,我可以得到一點獎勵
在此推薦給正在經營或是有興趣經營YT的朋友們
https://www.tubebuddy.com/RootTsou
有的影片沒辦法營利,廣告費會被拿走
歡迎贊助本頻道,協助頻道經營
贊助方法一:使用Paypal:
paypal.me/RootTsou
贊助方法二:使用歐付寶,這個方法適用於「沒有信用卡」時:
https://payment.opay.tw/Broadcaster/Donate/23C60821C8C8F340A6FDCDD40F6AEE38
感謝您的贊助!
你 / 妳 想成為Youteber來增加被動收入嗎?
歡迎參考我的簡介喔,下面有詳細介紹
https://www.youtube.com/user/RootTsou/about
也歡迎幫我點讚、分享和訂閱喔 ️
點擊影片右下方的頭像可以訂閱我,或是結束時P4主角的頭像
如果有訂閱的話請「一定」要開啟小鈴鐺
這樣我上傳新影片的時候才會收到通知~
但就算這樣還是有可能會漏掉通知
這時候請加入Discord,會有機器人通知最新影片上傳!
Discord位置:
https://discord.com/invite/z6m3SWe
巴哈姆特小屋:
https://home.gamer.com.tw/homeindex.php?owner=prettysamy
Twitch頻道:
https://www.twitch.tv/roottsou_game
粉絲團網址:
t.me/Root_Tsou
巴哈姆特往日遊戲版的Facebook專頁:
https://www.facebook.com/groups/Baha.OldGames
(優質社團歡迎加入 ww)
![post-title](https://i.ytimg.com/vi/1frU6gmnocg/hqdefault.jpg)
user scenario 在 Root's Game Store Youtube 的最佳解答
#Root的遊戲心得小舖 #光明與黑暗 #王都巨神
繼續玩下去囉!
---------------------------------------------------------------------------------------------------------------
成為這個頻道的會員並獲得獎勵:
https://www.youtube.com/channel/UC3hy3XtCogcAyxt-ahy8EyA/join
Tubebuddy是一個很好用的工具,有在經營YT的應該都要使用
它可以讓你看到一些YT後台隱藏的訊息
例如自己和其他頻道的流量,還有設定的關鍵字,我自己也有在使用
使用下面的連結安裝的話,我可以得到一點獎勵
在此推薦給正在經營或是有興趣經營YT的朋友們
https://www.tubebuddy.com/RootTsou
有的影片沒辦法營利,廣告費會被拿走
歡迎贊助本頻道,協助頻道經營
贊助方法一:使用Paypal:
paypal.me/RootTsou
贊助方法二:使用歐付寶,這個方法適用於「沒有信用卡」時:
https://payment.opay.tw/Broadcaster/Donate/23C60821C8C8F340A6FDCDD40F6AEE38
感謝您的贊助!
你 / 妳 想成為Youteber來增加被動收入嗎?
歡迎參考我的簡介喔,下面有詳細介紹
https://www.youtube.com/user/RootTsou/about
也歡迎幫我點讚、分享和訂閱喔 ️
點擊影片右下方的頭像可以訂閱我,或是結束時P4主角的頭像
如果有訂閱的話請「一定」要開啟小鈴鐺
這樣我上傳新影片的時候才會收到通知~
但就算這樣還是有可能會漏掉通知
這時候請加入Discord,會有機器人通知最新影片上傳!
Discord位置:
https://discord.com/invite/z6m3SWe
巴哈姆特小屋:
https://home.gamer.com.tw/homeindex.php?owner=prettysamy
Twitch頻道:
https://www.twitch.tv/roottsou_game
粉絲團網址:
t.me/Root_Tsou
巴哈姆特往日遊戲版的Facebook專頁:
https://www.facebook.com/groups/Baha.OldGames
(優質社團歡迎加入 ww)
Facebook (Root Tsou):
https://www.facebook.com/root.tsou
電子郵件信箱:
shining383@gmail.com
![post-title](https://i.ytimg.com/vi/C4ouGCmEkN4/hqdefault.jpg)
user scenario 在 37 USER SCENARIO ideas - Pinterest 的推薦與評價
Dec 21, 2016 - User Scenarios, persona, Day In The Life Of and innovation videos. See more ideas about scenarios, innovation, retail banking. ... <看更多>
user scenario 在 User Story 和Customer Journey Map « 嫁給RD的UI Designer 的推薦與評價
Persona (人物誌) Scenario (情境故事法) User Story(使用者故事) Customer Journey Map (使用者旅程地圖) 這4 種很容易混淆嗎?文件的目的都不一樣啊... ... <看更多>