📜 [專欄新文章] 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.
👏 歡迎轉載分享鼓掌
同時也有120部Youtube影片,追蹤數超過56萬的網紅kottaso cook【kottaso Recipe】,也在其Youtube影片中提到,◆こっタソ動物園チャンネル 新しいチャンネルです!こちらもおヒマな時にどぞ。 ⇒https://www.youtube.com/c/こっタソ動物園-kottasoanimals ご視聴ありがとうございます。 Thank you for watching I want to deliver deli...
「for a long period of time」的推薦目錄:
- 關於for a long period of time 在 Taipei Ethereum Meetup Facebook 的最佳解答
- 關於for a long period of time 在 IELTS Nguyễn Huyền Facebook 的最佳解答
- 關於for a long period of time 在 Facebook 的最佳貼文
- 關於for a long period of time 在 kottaso cook【kottaso Recipe】 Youtube 的精選貼文
- 關於for a long period of time 在 ロイドごはん Youtube 的最佳貼文
- 關於for a long period of time 在 Tziaaa Tan Youtube 的最讚貼文
- 關於for a long period of time 在 Setting a timer for a long period of time, i.e. multiple minutes 的評價
- 關於for a long period of time 在 Setting a timer for a long period of time, i.e. multiple minutes 的評價
for a long period of time 在 IELTS Nguyễn Huyền Facebook 的最佳解答
TỪ VỰNG IELTS - CHỦ ĐỀ THROWAWAY SOCIETY
🎯PHẦN TỪ VỰNG
- throwaway society: xã hội mà trong đó người ta sử dụng đồ đạc trong một thời gian ngắn sau đó vứt chúng đi, mua thứ đồ mới
vpurchase the latest version of things: mua phiên bản mới nhất
- encourage somebody to do something: khuyến khích ai đó làm gì
- to be in good condition and perfectly functional: trong tình trạng tốt và các chức năng hoạt động tốt
- overconsumption = excessive consumption: việc tiêu thụ quá mức
- overproduction = excessive production: việc sản xuất quá mức
- long-lived products = durable products = products that are made to last for a long period of time: những sản phẩm có tuổi thọ dài
- short-lived products = non-durable products = products that are made to last for a short period of time: những sản phẩm có tuổi thọ ngắn
- repurchase = buy again: mua lại
- repeat customers: những khách hàng sẽ mua hàng lại ở cửa hàng họ đã mua
- make a dent in your finance: làm giảm số tiền bạn đang có
- higher profit margins for manufacturers: lợi nhuận biên lớn hơn cho các nhà sản xuất
- tempt customers into buying the latest, novelty items: thu hút khách hàng mua những sản phẩm mới nhất
- disposable products: những sản phẩm dùng 1 lần rồi vứt đi
- solid waste generation rates: tỷ lệ thải ra chất thải rắn
- environmental degradation: sự suy khóa môi trường
- contaminate soil and water: làm ô nhiễm đất và nước
- increase consumer spending: tăng chi tiêu của khách hàng
- bad spending habits: thói quen tiêu xài xấu
- leftover food: đồ ăn thừa
- a new version with more features: phiên bản mới với nhiều tính năng hơn
- have a negative/detrimental/harmful effect on: có ảnh hưởng có hại lên...
- buy things that you do not really need: mua những thứ mà bạn không thực sự cần
- a waste of money: một sự lãng phí tiền của
- buy new things to relieve stress or anxiety: mua đồ mới để giải tỏa căng thẳng và lo âu
- overspend = spend beyond one's income: chi tiêu quá mức
- huge amounts of toxic waste: 1 lượng khổng lồ chất thải
- to be discharged into the environment: bị thải ra môi trường
- encourage people to reuse and recycle more: khuyến khích người dân tái chế và tái sử dụng nhiều hơn.
- get into serious debt: bị mắc nợ nghiêm trọng
🎯PHẦN BÀI MẪU
These days people in some countries are living in a “throwaway” society which means people use things in a short time then throw them away. What are its causes and what impacts can it have?
Dịch đề: Ngày nay người dân ở một số quốc gia đang sống trong một “xã hội bỏ đi” nghĩa là người ta sử dụng đồ đạc trong một thời gian ngắn sau đó vứt chúng đi. Nguyên nhân và ảnh hưởng mà xã hội này gây ra?
The topic of “throwaway society” has been discussed in recent years. In this society, people tend to throw away their old items regardless of whether or not they still work and purchase the latest version of things. This essay will look at some primary reasons for this phenomenon and the adverse impacts that it could have on individuals and the environment.
There are several causes of the throwaway society and I think advertising could be the first culprit. Advertisements encourage people to purchase goods and services that they do not really need by delivering a message that possessing the latest version of an item could improve a person’s self-image, confidence and even social status. For example, many of today’s teenagers spend nearly $1,500 buying iPhone X to show that they are wealthy and fashionable even though their old phones are still in good condition and perfectly functional. Another cause is mass production of non-durable goods which are often used once and thrown away. These products are much cheaper and more convenient than durable ones, hence, attract a large number of customers.
Individuals living in the throwaway society could suffer a great deal. They could easily get into serious debt if they get into the habit of buying the latest, novelty items. Many teens are being burdened with thousands of dollars in credit card debt for their unnecessary purchases, which could lead to depression and anxiety. Environmental degradation is another problem facing the throwaway society. Due to excessive production of disposable goods, huge amounts of hazardous waste are being discharged into the environment, which directly contaminates soil and water.
In conclusion, there are various factors leading to the advent of our throwaway society and increasing consumer debt and environmental damage are the two major problems which result from this society.
(299 words, written by Nguyen Huyen)
PHẦN VÍ DỤ: https://ielts-nguyenhuyen.com/tu-vung-ielts-chu-de-throwaway-society-dich-tu-chi-tiet/
#ieltsnguyenhuyen
for a long period of time 在 Facebook 的最佳貼文
Due to this Critical Pendamic, wearing mask for a long period of time will cause of difficulty breathing. Whats the methods to calm this down?
Start with just a roll on the outside edges of the mask.
Ophelia Winter‘s Oil ❄️
1.Echinacea Angustifolia
Decrease infection of the respiratory tract
2.Melaleuca Alternafola Leaf
To prevent yourself from getting the flu, keep your immune system strong.
3.Mentha Piperita
Used to treat Muscle Pain Relief – effective natural painkiller and muscle relaxant and also tension headaches.
More info : https://www.opheliaglobal.com
for a long period of time 在 kottaso cook【kottaso Recipe】 Youtube 的精選貼文
◆こっタソ動物園チャンネル
新しいチャンネルです!こちらもおヒマな時にどぞ。
⇒https://www.youtube.com/c/こっタソ動物園-kottasoanimals
ご視聴ありがとうございます。
Thank you for watching
I want to deliver delicious Japanese-food recipes to the world
【材料】(保存期間:冷蔵で約3日)
●キュウリ:6本
●白だし(10倍濃縮):大さじ6(薄めがお好みの方は大さじ4くらい)
●醤油:大さじ2(薄めがお好みの方は大さじ1くらい)
●塩昆布:大さじ2
●酢:大さじ2
●豆板醤:大さじ1(コチュジャンでもOK)
●砂糖:小さじ2(ラカントとかにするとより糖質を抑えれます)
●唐辛子:お好み量
●生姜:お好み量
●お好みでおろしニンニクか刻みニンニクをプラスしてもよりやみつきに♪
※二度漬けは出来ません。
※今回の味の濃さだとお酒だけじゃなくご飯もすすむ感じの濃さです♪
味の濃さは動画でお伝えしている通り、お好みで調節してみて下さい。
-------------------------------------------------------
今回は食べて貰った方に必ずレシピを聞かれるくらい大好評の
『超やべぇキュウリの1/2本漬け』を作りました。
何度も漬けてきて分かったんですけど1本より1/2本の方が漬けやすいw
市販品やお店でも食べる事はあるんですが
やっぱりこの味が一番大好きで
食べて貰った方にも他の味だと物足りない…
って何度も言われたくらい(これ言われるの凄く嬉しい♪)
暑い日や夏の季節になると僕も必ず作るんです(*^^*)
酸味や塩気もちょうど良くて(自分好みに出来るのも良いよね♪)
後からほんのりピリっとくる感じと生姜の清涼感が
暑さを吹き飛ばしてくれて最高なんです!!!
あとこのあごだし入りの白だしと塩昆布、それから豆板醤のお陰で
味にコクと奥行きが出てキュウリだけなのにお酒とご飯が超すすむんです♪
暑い日はこれとビールさえあれば他は何もいらないですよ!(おにぎりあったら尚よしw)
作り方も漬けるだけ!!とっても簡単なので
『超やべぇキュウリ』是非一度お試し下さい。
【Ingredients】 (Preservation period: about 3 days refrigerated)
● Cucumber: 6
● Clear soup base (10x concentrated): 6 tablespoons
● Soy sauce: 2 tablespoons (or about 1 tablespoon if you prefer a
lighter soy sauce)
● Sio-Kombu (seasoned seaweed): 2 tablespoons
● Vinegar: 2 tablespoons
● Dou ban jiang: 1 tablespoon(gochujang is also fine)
● Sugar: 2 teaspoons (you can use lakanto to reduce sugar content)
● Chili pepper to taste
● Ginger: As much as you like
● Ginger: to taste
※ You can't marinate it twice.
※ The flavor is so thick that it can be enjoyed with rice as well as alcohol ♪
You can adjust the intensity of the flavor to your liking as shown in the video
-------------------------------------------------------------
This time, I made "Amazingly Yummy Half Cucumber Pickles", which is so popular that people who have eaten it always ask me for the recipe.
I've been pickling cucumbers for a long time, and I've learned that it's easier to pickle 1/2 cucumber than 1 cucumber lol
I've eaten it in stores and stores, but this flavor is my favorite,
and I've been told many times by people who've eaten it that other flavors are not good enough (I'm very happy to hear this ♪)
Whenever it's hot or in the summer season, I make it (*^^*)
It has just the right amount of sourness and saltiness (it's also good that you can make it to your own taste ♪)
The slight spiciness afterwards and the coolness of the ginger blow away the heat!!
Also, the clear soup base with fish stock, salted kelp, and Dou ban jiang add a richness and depth to the flavor, and even though it's just cucumbers, it goes great with drinks and rice ♪
When it's hot, all you need is this and beer, and you don't need anything else! (If you have Onigiri (rice balls) it's even better lol)
All you have to do is pickle it! It's very easy to make, so please give "Amazingly Yummy Half Cucumber Pickles" a try.
●Instagram
⇒https://www.instagram.com/kossarishuntaso/
●twitter
⇒https://twitter.com/kottaso_recipe
●連絡先
⇒kossarisyuntaso@gmail.com
#こっタソの自由気ままに #漬けるだけ #超やべぇキュウリ #きゅうりの1/2本漬け #きゅうりの一本漬け #超やべぇ野菜漬け #やみつき野菜 #きゅうり浅漬け #Cucumber #JapanesePickles #和食 #低糖質おつまみ #糖質制限レシピ #ヤセ筋 #低糖質レシピ #ヘルシー #ダイエットレシピ #激痩せ #糖質制限レシピ #ロカボレシピ #dietfood #lowcarbdiet #dietrecipe #晩ごはんレシピ #ご飯泥棒 #おかず #極上レシピ #ワンパンレシピ #時短レシピ #おうちごはん #至福の料理 #ご飯のお供 #太らないレシピ #やみつきレシピ #酒のつまみ #簡単つまみ #こっタソレシピ #男飯レシピ #mukbang #먹방 #男子ごはん #HomeCooking #StayHome #大食い #男ウケ料理 #晩酌 #自炊 #酒の肴 #簡単レシピ #弁当 #作り置き #常備菜 #Bento #recipesfordinner #マツコの知らない世界 #WithMe #Eazyrecipe #モッパン #から揚げ #唯一無二の絶品レシピ #こっタソ動物園
for a long period of time 在 ロイドごはん Youtube 的最佳貼文
お弁当の定番おかず…「から揚げ」!『から好し』の唐揚げ弁当をテイクアウトしてみました!「から好し」はガストやジョナサン、バーミヤンなどを運営する「すかいらーくグループ」が新たに手がけた唐揚げ専門のお店です。2017年、埼玉に1号店がオープンしました。から好し店舗は90店舗ですが、併設ガストを合わせると600店舗を超えるそう!今回もガストでテイクアウトできました。からあげは、古くは江戸時代から作られてきた説もあるくらい昔から日本で親しまれてきた調理方法です。肉に衣をつけて油で揚げるというシンプルなレシピですが、その味はもはや子どもから大人まで親しまれる日本のソウルフード!から好し初体験、早速ご覧ください!
*感染対策を徹底して撮影を行っています。
*撮影に際しては、お店の方や周りのお客様に充分配慮して撮影をおこなっています。
A classic side dish for bento ... "Karaage"! I took out the fried chicken lunch box from "Karayoshi"! "Karayoshi" is a restaurant specializing in fried chicken newly created by the "Skylark Group" that operates Gust, Jonathan, Bamiyan, etc. In 2017, the first store opened in Saitama. There are 90 favorite stores, but it seems that the total number of stores will exceed 600! I was able to take out with gust this time as well. Karaage is a cooking method that has been popular in Japan for a long time, as there is a theory that it was made from the Edo period. It's a simple recipe of battering meat and frying it in oil, but the taste is Japanese soul food that is loved by children and adults alike! Please have a look at your first experience!
* We take thorough measures
against infection.*When shooting, we give due consideration to the shop and customers around us.
いつもありがとうございます!( ´ ▽ ` )
高評価&チャンネル登録もよろしくお願いいたします!
#から揚げ #から好し #肉 #ロイドごはん #フラメンコロイド
—————《姉妹チャンネル》—————
【姉妹チャンネルもよろしくお願いします!】
メロンシートジャーニー
https://www.youtube.com/channel/UCwNlBAUziFWkJZFY_u3t65A
フラメンコロイド
https://www.youtube.com/channel/UCsFJHNg3SR41R2a3vctUInw
🍀「ロイドごはん」公式LINE
https://lin.ee/ow4OdaV
—————《本日の店舗情報》—————————————————
『から好し』
https://www.skylark.co.jp/karayoshi/
—————《ロイドごはんのおすすめ動画 ROIDGOHANs’ Recommended video》———————————
超デカ盛り【上州屋】唐揚げと爆盛りライスで大食い!
https://youtu.be/RlxlPP92kWc
78才おじいちゃん屋台ラーメンの朝『幸っちゃん』夜明けの銀座 【飯テロ】Old Style Ramen yatai Japanese Street Food
https://youtu.be/YHiWYvhxUI4
神回【ラーメン二郎の貴重映像】全増しが出来るまで一部始終を大公開!【ラーメン二郎 ひばりヶ丘店】ramen
https://youtu.be/mBFcdMHyaxA
—————《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
—————《各サイトの情報》—————————————————
★ロイドwalker《人生をドラマチックに彩る旅とグルメと温泉図鑑》
https://ramenjapan.net/
★メロンシート《フラメンコギターの世界一の旅》
https://pordiotama3.xsrv.jp
★フラメンコロイド 《フラメンコロイドの神話と伝説》
https://flamenkoroid.net
for a long period of time 在 Tziaaa Tan Youtube 的最讚貼文
Finally! We done 95% of our #shengyixtziahome Reno, there’s still corners that are work-in-progress. However, we thought, we should do the house tour video now, and slowly work on the remaining 5%, where we might or might not do another YouTube video, but would definitely share it on our Instagram. So stay tune.
This house was the effect of MCO I would say, if it wasn’t because of us being forced to stay home for such a long period of time last year, we might not thought of moving because we were so used to working outside, and home was just a place for us to sleep in after a long day. We never really put it thoughts about moving in to a bigger space, and possibly the next stage of life.
Back to what has already done for #shengyixtziahome thus far... I just want to say, I’m so proud of us! Hard work paid off, when we finally got this house that is comfortable enough for us to stay in the entire day, and a place we can finally host our family & friends for drinks & dinner. Yay!
We are just really HAPPY in this space, that is just so #shengyixtzia. Hahah.
Alright, I hope you enjoy the video.
& here’s the link of the products I mentioned in the video.
All Areas:
Flooring & Wall Paint: https://www.vasarimalaysia.com
Smart Home System: https://wpm-home.com
Curtains & Blinds: https://www.mk.com.my
Built-in Cabinet (Wardrobe, Wine Rack, Mirrors, Tv Cabinet, etc): https://www.instagram.com/fch_furniture/
Ceiling Spotlight & Cabinet Lightings: GT Electric - Papa Tan
Plaster Ceiling - Papa Tan’s Team
Interior Ideation: https://www.instagram.com/madnessdesignstudio/
Living Room:4 Seater Sofa: https://www.instagram.com/hugosofa/ (custom made)
1 Seater Sofa: https://m.tb.cn/h.4MfZ6lK?sm=c3725d
Coffee Table: https://instagram.com/crownlivin_my?igshid=1mqr36fguptzc
Side Table: https://m.tb.cn/h.4NKK4rH?sm=deb281
Carpet: https://m.tb.cn/h.4n98HBq?sm=29a66d
Dining Area:
Pendant Light: GT Electric - Papa Tan
Drawings: https://instagram.com/sanctvsofficial?igshid=7pnfkgqnj8xa
Dining Table & Chairs: https://instagram.com/crownlivin_my?igshid=1mqr36fguptzc
Dry Kitchen:
Lighting: https://m.tb.cn/h.4mF8FDo?sm=dd4c36
Cutlery Holder: https://rw.josephjoseph.com/products/drawerstore-cutlery-utensil-gadget-organiser-grey?variant=32586212474940
Plates: https://www.lecreuset.com.my
Cupboard Organiser: https://s.lazada.com.my/s.XTl50
Fridge Organiser: https://s.lazada.com.my/s.XTlUe
Coffee Machine: https://www.nespresso.com/my/en/order/machines/nespresso-creatista-plus-metal-stainless-steel-coffee-machine
Wet Kitchen:
Knife Organizer: https://rw.josephjoseph.com/collections/sale
Sink Caddy: https://rw.josephjoseph.com/products/caddy-large-sink-tidy-grey
Chopping Board: https://rw.josephjoseph.com/collections/chopping-boards/products/folio-chopping-board-set-editions-blue?variant=32586279747644
Garlic Storage: https://s.lazada.com.my/s.XTlUG
Seasoning Storage: https://m.tb.cn/h.4NKHXe9?sm=2ab9ef
Oil Storage: https://www.ikea.com/my/en/p/oertfylld-3-piece-oil-vinegar-set-glass-stainless-steel-20391352/?
Dishwasher: https://s.lazada.com.my/s.XTmHH
Washer dryer: https://s.lazada.com.my/s.XTmsG
Guest Room:
Sofa Bed: https://m.tb.cn/h.4NKqqYK?sm=132cc7
Table: https://m.tb.cn/h.4n98hLy?sm=257250
Carpet: https://m.tb.cn/h.4n9Qvzp?sm=cdf76e
Lighting: https://m.tb.cn/h.4mF9Wqz?sm=1626c2
Mirror: https://m.tb.cn/h.4mFQv4w?sm=e6e9d4
Mirror Box: https://m.tb.cn/h.4NKNQH7?sm=3e7462
Master Bed Room:
Bed: https://sertamattress.com.my/product/grand-canyon/
Beddings: Hallmark Silk Beddings from Pavillion Elite
Acrylic Bag Storage: https://m.tb.cn/h.4NKr37u?sm=14730f
Jewellery Storage: https://m.tb.cn/h.4NKI5hr?sm=0472a6Lipstick Storage: https://s.lazada.com.my/s.XTl5p
Work Room:
Printer rack: https://s.lazada.com.my/s.XTmQu
Sneaker Room:
Storage Rack: Papa Tan
Storage Box: https://instagram.com/towerbox_malaysia?igshid=1grcl3ptogchy
Hope you all enjoyed the video!
& Happy shopping! Heh!
for a long period of time 在 Setting a timer for a long period of time, i.e. multiple minutes 的推薦與評價
I want to use firebase auth with react native for Login and Signup but I got a yellow error: Setting a timer for a long period of time, ... ... <看更多>
for a long period of time 在 Setting a timer for a long period of time, i.e. multiple minutes 的推薦與評價
... <看更多>