📜 [專欄新文章] 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.
👏 歡迎轉載分享鼓掌
同時也有28部Youtube影片,追蹤數超過63萬的網紅Hana's Lexis,也在其Youtube影片中提到,Hello các bạn! Hôm nay, các bạn hãy cùng mình học từ vựng tiếng anh khó thông qua thông tin về việc chính phủ Mỹ tuyên bố những người đã chích vắc xin...
incentive 在 Facebook 的最讚貼文
Riety Studio กำลังมองหาคนมาร่วมทีมเพิ่มดังนี้
Editor ประจำ 3 ตำแหน่ง
Script Writer 1 ตำแหน่ง
Project Manager 1 ตำแหน่ง
- มีเงินเดือนประจำและ Incentive เพิ่มตามปริมาณงานที่ตัดต่อ / เขียน / ประสานงาน
- เบิกค่าเดินทางได้ไม่จำกัดจำนวนครั้งต่อเดือน ( ช่วง Covid-19 ทางเราให้ทีมงานเดินทางด้วย Grab Car ) สตูดิโออยู่ใกล้บีทีเอสพระโขนง
- ประกันสังคม เบิกค่าเจ็บป่วยได้
- วันหยุดไม่จำกัด ไม่มีเวลาเข้างาน ขอแค่ทำงานเสร็จ ไม่ต้องเข้าสตูดิโอทุกวัน
- มีฝีมือ ชื่นชอบศิลปะ มีความรับผิดชอบสามารถแบ่งเวลาด้วยตัวเองได้ สามารถทำงานเป็นทีมและเรียนรู้สกิลใหม่ได้
[ EDITOR ]
-สามารถใช้ Premiere pro / Final Cut ตัดต่อได้ดีเยี่ยม ถ้ามีพื้นฐานทาง Graphic Design หรือ Motion graphic มาก่อนจะได้รับการพิจารณาเป็นพิเศษ
[ SCRIPT WRITER ]
- ชื่นชอบการค้นคว้าและเขียนด้านศิลปะ วิทยาศาสตร์ ประวัติศาสตร์ การเมือง ฯลฯ
- ชอบทดลอง
- ชอบหาคำตอบ ชอบถามคำถาม
- สามารถเรียบเรียงเรื่องราวได้ดี
- มีความสามารถในการค้นคว้าข้อมูลทั้งภาษาไทยและอังกฤษ
[ PROJECT MANAGER ]
มีความสามารถในการบริหาร ประสานงาน มีความคิดสร้างสรรค์ในการแก้ไขปัญหาและดูแลให้โปรเจคต่างๆสำเร็จลุล่วงได้ด้วยดี
Riety Studio เป็นบริษัทที่ประกอบด้วยโปรดักชั่นเฮาส์ผลิตสื่อ โฆษณา สื่อออนไลน์ (เช่นเพจ Riety ) และ Digital Agency เราต้องการหาบุคคลที่สามารถบริหารทรัพยากรในบริษัทให้เกิดสินค้าและบริการใหม่ๆ
ถ้าหากสนใจ ส่งใบสมัครมาได้ที่ [email protected] รอร่วมงานด้วยกันอยู่นะคะ
incentive 在 YURA (ยูร่า) Facebook 的最讚貼文
YURA เปิดรับสมัครทีมงาน ตำแหน่ง Graphic Designer / กราฟิคดีไซน์เนอร์ จำนวน 1 อัตรา
คุณสมบัติผู้สมัคร
• วุฒิการศึกษา ปวส. หรือปริญญาตรี สาขาใดก็ได้ เป็นผู้มีประสบการณ์ในการออกแบบอาร์ตเวิร์ค สกินแคร์ เครื่องสำอาง
• ใช้โปรแกรมด้านออกแบบพื้นฐานได้คล่อง Adobe Illustrator , Photoshop , Premiere Pro
• ตัดต่อ clip video สั้นๆได้
• มีทัศนคติในการทำงานที่ดี
• ส่งผลงานประกอบการพิจารณา
• อายุไม่เกิน 35 ปี
รายละเอียดงาน
• คิด Content ออกแบบ จัดทำอาร์ตเวิร์ค และตัดต่อคลิปสั้นๆ เพื่อใช้ประชาสัมพันธ์ในสื่อสังคมออนไลน์ต่างๆได้ (Facebook ,Twitter , Instragram , Youtube, LINE OA , Tiktok)
สอบถามรายละเอียด 02-116-1666 ต่อ 111 เวลาทำการ จันทร์-ศุกร์ เวลา 8.30 น. – 17.30 น.
เงินเดือน ตามตกลง
ลักษณะงาน งานประจำ
สถานที่ทำงาน บริษัท ไทย มัลติพลาย จำกัด ถ.รามอินทรา แขวง/เขตคันนายาว กรุงเทพมหานคร
สวัสดิการ
- โบนัสประจำปี
- มีผลตอบแทนการทำงาน ( incentive)
- สิทธิการเบิกสินค้าสวัสดิการพนักงาน
- ประกันสังคม
- วันหยุดประจำปี
- สิทธิการลาต่างๆตามกฎหมายแรงงาน
incentive 在 Hana's Lexis Youtube 的最佳解答
Hello các bạn! Hôm nay, các bạn hãy cùng mình học từ vựng tiếng anh khó thông qua thông tin về việc chính phủ Mỹ tuyên bố những người đã chích vắc xin đầy đủ sẽ không phải đeo khẩu trang khi đi ra ngoài nhé!
Xem lời thoại dưới đây để học từ vựng tiếng Anh khó của ngày hôm nay nha.
Gần đây thì có một thông tin gây được rất nhiều sự quan tâm của dư luận đó là việc vào ngày 13 tháng 5, Trung tâm Kiểm soát Dịch bệnh Hoa Kỳ đã tuyên bố rằng tất cả những người đã được chích đủ liều vắc xin sẽ không cần phải đeo khẩu trang khi đi ra đường. Điều này được cho là nhằm tạo ra **incentive** (động lực) thúc đẩy người dân đi chích vắc xin nhiều hơn. Tuy nhiên, thì quy định mới cũng đi kèm với **caveat** (điều cần lưu ý). Đó là người dân vẫn phải đeo khẩu trang khi đi vào bệnh viện, hay di chuyển trong các phương tiện công cộng. Các chuyên gia cũng cảnh báo rằng những người có hệ miễn dịch yếu cần cân nhắc thật kĩ trước khi **relinquish** (từ bỏ) thói quen đeo khẩu trang.
Cần lưu ý rằng đây là quyết định của chính phủ, và không liên quan đến **decree** (đạo luật) của từng bang. **In deference to** (nhằm tôn trọng) chính quyền của từng bang, Tổng thống Biden vẫn cảnh báo rằng công dân phải **abide by** (tuân thủ) luật lệ riêng của từng bang. Tức là nếu chính quyền của bang vẫn bắt người dân đeo khẩu trang ra đường, thì người dân sống tại bang đó vẫn phải đeo khẩu trang.
Phải nói thêm là quyết định này của chính quyền Tổng thống Biden đã đặt ra rất nhiều dấu hỏi. Hiện nay, thì theo tờ New York Times, chỉ có 36% người dân Mỹ đã chích đủ liều vắc xin. Rất khó để nhận biết trong số những người không đeo khẩu trang thì ai đã thật sự trải qua quá trình **inoculation** (sự tiêm chủng), và ai chưa chích. Những người đã chích vắc xin sẽ được nhận 1 tờ giấy chứng nhận. Tuy nhiên, thì hiện nay trên mạng đã xuất hiện rất nhiều nơi bắt đầu **forge** (làm giả) giấy chứng nhận này. Có nhiều ý kiến đề xuất chính phủ nên bắt đầu tạo ra những hộ chiếu vắc xin. Tuy nhiên thì đề xuất này đã bị **derailed** (chặn lại) bởi sự **backlash** (sự phản đối quyết liệt) tới từ phe Cộng Hòa do lo ngại về vấn đề quyền riêng tư.
0:00 - Intro
0:51 - Mỹ cho phép người dân bỏ khẩu trang khi đi ra ngoài
3:12 - Khuyến mãi SUMMERWITHHANA
3:58 - Tổng kết 10 từ vựng
--------------------
Click vào link tham gia Nuii Gang để nhận các đặc quyền sau! https://www.youtube.com/c/HanasLexis/join
1. Daily vlog đời sống chỉ chia sẻ cho Nuii Gang xem
2. Live stream riêng mỗi tháng trả lời câu hỏi nhiều bình chọn
3. Hẹn gặp ngoài đời khi mình tới thành phố bạn sống
4. Reply comment đăng trên video trong vòng 24h đầu
5. Hiện tên bạn cảm ơn trong end credits ở cuối video
--------------------
Q: Hana là ai làm gì ở đâu?
A: Hana hiện làm software engineer / lập trình viên ở Mỹ, là cựu chuyên Anh trường Phổ Thông Năng Khiếu, từng đạt 9.0 IELTS General, từng có quá khứ "huy hoàng" bỏ học, sống vô gia cư, làm chui, v.v không mấy lỗi lạc, bắt đầu làm Youtube từ 3/2019 sau khi chán ngán nghe chia sẻ tiếng Anh nhạt nhẽo, khô khan, không thực tế trên mạng.
Q: Hana's Lexis có nghĩa là gì?
A: Hana's Lexis có thể hiểu là vốn từ vựng của Hana, dùng từ chuyên ngành "lexis" nhằm hướng tới phân khúc người học tiếng Anh ở trình độ khá, đang phấn đấu lên giỏi. Cần lưu ý dấu 's sở hữu cách, vì đây không phải tên riêng.
Q: Kênh Hana's Lexis làm về nội dung gì?
A: Chia sẻ tiếng Anh xịn, chất, chuẩn, ví dụ như về sắc thái từ vựng, độ tự nhiên trong cách dùng ngôn ngữ, cách phát âm chuẩn Mỹ, những điều mà trường lớp không hoặc ít dạy. Một vài format / hình thức video Hana tự sáng tạo ra cho người xem thấy tiếng Anh thú vị hơn gồm Dịch Ngựa, Truyện Chêm, IELTS Khẩu Nghiệp, v.v. Ai bắt chước là lêu lêu copycat nhe.
Q: Các bạn follow Hana gọi là gì?
A: Một cái tên thân thương là "nuii" (đọc là nui-ì) với 3 tầng nghĩa: 1) học tiếng Anh kiểu nuii / new / mới, 2) học kiểu nuii / nui / mì ăn liền giúp dễ thấm và dùng ngay được, 3) nuii gần giống tên thật của Hana là Nhung hehe.
--------------------
✪ Các thì tiếng Anh thật sự dùng trong văn nói?
➥ https://youtu.be/0mhWAFhs7KQ
✪ Học nhồi 100 từ vựng/ngày?
➥ https://youtu.be/Uq3KjJA8BHQ
✪ Bốn sai lầm khi phát âm tiếng Anh?
➥ https://youtu.be/9wHHy1JaSeQ
✪ Dịch ngựa cho Đen Vâu
➥ https://youtu.be/TgkI73t4vDc
--------------------
✪ WEBSITE: https://hanaslexis.com
✪ FACEBOOK: https://facebook.com/hanaslexis
✪ INSTAGRAM: https://instagram.com/hana.s.lexis
✪ EMAIL (vui lòng chỉ liên hệ về công việc): work@hanaslexis.com
➥ #hanaslexis #tuvung #tienganh
--------------------
© Bản quyền thuộc về Hana's Lexis
© Copyright by Hana's Lexis ☞ Do not Reup
incentive 在 台灣1001個故事 Youtube 的精選貼文
How far, or perhaps how close, are the endemic leopard cats to life and death? This time, “Orphans of the Earth” joins three orphaned baby leopard cats and records how they have been looked after, trained and released back to the wilds. Spanning over two years for shooting, this documentary also follows the first-ever release and track project of leopard cats in the history of animal conservation efforts in Taiwan. When Duyan the leopard cat fell to death in a well, we were there with the conservation experts, climbing up and down in the difficult paths and picking the bones of leopard cats. The life and death of leopard cats would instantly take us into the cruel world of leopard cats.
The documentary team also joined the latest research project on roadkill leopards, which were dissected, and parasites carefully examined; we also followed up with the cash incentive program of “leopard cat friendly farms”. With this documentary, it is our hope to enhance deeper understanding, compassion and eventually more conservation efforts for leopard cats, the only surviving feline species native to Taiwan. When the habitats are degraded and threats emerge as roadkill, canine-kill, poisons and illegal hunting, the leopard cats are pushed back to crueler survival games when they are released into the wild. It’s estimated by experts that this last native feline specie might disappear in Taiwan within 20 years.
■台灣1001個故事 說不完的故事
每周日晚間9點,請鎖定東森新聞【台灣1001個故事】唷!
更多精彩內容鎖定《台灣1001個故事》
https://www.youtube.com/user/ettvtaiwan1001
#台灣1001個故事 #白心儀 #石虎
incentive 在 JSK-koubou Youtube 的最佳貼文
I got a radio-controlled airplane for free by using a tax incentive system called "Hurusato-nouzei" payment in Japan.
It was very stable and flew well.
※This kit is originally a float specification.
Although not shown in the video, a float was also included.
However, I have little experience with radio-controlled aircraft, so I made and installed the tires myself.
incentive 在 incentive - Yahoo奇摩字典搜尋結果 的相關結果
incentive · n. 刺激;鼓勵;動機[U][C][(+to)][+to-v] · adj. 刺激的;鼓勵的,獎勵的 ... ... <看更多>
incentive 在 incentive (【名詞】刺激, 誘因, 獎勵)意思、用法及發音 - Engoo 的相關結果
"incentive" 相關課程教材. She said, “Drug pricing and availability at a level of provider incentives – those are the kinds of things that governments can do ... ... <看更多>
incentive 在 incentive中文(繁體)翻譯:劍橋詞典 的相關結果
Tax incentives have been very effective in encouraging people to save and invest more of their income. 稅收措施在鼓勵人們將收入多儲蓄和多投資方面很有效。 ... <看更多>