📜 [專欄新文章] 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.
👏 歡迎轉載分享鼓掌
同時也有145部Youtube影片,追蹤數超過40萬的網紅SLSMusic,也在其Youtube影片中提到,SLS playing "My Dearest" from "Guilty Crown" original by supercell, using "Arturia Keylab 88 MK2" weighted keyboard controller. ↓↓↓ Keyboard, Sheet Mu...
「mapping with」的推薦目錄:
- 關於mapping with 在 Taipei Ethereum Meetup Facebook 的最佳解答
- 關於mapping with 在 Sharmaine Kwan - Artist Facebook 的最佳解答
- 關於mapping with 在 軟體開發學習資訊分享 Facebook 的最佳貼文
- 關於mapping with 在 SLSMusic Youtube 的最佳解答
- 關於mapping with 在 Kouki Youtube 的最佳貼文
- 關於mapping with 在 LÊ Quốc Khánh Youtube 的最佳貼文
- 關於mapping with 在 Mapping with Firebase (part 1) - Geocasts - YouTube 的評價
mapping with 在 Sharmaine Kwan - Artist Facebook 的最佳解答
Only 15 days left till the opening of Digital Art Fair Asia 2021! Stay tuned for more exciting fair highlights and program details to be announced soon! I will be showing some neon artworks, light installation and NFT!✨
------------------------------------------------------------
Digital Art Fair Asia Edition 2021 - Hong Kong is the first-ever physical Art Fair in Asia with a focus on immersive art, new media art and NFT Crypto Art, using cutting edge technology such as Virtual Reality, Blockchain and 3D Mapping. The first Digital Art Fair featuring some of the most exciting artwork by renowned international artists.
Visit our exhibition in Hong Kong this September 2021 or via your VR Google anywhere in the world. We look forward to seeing you at our 20,000 sq ft venue in Central, Hong Kong
30th September - 17th October 2021
59 Queen's Road, Central, Hong Kong
mapping with 在 軟體開發學習資訊分享 Facebook 的最佳貼文
🔥 課程特價中
以實戰專案學習 JIRA 的專案計劃和敏捷的路徑圖( road-mapping )工具
本課程介紹 Advanced Roadmaps ( 高階路徑圖 )的所有核心特徵和功能 – JIRA的專案計劃和敏捷的路徑圖工具, 現在可以在 Jira Premium 中使用。
該工具(以前流行的附加組件,Portfolio)已被證明如此受歡迎和有用,以至於 Atlassian 自己接管了該工具,現在已包含在 Jira Premium 依期訂用服務。不過,它仍然是 Jira Server 上可用的附加組件。
Advanced Roadmaps 脫離了計劃的鐵三角,將範疇、時間和資源定義為計劃的主要限制和參數。在本課程中,你將學習如何找到上述最佳組合,以設置現實的路徑圖、發佈日期和總體專案計劃。
https://softnshare.com/agile-project-planning-with-jira-portfolio/
mapping with 在 SLSMusic Youtube 的最佳解答
SLS playing "My Dearest" from "Guilty Crown" original by supercell, using "Arturia Keylab 88 MK2" weighted keyboard controller.
↓↓↓ Keyboard, Sheet Music and More Info ↓↓↓
🔔New Video and Live Every Week, Please SUBSCRIBE and turn the bell on :1
💎Join Membership to support SLSMusic
🎁Get Full Scores, Lead Sheets, MIDI Files, Live & MORE
► http://www.youtube.com/slsmusic/join
📖Sheet Music
🎼https://gum.co/NSRFU
🎼https://www.mymusicsheet.com/slsmusic/29845
For the "Relaxing Piano Pro" series this time, I choose to play legendary "My Dearest" and add a little personal improvisation in it, hope you like it. And you could see that I use a different keyboard to record this time, it's Keylab 88 mk2 from @Arturia, a 88keys beautiful piano action midi controller.
Keylab 88 mk2 has fully weighted 88-note Fatar hammer-action keybed that will delight the most serious pianists, and there are 16 RGB-backlit performance pads, 9 faders and encoders, with its smart mapping functions, you could easily match it with your DAW (Digital Audio Workstation) including Ableton Live, Logic Pro X, Pro Tools, Cubase, Studio One and Reaper.
If you need to read score or using the laptop while playing, there are removable iPad/sheet music stand and an extension shelf for laptop placement as well.
For a budget like this ($899 on Sweetwater), I could say that its really a nice choice for a full-weight midi controller with so much functions. I'll leave the links down below you could check it out more details.
Arturia▶︎ https://www.arturia.com/products/hybrid-synths/keylab-88-mkii/overview
Sweetwater▶︎ https://www.sweetwater.com/store/detail/KeyLab88mk2--arturia-keylab-88-mkii-weighted-keyboard-controller
🎧Find SLSMusic on Spotify, iTunes, Apple Music, Amazon, Deezer and more
► https://li.sten.to/slsmusic
🎧Streaming Platforms
🎹Spotify ► http://bit.ly/SLSMusicSpotify
🎻iTunes ► http://bit.ly/SLSiTunes
✅SLSMusic LINE Stickers ► https://line.me/S/sticker/7239025
🎧Playlists
Official Playlists 🎥
https://www.youtube.com/playlist?list=PLqY5-xxyprjtckllGMQK4XljIu_5csx3z
Relaxing Piano Project🎹
https://www.youtube.com/playlist?list=PLqY5-xxyprjtu-55c25HnX1cGsXSbaPVU
ANIME 🌀
https://www.youtube.com/playlist?list=PLqY5-xxyprjvRFtzx5OPeWYIyncPC2JGi
🎤Social Media
Website ➡ https://www.slsmusic.net
Instagram ➡ https://www.instagram.com/slsmusictw
Twitter ➡ https://twitter.com/slsmusictw
Facebook ➡ https://www.facebook.com/slsmusictt
🥁DONATION
PayPal ► https://www.paypal.me/SLSMusic
歐付寶 ► https://www.bit.ly/DonateSLS
🔧Equipment
●Piano / Arturia Keylab 88 mk2
●Speakers / ADAM A7X
●Audio Interface / Yamaha AG06
●Camera / Panasonic GH5
●Studio Desk / Wavebone HEADQUARTER
■──────────────────■
#MyDearest #RelaxingPianoProject #GuiltyCrown
![post-title](https://i.ytimg.com/vi/3VSwWDKnuac/hqdefault.jpg)
mapping with 在 Kouki Youtube 的最佳貼文
如果把鬥陣特工跟Undertale結合會變成什麼遊戲 !!
❤ 每天都有新影片!! 從今天起開始訂閱吧 !! ❤ ➔ http://bit.ly/Kouki
🔥 來看看【阿神】在使用的【實況裝備】有哪些超酷的東西:http://elgato.com/kouki 🔥
【影片製作團隊】
1) 剪輯師 ➔ AF
2) 字幕師 ➔ NatC
3) 封面製作師 ➔ Brocardo / BUUZ / Osla / KrepsStudio
4) 封面角色模組來源 ➔ https://www.minecraftforum.net/forums/mapping-and-modding-java-edition/minecraft-mods/2636433-undertale-mod-map-minecraft-1-10-2
5) 原作者 ➔ TobyFox
•⭐•⭐•⭐•⭐•⭐• Credits •⭐•⭐•⭐•⭐•⭐•
原作者 ➔ 天豹星雲 & 阿庫洛羅基亞
指令下載 ➔ https://forum.gamer.com.tw/C.php?bsn=18673&snA=183278&tnum=1
•⭐•⭐•⭐•⭐•⭐•⭐•⭐•⭐•⭐•⭐•⭐•⭐•⭐•
歡迎【提交你的自創麥塊地圖】:http://bit.ly/KoukiMaps
【Facebook】追蹤我 ➔ https://www.facebook.com/KamiKamiMatsu
【Twitter】追蹤我 ➔ https://twitter.com/Ashan_kouki
•⭐•⭐•⭐•⭐•⭐• License •⭐•⭐•⭐•⭐•⭐•
1) OMFG https://www.youtube.com/user/alexsavageomfg
Available at: http://bit.ly/meant4u
(as well as Spotify: http://bit.ly/meantforyou)
使用授權聲明 ➔ https://i.imgur.com/46j391z.jpg
2) D1ofAquavibe www.youtube.com/user/D1ofAquavibe
Available at: www.D1ofAquavibe.com/music
(as well as iTunes, Google Play, etc.)
使用授權聲明 ➔ https://i.imgur.com/Poykr3O.jpg
3) TheFatRat https://www.youtube.com/user/ThisIsTheFatRat
Available at: https://the-arcadium.net/
使用授權聲明 ➔ https://i.imgur.com/VL6htMz.png
4) Epidemicsound https://player.epidemicsound.com/browse/
使用授權聲明 ➔ https://i.imgur.com/BfoLOnN.jpg
5) FesliyanStudios https://www.fesliyanstudios.com/
使用授權聲明 ➔ https://i.imgur.com/K9Bs1sQ.jpg
6) Outro ➔ https://soundcloud.com/shurkofficial/haunted
使用授權聲明 ➔ https://i.imgur.com/c91ZARg.jpg
•⭐•⭐•⭐•⭐•⭐•⭐•⭐•⭐•⭐•⭐•⭐•⭐•⭐•
Microphone ➔ AT2020
Keyboard ➔ Ducky 青軸
Mouse ➔ D.Va Razer Abyssus Elite
#地下傳說 #Undertale #第一集
*If any producer or label has an issue with any of the uploads please get in contact (charlie615118@gmail.com) with me and I will delete it immediately (this includes artists of the images used).
![post-title](https://i.ytimg.com/vi/nOk3W0Y6Qf0/hqdefault.jpg)
mapping with 在 LÊ Quốc Khánh Youtube 的最佳貼文
Anh đã thấy những bông hoa nở và tàn phai
Anh đã yêu và chia tay nhiều cô gái
Nhưng mãi trong anh là em
Anh đã hiến dâng tuổi thanh xuân của mình cho em.
Rất nhiều cỗ máy có thể tuyên bố tầm ảnh hưởng đến thiết kế superbike hiện đại. Một số người cho rằng Honda CB750 đã đặt nền móng vào năm 1969. Những người khác có thể nói rằng Yamaha R1 của năm 1998 đã định rõ phân khúc này. Nhưng Suzuki GSX-R - cùng nhiều phiên bản - luôn dẫn đầu.
Nó có thể không thực sự là chiếc GSX-R đầu tiên, nhưng GSX-R750 năm 1985 là chiếc xe đã thu hút sự chú ý của cả thế giới. Suzuki’s GSX-R750 sẽ luôn được nhớ đến như một cỗ máy mô phỏng đường đua thực sự đầu tiên. Công suất 100 mã lực và nặng 176kg, nó đã tạo ra một chiếc xe hiệu suất cao hoàn toàn mới.
Suzuki 2008 GSX-R750. Khung hợp kim nhôm đúc mới. Thân xe mới với tăng tính khí động học. Hệ thống quản lý động cơ và phun nhiên liệu tiên tiến với mapping có thể điều chỉnh khi đang di chuyển. Hệ thống treo hiệu suất cao có thể điều chỉnh hoàn toàn và phanh gắn hướng tâm. Mang đến hiệu suất đường đua đẳng cấp trong một package tầm trung.
Các bạn có thể ủng hộ mình qua số tài khoản: 0251002559129, Vietcombank hoặc qua Patreon: https://www.patreon.com/lequockhanh
Kết nối với mình qua Facebook / Connect with me via Facebook: https://www.facebook.com/leqkhanh29
#lequockhanh #SuzukiGSXR750 #GSXR750
![post-title](https://i.ytimg.com/vi/K4YlB21iw0w/hqdefault.jpg)
mapping with 在 Mapping with Firebase (part 1) - Geocasts - YouTube 的必吃
... <看更多>