📜 [專欄新文章] 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.
👏 歡迎轉載分享鼓掌
同時也有4部Youtube影片,追蹤數超過7萬的網紅sherrybyw,也在其Youtube影片中提到,This is seriously my all-time favourite breakfast to make at home. ? Instagram http://www.instagram.com/sherrybyw ☀️ Facebook http://www.facebook.co...
「random seed time」的推薦目錄:
- 關於random seed time 在 Taipei Ethereum Meetup Facebook 的最佳解答
- 關於random seed time 在 Milton Goh Blog and Sermon Notes Facebook 的最佳解答
- 關於random seed time 在 Santai Ben Ashaari Facebook 的最佳貼文
- 關於random seed time 在 sherrybyw Youtube 的精選貼文
- 關於random seed time 在 GreenBeautyKoKo Youtube 的最佳解答
- 關於random seed time 在 GreenBeautyKoKo Youtube 的最佳貼文
random seed time 在 Milton Goh Blog and Sermon Notes Facebook 的最佳解答
The Gospel of Jesus Christ in a tweet.
The part that is missing in many explanations of the Gospel is that Jesus is the Son of God and that He always existed since the beginning as God.
The cross makes no sense without that part. You can’t just proclaim, “Jesus died for your sins!” If any mortal man died on a cross for our behalf, it would be useless because he has sin in the blood which makes his sacrifice unacceptable in God’s eyes.
If you share the Gospel without explaining that Jesus is the eternal Son of God, people will just be thinking, “Who is this random guy that died for my sins? Who cares?”
It is precisely because Jesus is the Son of God that His sinless blood is an infinitely valuable sacrifice, able to atone for the sins of the whole world, throughout all time.
It is like paying a trillion dollars for a hundred dollar debt—it is a massive overpayment.
That is how forgiven you are if you receive Jesus Christ as Lord. Your sin debt is instantly wiped out, and you become righteous in God’s eyes. You didn’t earn it, but received it as a free gift; this is God’s Grace to mankind because He loves us and doesn’t want to see any perish in their sins.
If you have not received Jesus as Lord, you can do so just by believing and speaking a prayer: “Dear Jesus, I receive You as my Lord and Savior. I believe that You died on a cross for my sins, and you were raised from the dead on the third day as a proclamation that all my sins have been perfectly forgiven. You are now seated in Heaven, far above all principalities and powers, and I am looking forward to Your return, just as You promised in the Scriptures. In the meantime, use my life for Your glory. Amen!”
Re-share this post to plant a seed of the Gospel in the hearts of your friends on Facebook.
Follow me on Twitter too for more daily Gospel bites: http://twitter.com/miltongohblog
random seed time 在 Santai Ben Ashaari Facebook 的最佳貼文
An overview for the industry and buyers about olive oil standards and testing, including tips for quality monitoring and good handling.
.
Olive oil is a valuable product, especially when compared with less-expensive, lower-quality cooking and seed oils. In order to protect olive oil’s value and ensure authenticity in the olive oil market, detailed grade standards and testing measures have been developed.
.
These standards are maintained by the International Olive Council (IOC), a United Nations chartered organization created in 1959. Based in Madrid, Spain, the IOC facilitates international research and developments in the olive oil industry in order to promote fair trade worldwide. The 25 countries covered as IOC members represent 97% of the world’s olive oil production.
.
Standards based on the IOC trade standard have been adopted by the USDA and a number of state legislatures including Connecticut, California, New York and Oregon. About 97% of all the olive oil consumed in the U.S. is imported, overwhelmingly from producing countries that are members of the IOC. Members of the North American Olive Oil Association agree to comply with the IOC standards.
.
To support monitoring and enforcement of the trade standards, each year the IOC certifies or re-certifies testing laboratories and sensory panels around the world. The list of certified labs and panels is published annually on the IOC website, and suppliers and organizations such as the NAOOA rely on these certified labs and panels for full and independent assessments of olive oil quality and purity.
.
There are a handful of quality measures and about 30 chemical measures required to confirm compliance with the standards, and testing can be time-consuming and expensive. It is critical for buyers to work closely with their suppliers and perform random confirmations to ensure they are receiving authentic quality olive oil.
.
Many buyers and importers will invest in supplier visits and frequent testing when beginning a relationship. Once partnerships are established, an on-going quality and authenticity control plan is developed based on the volume of oil, number of lots and capabilities and budget of the supplier and buyer.
.
Topics to cover with an olive oil supplier include the traceability system, frequency of testing, certifications of the testing facility, and any special buying preferences.
.
Many companies perform quality screenings which can be carried out more frequently and at a lower cost than full authenticity testing. Such screenings are beneficial, but should be supplemented with complete purity testing. Quality should also be monitored over time because it changes and can be negatively affected by storage and handling.
.
To maintain optimum quality implement these tips for good handling...:
.
- Store olive oil in a dark, temperature-controlled warehouse or stockroom, because heat and light can damage the oil
.
- Protect olive oils from direct sunlight and fluorescent lighting
.
- Rotate stock faithfully and check best-by dates regularly
.
The NAOOA offers a testing coordination service that allows buyers and importers to submit oils independently and receive a full analysis back from an IOC-certified lab and panel. Contact us for more information.
random seed time 在 sherrybyw Youtube 的精選貼文
This is seriously my all-time favourite breakfast to make at home.
? Instagram http://www.instagram.com/sherrybyw
☀️ Facebook http://www.facebook.com/sherrybyw
? Snapchat https://www.snapchat.com/add/sherrybyw
•••••••••••••••••••••••••••• ABOUT ME •••••••••••••••••••••••••••••••••••••••••••••
I'm Sherry and I love filming videos of all sorts - travel, lifestyle, and general entertainment. I speak English and Cantonese, and am currently working on my Mandarin. I'm originally from Canada (woo Toronto) and Hong Kong, but I currently work and live in Singapore!
What do I do full-time? https://www.youtube.com/watch?v=zbTk5nKjuEc
Here are some more random facts about me: https://www.youtube.com/watch?v=o0ufTue-O9k
Let's chat!
For random questions - sherry@abrushofbeauty.com
For business inquiries - info@abrushofbeauty.com
•••••••••••••••••••••••••••• MORE VIDEOS •••••••••••••••••••••••••••••••••••••••••••
THE YOUNG SINGAPORE EXPAT SERIES: https://www.youtube.com/playlist?list=PLkex7OLfqFV2kr-6SCCYeWHraPgyEzbuU
自然捲髮造型分享 ?How I Curl My Hair: https://www.youtube.com/watch?v=rRGTU7WNsG8
10分鐘去學的眼鏡化妝!! Glasses Makeup: https://www.youtube.com/watch?v=D92l5gnyzlY
Sisters Q&A!!!: https://www.youtube.com/watch?v=4pYfg3PV8Dk
自信心 ♡ How am I so confident?!: https://www.youtube.com/watch?v=a2pFq92Vf70
•••••••••••••••••••••••••••• CAMERA, EQUIPMENT, AND MUSIC ••••••••••••••••••••••••••••••••
https://soundcloud.com/ikson
#diet #fitness #weightloss
DJI Osmo Pocket
Canon EOS 70D
Canon EF-S 18-55mm f/3.5-5.6
Canon EF-S 24mm f/2.8
Canon EF 50mm f/1.8
Canon
Sony NEX-5R
Minolta 35, 50, and 85mm
Iphone 7+

random seed time 在 GreenBeautyKoKo Youtube 的最佳解答
Hello sweet macarons,
BeautyKoKo web site: http://beautykoko.gostorego.com/
BeautyKoKo Facebook page: https://www.facebook.com/SmallsimpleBeauty
BeautyKoKo email: smallsimplebeautie@gmail.com
It was a difficult to understand Free Radicals and it was not easy for me to use a simple way to explain the relationship between Free Radicals and Anti-oxidant. If you can understand, can you give me a thumb up and comment below.
♥Giveaway♥
You can win this Ralph Polo shopping bag. Please follow the 4 simple rules down below and the contest will end on November 25th, 2012. The winner will be chosen at random from all over the world. Thank you again for your support!
♥GIVEAWAY Guidelines!
1. Be A Subscriber To My Channel a
2. Please "Like" my ♥潔面同時護膚保濕♥Cleansing your face♥ videos
3. Please add My Facebook Page to "Interest List" and this post http://www.facebook.com/SmallsimpleBeauty
4. Please let me know how you flight with free radicals?
It is not difficult to maintain healthy and flawless skin. What we need to do is to flight with the free radicals everyday and night. For internal and external, we have to absorb more anti-oxident ingredients like green tea, Vitamin A, C, E, green tea, amino acids and grape seed extract.... etc. Those anti-oxident ingredients can help us to flight with the free radicals.
For this Hylunia's day lotion, I really like it because it is full of the anti oxidant ingredients and it is no greasy at all. It helps my acne at the same time. My face is so smooth and hydrated.
Ingredients: Organic Aloe Vera Extract, Hyaluronic Acid / Hyaluronic Complex Solution, Octyl Methoxy Cinnamate (sun screen), Anti-Microbial ComplexTM, Proprietary Emulsifying Complex and Neutralizer, Green Tea and Chrysanthemum Indicum Extract, Peptide Complex (Saccharomyces / Copper / Manganese / Zinc / Selenium Ferment), Cucurbita Pepo Seed Extract (Pumpkin Seed Peptide-Curcubitine), Micro-Sized Titanium Oxide (sun block), Squalane from Olive, Shea Butter, Alteromonas Macleodii Ferment Extract (From Volcanic Ocean), Oat, Turmeric , Grape Seed Extract, Encapsulated Super Oxide Dismutase.
Hylunia 日間保濕修護日霜
深層滋潤皮膚, 同時鎖緊皮膚水份, 改善脫水情況
撫平細紋、皺紋, 令皮膚更具彈性和健康
有防曬功能
成份: 有機蘆薈精華,辛基甲氧基肉桂酸(防曬),抗微生物ComplexTM(抗微生物複合™是Hylunia護膚品的專有配方,這是20年的研究結果,利用植物的天然抗微生物性能的方法代替傳統的有害的防腐劑),綠茶和野菊花提取物,肽複合物(酵母/錳/銅/鋅/硒發酵),西葫蘆籽提取物(南瓜子肽Curcubitine),微米級二氧化鈦(防曬),橄欖角鯊烯(squalene),乳木果油(Shea Butter),單細胞菌(從火山岩海洋1.5M下提取的植物)燕麥,黃薑,葡萄籽,海藻。

random seed time 在 GreenBeautyKoKo Youtube 的最佳貼文
BeautyKoKo shopping web site: http://beautykoko.gostorego.com/
BeautyKoKo Facebook page: https://www.facebook.com/SmallsimpleBeauty
BeautyKoKo email: smallsimplebeautie@gmail.com
Here are the lucky gals:
Gigi Cheng eyeshadow 7564
Apple Hui lip gloss 2111
Faa L lip gloss 9014
DragonFly gloss 9014
Please send me a message with your address at the end of November, 2012
Hello my fairladies,
Updated version of Hylunia's organic face cleaning review, effective face cleaning tips & testing on a guest.
♥Giveaway♥又有禮物鳥♥
You can win one of these four items. Please follow the 4 simple rules down below and the contest will end on November 20th, 2012. The winner will be chosen at random from all over the world. Thank you again for your support!
♥GIVEAWAY Guidelines!
1. Be A Subscriber To My Channel
2. Please "Like" my ♥潔面同時護膚保濕♥Cleansing your face♥ videos
3. Please "Like" My Facebook Page and add to "Interest List" http://www.facebook.com/SmallsimpleBeauty
4. Please let me know which item do you like and which video you like the most??
I am happy when you are happy:)
Items included:
1. elf hypershine lipgloss 9014
2. elf hypershine lipgloss 2111
3. elf hypershine lipgloss 9014
4. Physicians Formula Nude eyes 7564
For this video
A long time ago, I love those bubbles or foam facial cleansers since I believed that they can help me to clean my face. However it was not true. When you find that your cleansers can make a lot of foams, you have to check whether they have Parabens, Grapefruit Seed Extract, Sodium Lauryl Sulfate, Formaldehyde, Propylene Glycol, Alcohol, Color and Fragrance. Those ingredients are going to worse your skin's health and you skin is going to easily dry out, sensitive and have breakouts.
Today I would like to share some organic, natural and effective facial cleansers. I use them everyday.
Facial Cleansing Lotion:
Recommended for all skin types including dry and sensitive skin and conditions such as rosacea, eczema and psoriasis
Ingredients: Organic Aloe Vera Extract, Propriety Surfactant Blend, Glycerin (USP-Kosher-Plant Derived), Sesame Oil, Hyaluronic Complex Solution (plant derived), Propriety Emulsifying Complex and neutralizer and Anti-Microbial Complex™
Facial Cleansing Gel:
Recommended for normal and combination skin
Ingredients: Organic Aloe Vera Extract, Propriety Surfactant Blend, Hyaluronic Complex Solution (plant derived), Sclerotium Gum (from straw), Sesame Oil,Citric Acid (from citrus fruits) and Anti-Microbial Complex™.
Salicylic Facial Cleansing Gel:
Recommended for oily and acne-prone skin types. It can deep cleanses to minimize excess oil, blackheads, whiteheads, acne, ingrown hairs and other blemishes.
Ingredients:Organic Aloe Vera Extract, Proprietary Surfactant Blend, Extracts Of Bilberry, Sugar Cane, Sugar Maple, Lemon and Orange, Hyaluronic Complex Solution (plant derived), Glycerin (USP-Kosher-Plant Derived), Salicylic Acid, Citric Acid (from citrus fruits), and Anti-Microbial Complex™.
Application Ritual: Apply a small amount between moist hands and massage 20 seconds over face and neck, avoiding eye area. Rinse thoroughly with luke-warm water. Use daily, morning and night.
Those above cleansers are made entirely without synthetic preservatives and use nature's very best to gently remove impurities from your skin while preserving your skin's natural moisture. PH balanced for all skin types. They can remove impurities without losing critical natural oils from your skin. This gentle yet effective cleansers are water-activated, doesn't irritate sensitive skin and keeps your skin hydrated while removing dirt and impurities.
Since our skin's conditions are changed from time to time, I always buy different kinds of cleansers for my face. For Mia (My niece), I did not ask her so say anything before. Thus this was her true feelings when she said her skin was better and she liked her skin now.
If you guys are interested in buying those Hylunia's products, please go to my Facebook page and place the order. Since my web site is still under construction. We would like to take the orders by sending us emails and messages
BeautyKoKo's Facebook page
https://www.facebook.com/SmallsimpleBeauty
For those buyers:
BeautyKoKo 購物須知
FaceBook Post
1. 只要係心儀貨品下面留言或email: smallsimplebeautie@gmail.com
2. 我們會盡快以FaceBook 留言或email確認訂單
3. 1-2個工作天內付錢到 beautykoko paypal 户口,確認后,客人將會在10﹣14日工作天左右收到貨品
所有價品將會包括 稅金, 國內運費, 國際運費
**注意*** BeautyKoKo只接受Paypal付款
另外,因為有時差的關係,郵件和訊息有可能延遲, 不便之處,敬請原諒!!
BeautyKoKo 的購物網站將會盡快啟用^^

random seed time 在 datetime函式和random.seed()函式的應用- IT閱讀 的相關結果
時間間隔(這是一個time模組很有用的) ... random.seed()是隨機數種子,也就是為隨機數提供演算法,完全相同的種子產生的隨機數列是相同的,. ... <看更多>
random seed time 在 Python random.seed() function to initialize the ... - PYnative 的相關結果
By re-using a seed value, we can regenerate the same data multiple times as ... ... <看更多>
random seed time 在 Python: Random System time seed - Stack Overflow 的相關結果
import random from datetime import datetime random.seed(datetime.now()). ... <看更多>