📜 [專欄新文章] 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.
👏 歡迎轉載分享鼓掌
同時也有3部Youtube影片,追蹤數超過15萬的網紅ロイドごはん,也在其Youtube影片中提到,あの濃厚豚骨ラーメンの『山岡家』でテイクアウトスタート!今回伺ったのは4月24日からテイクアウトを開始している『山岡家厚木店』です!「山岡家」では、厚木店のほかに相模原店、瑞穂店、つくば中央店の計4店舗で期間未定のテイクアウトラーメンの販売がスタートしました!また、この4つ以外の店舗についてもお店に...
sequentially 在 Facebook 的最佳解答
<30th L'Anniversary Starting Live “L'APPY BIRTHDAY!” Photo Book
Completely Pre-order Made-to-Order Confirmed!!>
Completely covering the 30th L'Anniversary Starting Live “L'APPY BIRTHDAY!” that was held on May 29 and 30, a special documentary photo book will be going on sale.
The photo book will also include a special replica pass with your name written on it!
Fans who were not able to attend the concerts can also get a pass with their names written on it, so please do pre-order to commemorate the 30th L'Anniversary Starting Live “L'APPY BIRTHDAY!”.
【Description】
Size: Modified A4-size / 96-pages approximate
Price (Inclusive of delivery fee): ¥6,000 (tax included)
※The product specifications are subject to change without notice. We thank you for your kind understanding.
【Pre-order Schedule】
June 1, 2021 (Tue) 6:00pm ~ August 31, 2021 (Tue) 11:59pm (local time)
The product will be shipped out sequentially starting from early October.
Details>> https://official-goods-store.jp/larc-en-ciel/
#LAPPYBIRTHDAY #ラピバ #LArc #ラルク #LArcenCiel
==================================
<30th L'Anniversary Starting Live "L'APPY BIRTHDAY!”写真集(仮)
完全予約通販受注決定!!>
5月29日、30日に開催された30th L'Anniversary Starting Live "L'APPY BIRTHDAY!”に完全密着したスペシャルドキュメント写真集の販売が決定しました。
今回はスペシャルレプリカパスにお名前を入れてお届けします!
LIVEに参加出来なかった方にもお名前入りでお届けいたしますので、30th L'Anniversary Starting Live"L'APPY BIRTHDAY!”の記念に是非ご予約ください。
【内容】
サイズ A4変形/96P前後予定
販売価格(配送料込) ¥6,000(tax in)
※仕様は予告なく変更になる場合がございます。あらかじめご了承ください。
【受付スケジュール】
2021年6月1日(火) 18:00~8月31日(火)23:59まで
商品は10月上旬より順次発送予定となります。
詳細はこちら>> https://official-goods-store.jp/larc-en-ciel/
#LAPPYBIRTHDAY #ラピバ #LArc #ラルク #LArcenCiel
sequentially 在 元毓 Facebook 的精選貼文
Apple 2021 Q2 電話法說會摘要
照慣例電話會議一上來就是Apple CEO Tim Cook與CFO Luca Maestri 把主要財務數字炫耀一番,畢竟Q2營收的年成長率54%,太亮眼了。以Apple這種體量的公司,如果將其當作一個國家,營收對比GDP,如此一家私人公司足以排進世界前15國。
對我們股東來說一個CFO揭露的重要訊息是: We ended the quarter with over $204 billion in cash plus marketable securities. We issued $14 billion of new term debt and retired $3.5 billion of term debt leaving us with total debt of almost $122 billion. As a result, net cash was $83 billion at the end of the quarter.
我把Q&A部分放到最前面,CEO與CFO的開場摘要則放到最後。
Q&A部分
許多關於供應鏈是否存在短缺或不足的問題,現代供應鍊大神Tim Cook全都語焉不詳,只強調Q2他們不存在material shortage。
另外就是有提到中國市場成長力道強勁,且2/3的中國iPad和Mac買家都是第一次購買蘋果產品的用戶,這對Apple來說是讓他們感到樂觀的現象。
同樣的,關於Apple Service Business部分Tim Cook一樣東拉西扯就是不肯提供更多訊息,頂多只說從去年開始Apple App Store與開發者的抽成費率降了15%。
還有Apple這次與Facebook鬧翻的隱私權問題,在這個恐怕重創FB營運的決策上,Tim Cook依然官腔滿滿,聲稱「Apple在做對的事」,他們就是要給用戶選擇保護自己隱私的權利,無關Apple或任何其他公司。(有點此地無銀三百兩)
值得一提的是,Tim又補充:「即便沒多少用戶選擇不被隱私追蹤,蘋果也堅持要提供這個功能」(這是說絕大多數用戶不需要這個功能,Apple也堅持要花費成本做下去?你還跟我說是利益用戶而不是針對其他公司?)
Tim Cook 開場:
1. new March quarter records for both revenue and earnings, besting our year ago revenue performance by 54%.
2. iPhone, which grew 66% year- over-year driven by the strong popularity of the iPhone 12 family.
3. iPad grow very strong double digits to its highest March quarter revenue in nearly a decade.
4. In fact, the last three quarters for Mac have been its three best quarters ever
Wearables, Home and Accessories, which grew by 25% year-over-year.
5. Services. We achieved growth of 27% year-over-year and set new records for services in each of our geographic segments.
Over the next five years, we will invest $430 billion, creating 20,000 jobs in the process.
CFO Luca Maestri開場:
1. Our revenue reached a March quarter record of $89.6 billion, an increase of over $31 billion or 54% from a year ago.
2. Products revenue was a March quarter record of $72.7 billion, up 62% over a year ago.
3. Our services set an all-time record of $16.9 billion, growing 27% over a year ago. ( App Store, cloud services, music, video, advertising and payment services. Our new service offerings, Apple TV+, Apple Arcade, Apple News Fitness+)
4. Company gross margin was 42.5%, up 270 basis points from last quarter driven by cost savings, a strong mix and favorable foreign exchange. Products gross margin was 36.1%, growing 100 basis points sequentially also thanks to cost savings and FX, partially offset by seasonal loss of leverage. Services gross margin was 70.1%, up 170 basis points sequentially and mainly due to a different mix. Net income of $23.6 billion, diluted earnings per share of $1.40 and operating cash flow of $24 billion were all March quarter records by a wide margin.
5. During the March quarter, we added more than 40 million paid subs sequentially, and we have now reached more than 660 million paid subscriptions across the services on our platform. This is up $145 million from just a year ago and twice the number of paid subscriptions we are only 2.5 years ago.
6. Apple Watch continues to extend its reach, with nearly 75% of the customers purchasing Apple Watch during the quarter being new to the product.
7. Mac. We set an all-time revenue record of $9.1 billion, up 70% over last year, and grew very strongly in each geographic segment with all-time revenue records in Europe and rest of Asia Pacific and March quarter records in the Americas, Greater China and Japan. This amazing performance was driven by the very enthusiastic customer response to our new Macs powered by the M1 chip.
8. iPad performance was also outstanding with revenue of $7.8 billion up 79%.
9. And UCHealth, a large health care provider in Colorado, was able to reduce per patient vaccination time from 3 minutes to only 30 seconds largely by moving from PC stations to iPhones
10. We ended the quarter with over $204 billion in cash plus marketable securities. We issued $14 billion of new term debt and retired $3.5 billion of term debt leaving us with total debt of almost $122 billion. As a result, net cash was $83 billion at the end of the quarter.
11. we were also able to return nearly $23 billion to shareholders during the March quarter. This included $3.4 billion in dividends and equivalents and $19 billion through open market repurchases of 147 million Apple shares.
12. This will cause a steeper sequential decline than usual. Second, we believe supply constraints will have a revenue impact of $3 billion to $4 billion in the June quarter.
https://yuanyu.idv.tw/2021/05/03/apple-2021-q2-電話法說會摘要/
sequentially 在 ロイドごはん Youtube 的最佳貼文
あの濃厚豚骨ラーメンの『山岡家』でテイクアウトスタート!今回伺ったのは4月24日からテイクアウトを開始している『山岡家厚木店』です!「山岡家」では、厚木店のほかに相模原店、瑞穂店、つくば中央店の計4店舗で期間未定のテイクアウトラーメンの販売がスタートしました!また、この4つ以外の店舗についてもお店によってはGW明けから順次テイクアウトをスタートしていく予定とのことですので、ご興味ある方はぜひお近くの店舗にお問い合わせください!こちらのテイクアウトは麺の硬さだけは指定ができないようですが、トッピングや味の濃さ、脂の量の対応もしてもらえますし、冷凍餃子や乾麺、焼き餃子などもテイクアウト可能とのこと!今回は以前の動画で視聴者の方からオススメ頂いた「特製味噌ラーメン」をお持ち帰りにしてみました!・以前の動画はコチラ→ https://youtu.be/H7wUarNrEggあの豚骨バリバリのラーメンがどんな風に持ち帰れるのか?その味は果たして…?それでは早速動画を見ていきましょう♪
*撮影に際しては、お店の方や周りのお客様に充分配慮して撮影をおこなっています。
Takeout start at that rich pork bone ramen "Yamaoka-ya”! This time, We visited "Yamaoka-ya Atsugi Store", which has started takeout from April 24th! In the "Yamaoka-ya,” take-out ramen for an undetermined period has begun to be sold at a total of four stores, including the Atsugi store, Sagamihara store, Mizuho store, and Tsukuba Central store! Also, for stores other than these four, we plan to start takeout sequentially from the beginning of GW depending on the store, so if you are interested, please contact the store near you! It seems that you can not specify only the hardness of the noodles in this takeout, but you can also handle the topping, the strength of the taste, the amount of fat, and you can also take out frozen gyoza, dry noodles, baked gyoza etc! This time We tried to take home the "special miso ramen" recommended by the viewers in the previous video!・ Click here for the previous video → https://youtu.be/H7wUarNrEggHow can that pork bone crunchy ramen be brought home? Is that taste ...? Let's see the video now ♪
* When shooting, we give due consideration to the shops and customers around us.
いつもありがとうございます!( ´ ▽ ` )
高評価&チャンネル登録もよろしくお願いいたします!
#ラーメン #テイクアウト #山岡家 #ロイドごはん #フラメンコロイド
—————《ロイド のサブチャンネル》—————————————
【フラメンコロイド のサブチャンネルもよろしくお願いします!】
ロイドチャネル
https://www.youtube.com/channel/UCwNlBAUziFWkJZFY_u3t65A
フラメンコロイド
https://www.youtube.com/channel/UCsFJHNg3SR41R2a3vctUInw
—————《本日の店舗情報》—————————————————
『山岡家 厚木店』https://tabelog.com/kanagawa/A1408/A140802/14009434/
—————《twitter》—————————————————————
★ロイドごはん
https://twitter.com/roidgohan
★メロンシート
https://twitter.com/meloncito310
★フラメンコロイド
https://twitter.com/flamenkoroid
—————《instagram》———————————————————-
★ロイドごはん
https://www.instagram.com/roidgohan
★メロンシート
https://www.instagram.com/satoshimelo...
★フラメンコロイド
https://www.instagram.com/flamenkoroid
—————《各サイトの情報》—————————————————
★ロイドごはん《人生をドラマチックに彩る旅とグルメと温泉図鑑》
https://ramenjapan.net/
★メロンシート《フラメンコギターの世界一の旅》
https://pordiotama3.xsrv.jp
★フラメンコロイド 《フラメンコロイドの神話と伝説》
https://flamenkoroid.net
—————《ロイドおすすめ動画はこちら》———————————
【家系ラーメンシリーズ】
https://www.youtube.com/playlist?list=PL6yW17uB9uIVUmOS8qnXrRwcBu8W-uRYZ
【ステーキ&焼肉シリーズ】
https://www.youtube.com/playlist?list=PL6yW17uB9uIUC_ZTqR3chIZ38rvvKiN3D
神回【ラーメン二郎の貴重映像】全増しが出来るまで一部始終を大公開!【ラーメン二郎 ひばりヶ丘店】ramen
https://youtu.be/mBFcdMHyaxA
巨大塊肉に挑戦!【いきなりステーキ】2人で1.5キロの結果は?【飯テロ】
https://youtu.be/lxn_oa-rCvQ
一瞬でファンになる86才職人のおすすめラーメン【ほりえラーメン】感動の鹿児島グルメ
https://youtu.be/0IuRURqh4ek
屋台でラーメンが出来上がるまでの職人技をお見せします【ボギー亭 虎ちゃん】味噌ニンニクラーメン【飯テロ】
https://youtu.be/ZJoloTuYOQ4
神技!いつもびっくりするよ!【がんちゃん】お好み焼きの名店に感動!【飯テロ】× フラメンコロイド 広島県
https://youtu.be/8q_j5QX4-vg
消滅する屋台ラーメンの職人技【幸っちゃん】ラーメンの作り方一部始終【ramen】
https://youtu.be/prw-olhOAyl
![post-title](https://i.ytimg.com/vi/dpmDt0wYtzU/hqdefault.jpg)
sequentially 在 Ytower Cooking channel Youtube 的最佳解答
材料:
A.小嫩土雞1隻、水適量(約鍋具八分滿)、蒜仁15顆、葱段3根、米酒100cc、韓式年糕1包、馬鈴薯2顆、鹽適量、泡菜適量、白飯1碗、海苔絲適量
B.大蛤1200公克、蝦600公克、蒜末60公克
C.透抽2尾、小龍蝦2隻、薑絲50公克
D.三點蟹3隻、薑片9片
Ingredients:
A.1 small tender free range chicken, Suitable amount of water (enough to fill the pot to 1/8'th capacity,) 15 garlic cloves, green onions 3 lengths, 100cc rice wine, 1 Korean style rice cake package, 2 potatoes, a suitable amount of salt and kimchi pickled cabbage, 1 cup of white rice, and a suitable amount of Nori seaweed flakes
B.Large clams 1,200 grams, shrimp 600 grams, garlic powder 60 grams
C.2 squids, 2 freshwater crayfish, minced ginger 50 grams
D.3 Three spotted crabs, 9 slices of ginger
作法:
1.將小嫩土雞放入電鍋中、加入水、蒜仁、1又1/2根的蔥段、米酒,按下開關、蓋上鍋蓋,煮約1小時。
2.馬鈴薯去皮切塊;海鮮洗淨,透抽去除內臟切大圈狀。
3.將透抽和小龍蝦放入蒸籠中,擺上薑絲備用;大蛤和蝦放入蒸籠中,撒上蒜末備用;三點蟹放入蒸籠中,擺上薑片備用。
4.將作法1的小嫩土雞剪成塊,加入韓式年糕、馬鈴薯塊、其餘1又1/2根的蔥段、適量鹽。
5.將作法3的3個蒸籠依序放在作法4的電鍋上,續蒸煮約15~20分鐘至海鮮熟。
6.取下蒸籠後即可邊品嚐海鮮邊吃韓式一隻雞鍋,也可加入適量泡菜一起享用。
7.待一隻雞鍋料吃完後,可再加入白飯,撒上海苔絲,煮成粥享用。
Preparation Method:
1. Put the small tender free range chicken into the pot, put in water, garlic cloves, 1 1/2 green onion roots, and rice wine. Press the switch, cover and cook for about 1 hour.
2. Peel the potatoes and cut into pieces; thoroughly wash and clean out the viscera from the seafood and cut the squid into large circular loops.
3. Place the large clams and shrimp into a steaming basket, put the shredded ginger on top and set aside; The squid can then be put into a steaming basket followed by the freshwater crayfish and sprinkled with garlic powder on top and set aside. Put the three spotted crabs into a steaming basket, lay the ginger slices on top and set this aside.
4. Cut the free range chicken from step 1 into small pieces, add in the Korean rice cakes, potato chunks, the remaining 1 1/2 green onion roots, and a suitable amount of salt.
5. Take the three steamer baskets from step 3 and place them sequentially on top of cooker pot from step 4. Continue cooking for about 15 to 20 minutes until the seafood is cooked.
6. Remove the steaming baskets to sample the seafood while eating the Korean style chicken in the pot. Also, some kimchi can be added in and enjoyed together.
7. After having eaten the chicken, you can then add rice, sprinkle on some Nori seaweed flakes and make an enjoyable porridge.
-
楊桃美食網
http://www.ytower.com.tw
天天買菜 天菜網
http://www.skycook.com.tw
Youtube
https://www.youtube.com/user/ytower01
Facebook
https://www.facebook.com/ytower01
![post-title](https://i.ytimg.com/vi/a6D0PGFlm1g/hqdefault.jpg)
sequentially 在 一二三渡辺 Youtube 的精選貼文
日本初のダチョウ料理専門店、
ライダーズカフェMACHⅢ
大阪府堺市美原区北余部469-6
TEL&FAX072-361ー3171
http://www.h4.dion.ne.jp/~maltuha/index.html
http://www.kurocco.com/cgi-bin/mach3/
ER-6nをベースとしたスポーツツアラーモデル 「ER-6f」 が登場。ツーリングにも実用的なフルカウルを装着し、6nとは一味違う乗り味と使い方をご提供します。エンジンは6nで好評だったパラレルツイン型フュエルインジェクション搭載並列2気筒エンジンを引続き採用し、インジェクション特有のメリハリの効いた特性が力強いレスポンスを感じさせます。車体は乾燥重量178kgと軽量でバランスの良さを実感させます。ロングツーリングでももっと遠くへ行きたくなるような1台になるでしょう。
ブライト希望小売価格¥819,000
Sports tourer model "ER-6f" based on ER-6n appears. I attach a practical full cowl to touring and offer riding taste and how to use that gangs are different from 6n in. The engine adopts two popular parallel twin type フュエルインジェクション deployment parallel cylinder engines in 6n sequentially, and the characteristic that the accent of the injection characteristic worked for lets you feel a powerful response. The body lets you realize a good point of the balance at dry 178kg in weight and light weight. Even long touring will become the one which wants to go farther.
Brightman hope retail price \ 819,000
![post-title](https://i.ytimg.com/vi/xmbVuk-ZYLo/hqdefault.jpg)
sequentially 在 sequentially - Yahoo奇摩字典搜尋結果 的相關結果
sequentially. KK[sɪˋkwɛnʃəlɪ]; DJ[siˋkwenʃəli]. 美式. adv. 相繼地;連續地;結果地. Dr.eye 譯典通. sequentially. 繼續地,從而 ... ... <看更多>
sequentially 在 sequentially - 讀音_用法_例句 - 海词词典 的相關結果
sequentially 的用法和樣例:. 例句. 用作副詞 (adv.) Because the algorithms process elements sequentially, they require input iterators. ... <看更多>
sequentially 在 SEQUENTIALLY在劍橋英語詞典中的解釋及翻譯 的相關結果
sequentially 的例句. sequentially. For it is possible to solve these tasks by making use of the information sequentially. 來自Cambridge English ... ... <看更多>