📜 [專欄新文章] 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.
👏 歡迎轉載分享鼓掌
同時也有57部Youtube影片,追蹤數超過0的網紅톡! TALK! 후지이 미나,也在其Youtube影片中提到,#후지이미나 #영화 #버킷리스트 민트들과 다양한 작품에 대해 이야기해보는 시간 무드톡! 그 첫번째 이야기, 영화 "버킷리스트" 지금 시작합니다~ ミントの皆さんとさまざまな作品について話してみる時間、ムードトーク! その第1話は、映画「最高の人生の見つけ方」、今、始まります〜 ...
mints 在 Facebook 的最佳解答
เพลงแรกในชีวิต และล้านวิวแรกในชีวิต ขอบคุณมากครับ❤️🙂. Mints
mints 在 Coach Anuar Facebook 的最讚貼文
GULA PERANG vs GULA PUTIH
Dalam group coaching sy pagi ni kami diskas lg ttng kalori baik vs kalori buruk kan.. Mmg benar beras perang lebih baik dari beras putih biasa dek kerana kandungan serat nya. Tp bagaimana pula dgn Gula Putih vs Gula Perang? Ada beza kah?? 🤔
Coach Anuar nak share lagi gula adalah salah satu faktor kegemukan kerana 1 gram gula memberi anda 4 kalori tanpa khasiat yang lain. Pengambilan gula atau kalori berlebihan yang tidak digunakan oleh tubuh akan bertukar menjadi lemak.
24 sudu teh gula akan menyebabkan keberkesanan sel darah putih menurun sebanyak 92% dan ini memakan masa sebanyak 5 jam. Proses penuaan menjadi lebih cepat menerusi pemecahan oksigen akibat pengambilan gula.
Tak ada beza pun. Maknanya, gula putih dan gula perang mempunyai kalori yang sama. Kerana kedua2nya tiada kandungan serat.
Jom baca panduan pengambilan pemanis:
1. Gula putih dan perang : kalori adalah 1g = 4kcal. Gula putih melalui proses penghasilan yang berbeza iaitu bleaching. Tetapi, kedua-duanya adalah jenis gula ringkas.
2. Stevia : kalori rendah atau boleh dikatakan tidak berkalori dan bersifat neutral. Pengganti pemanis yang baik.
3. Madu : kalori adalah 1g = 3kcal. Sangat bagus untuk diamalkan kerana mengandungi kandungan yang merangsang pertahanan badan.
4. Equal/Palsweet : tidak berkalori. Tetapi, membebankan buah pinggang untuk menapis serta membuang artificial sweetness daripada badan. Pemanis tiruan yang paling tidak bagus walaupun ia tidak menggemukkan.
5. Alcohol sugar : terdapat dalam chewing gum, candy dan mints yang kononnya bersifat 'sugar free'. Ada banyak jenis alcohol sugar yang berkalori 2.5kcal untuk 1g. Tidak mengandungi alkohol. Ia diberi nama alcohol sugar kerana struktur kimianya yang menyerupai alkohol.
Silakan TAG/SHARE dgn kawan-kawan yang suka minum manissss.. pesan diorang dah ckop manis, tayah tambah gula lagi dah dlm minuman 😊
Kredit Pic : Nutritionist KKM
mints 在 톡! TALK! 후지이 미나 Youtube 的最讚貼文
#후지이미나 #영화 #버킷리스트
민트들과 다양한 작품에 대해 이야기해보는 시간 무드톡!
그 첫번째 이야기, 영화 "버킷리스트" 지금 시작합니다~
ミントの皆さんとさまざまな作品について話してみる時間、ムードトーク!
その第1話は、映画「最高の人生の見つけ方」、今、始まります〜
Time to talk about various works with mints. Mood Talk!
The first story. The movie "Bucket List" starts now~
■ FujiiMina Instagram : https://www.instagram.com/fujii_mina_0715/
■ ON worldwide Official Web : http://onworldwide.co.kr/
■ Facebook : https://www.facebook.com/ONWORLDWIDE/
■ Instagram : https://www.instagram.com/o.n_worldwide/
■ Twitter : https://twitter.com/ON_world_wide
■ Weibo : https://www.weibo.com/p/1006063710858975/home?from=page_100606&mod=TAB&is_hot=1
mints 在 Van's Kitchen Youtube 的精選貼文
♥ Cách làm Gỏi Hoa Chuối (Nộm Hoa Chuối) và Canh Chua Hoa Chuối, 2 món rất ngon từ hoa chuối thích hợp cho mùa hè nóng, và những mẹo nhỏ để làm gỏi rau và canh chua đạt yêu cầu: gỏi không bị ra nước, nguyên liệu không bị mất đi độ giòn trong món rau trộn và canh chua đúng vị miền nam.
♥ Learn how to prepare Banana Blossom in 2 ways: Banana Blossom Salad and Banana Blossom soup. These are rich in vitamin C-content makes them ideal for a soothing summer meals.
♥ Ingredients:
❖ BANANA BLOSSOM SALAD
(4 portions)
1 cup shredded banana blossom (How-to video: https://www.youtube.com/watch?v=ABaq21r5QRw )
1 cup cooked shrimps
1 cup cooked, shredded chicken breast
1 cup fresh mints of herbs of your choice
Vietnamese sweet and sour salad dressing (Video recipe: https://youtu.be/BLI7H7c3cAc)
Pickled red onions (Video recipe: https://www.youtube.com/watch?v=BI3EcOY0XUk)
Deep fried shallots (Video recipe: https://youtu.be/wnc2LNtcqeA)
Crushed roasted peanuts
Black sesame rice crackers
❖ BANANA BLOSSOM SOUP
(4 portions)
2 cups shredded banana blossom
(How-to video: https://www.youtube.com/watch?v=ABaq21r5QRw)
1 lb shrimp, peeled, deveined and ground
2 tbsp Tamarind paste
2 tomates, peeled, wedged
½ cup rice paddy herbs
½ cup sawtooth herbs
½ cup green onion and cilantro, finely chopped
1 garlic clove, minced
1 shallot, sliced
3 cups chicken broth (Video recipe: https://youtu.be/OWhhNEGvbp8)
Salt
ground black pepper
½ tbsp sugar
Vegetable oil
-----
♥ Nguyên liệu:
❖ GỎI HOA CHUỐI (NỘM HOA CHUỐI)
(4 phần)
1 cup hoa chuối bào sợi (Cách chuẩn bị hoa chuối không bị đen : https://www.youtube.com/watch?v=ABaq21r5QRw )
1 cup tôm bỏ chỉ đen, nấu chín, lột vỏ
1 cup ức gà nấu chín, xé sợi
1 cup rau thơm tuỳ thích
Nước mắm chua ngọt trộn gỏi (Video cách làm: https://youtu.be/BLI7H7c3cAc)
Hành đỏ ngâm chua ngọt (Video cách làm: https://www.youtube.com/watch?v=BI3EcOY0XUk)
Hành phi giòn (Video cách làm: https://youtu.be/wnc2LNtcqeA)
Đậu phộng rang vàng, giã nhỏ
Bánh tráng mè hoặc bánh phồng tôm ăn kèm
❖ CANH CHUA HOA CHUỐI:
(4 phần)
2 cups hoa chuối bào sợi (Cách chuẩn bị hoa chuối không bị đen : https://www.youtube.com/watch?v=ABaq21r5QRw )
1 lb tôm, lột vỏ, bỏ chỉ đen, giã hoặc xay thô
2 tbsp muỗng canh me dầm
2 trái cà chua, lột bỏ vỏ, cắt làm bốn
½ cup rau ngò om, cắt khúc
½ cup rau ngò gai, cắt khúc
½ cup hành ngò, cắt nhỏ
1 tép tỏi, cắt nhỏ
1 củ hành ta, thái lát
3 cups nước dùng nấu từ xương (Video cách làm: https://youtu.be/OWhhNEGvbp8)
Muối
Tiêu xay
½ tbsp muỗng canh đường
Dầu ăn
♥ You can support my channel by buying the tools I used in this video with the following links. They earn me commissions:
Dao Victorinox 8-Inch Chef's Knife: http://amzn.to/YSD4Vg
Dao Victorinox Paring Knife: http://amzn.to/YgxiLH
Đồ xay tiêu mịn Peugeot Paris U'Select Pepper Mill: http://amzn.to/1OKZHBJ
Bộ nồi inox Calphalon Tri-Ply Stainless Steel Cookware Set: http://amzn.to/1jTCHBg
Bộ tô thuỷ tinh đựng thức ăn Anchor Hocking Oven Bake and Food preparation Set: http://amzn.to/Vrg35p
♥ Follow me on Facebook:
http://www.facebook.com/gocbep
http://www.facebook.com/VansKitchen
♥ Blog tiếng Việt: http://www.gocbep.com
♥ Blog in English: http://www.vanskitchen.net/
mints 在 もちよ/ mochiyo Youtube 的最讚貼文
「豚に真珠、梅ミンツに金箔」
"Pearl for pigs, gold leaf for plum mints"
texture : 発泡ビーズ×クリアのクランチ
飾り : 金箔シート2枚
香り : 梅ミンツ
サイズ : 8oz
価格 : 1450円
このスライムは11月27日金曜日の21時からBASEにて販売します!
詳細はインスタグラムや今後公開される動画でご確認ください♪
BASEショップやインスタグラムのURLはこちらから → https://linktr.ee/mochiyoslime
0:00 〜 OP
0:30 〜 本編開始
Start of the main movie
0:42 〜 さわりはじめ
Start touching
0:55 〜 容器から出す
take out of a container
1:10 〜ガッツリ遊ぶ
let's play!!
1:49 〜 バブル音とクランチ音
bubble sound & crunch sound
2:37 〜 バブル音とクランチ音
bubble sound & crunch sound
3:28 〜 バブル音とクランチ音
bubble sound & crunch sound
3:52 〜 バブル音とクランチ音
bubble sound & crunch sound
4:14 〜 バブル音とクランチ音
bubble sound & crunch sound
4:33 〜 バブル音とクランチ音
bubble sound & crunch sound
5:04 〜 もこもこテクスチャーで遊ぶ
play with a fluffy texture
6:07 〜 もこもこにして容器に還元 fluff up and return to the container
6:14 〜 もこもこテクスチャーで遊ぶ
play with a fluffy texture
*金箔は2枚入れるので、お好きなように混ぜて遊んでください!
こちらのスライムは、私の大好きなお菓子をイメージして、愛を込めて作ったギャグスライムです(?)
こちらは某梅ミンツをイメージしたクランチスライムです
This is a crunch slime with the image of plum mints.
本物の梅ミンツそっくりの発泡ビーズ!
Foam beads that look just like real plum mints!
このスライムの見た目、個人的に気に入っています()
I personally like the look of this slime♪
クランチならではの空気の入れやすさと音の良さです
It's very easy to put in air and sound like a crunch.
金箔が千切れてラメみたいになって可愛いです
The gold leaf changes like lame, and it's cute.
こちらは去年の12月に販売した「サンタだって病む」の妹です
This is Slime's sister who sold it last December.
こちらはリアルな梅ミンツと同じサイズ感のビーズです
These beads have the same size as real plum mints.
丸みを持ったコロコロ感が手のひらに伝わって楽しいです
It's fun to feel the rolling feeling of beads with the palm of your hand.
ベースはしっかりビーズを包み込む粘着性を持ちつつ
The base is adhesive enough to wrap the beads tightly.
遊びやすいモチモチ感もあります♪
It's chewy and easy to play with.
机で遊ぶ時はよく押し付けてください♪
Please press it well when you play at your table♪
このスライムの最大の特徴は梅ミンツそっくりな香りです!
t is characterized by a fragrance similar to plum mints.
梅ミンツの香り、それ以外言いようのない香りです
The scent of plum mints. It's impossible to describe.
梅ミンツが好きな方にはぜひ試していただきたい逸品です
If you like plum mints, please try it.
2倍くらいに膨らみます!
t swells about twice as much!
このスライムは11月27日金曜日の21じからBASEにて販売します!
詳細は概要欄や今後公開される動画でご確認ください♪
それでは引き続きASMRをお楽しみ下さい!
Please continue to enjoy ASMR!
おそまつさまでした!
Thank you for eating.
ご視聴ありがとうございました!
Thank you for watching!
8@gmail.com crunch.
〜*〜〜*〜〜*〜〜*〜〜*〜〜*〜
サブチャンネル【もちよの研究室】はコチラ!
↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
https://www.youtube.com/channel/UCWmSQDBSNQTX6kpFm6lYLnw
Instagram, twitter, BASE shop, メルカリはこちら!
↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
https://linktr.ee/mochiyoslimestore
スライムの提供についてはコチラ!
↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
https://www.instagram.com/s/aGlnaGxpZ2h0OjE3ODQ4ODU4NzU3MDI2MzA3?igshid=1hr3jy34zfnpo&story_media_id=2286885986591781571
イヤフォンやヘッドフォンをして聴いて頂くとよりいい音で楽しめるかとおもいますので、是非に😎
また、画面右上のチョンチョンチョンのとこから画質を1080pに設定して動画を見ていただけると、高画質でお楽しみ頂けます💪💪
どうもこんびんは!
もちよすらいむです🧜🏻♀️
有名なスライマーさんのスライムのレビューや、自分で作ったスライムの動画などのASMRを中心に、いろいろなジャンルの動画を上げていきたいと思います!
太古の動画や、short ver.の動画、編集実況などは全てインスタグラムのアカウントの方にあります。インスタライブでスライムを触ったりもします。
興味を持ってくだされば、是非インスタアカウントのもチェックして頂きたいです☺️
↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
https://www.instagram.com/mochiyoslime
*大学に通いつつ資格試験の勉強もしている学生の身ですので、更新が突然途絶える可能性があります🙇♀️
*慢性鼻炎でして、呼吸音が入ってしまうことがあります🤦♀️
また、机に爪がコツンと当たる音が入ってしまうことがあります。苦手な方は、ご視聴非推奨です🙇♀️
*自室にて、マイクを使って撮影してます!ですが、多少は「サーー」というホワイトノイズが入っています。また、稀ですが実家ぐらしなので家族の出す生活音が入ってしまう可能性があります。そういったものが苦手な方にも、ご視聴非推奨です🙇♀️
*動画を見てくださりありがとうございます💕そしてこの概要を最後まで読んでくださりありがとうございます💕
是非チャンネル登録をして、これからももちよの動画をお楽しみください💁♀️
〜*〜〜*〜〜*〜〜*〜〜*〜〜*〜
【今まで買ったスライムショップさん一覧】
《in Japan》
スライムジャパン→ https://slimejapan.thebase.in/
awesomeslime → https://mystyleslime.thebase.in/
さくらスライム→ https://sakuraslime.thebase.in/
TIA slime→ https://gsfr3.app.goo.gl/4KR19
slime lab→ https://slimelab59.thebase.in/
aoba slime→ https://preview.app.goo.gl/gsfr3.app.goo.gl/tyv86u
TAMR slime→ https://preview.app.goo.gl/gsfr3.app.goo.gl/9e9zq
SLY. jp→ http://gsfr3.app.goo.gl/p3yCT
niko slime→ https://www.mercari.com/jp/u/242242940/
very slimes→ https://veryslimes.thebase.in/
いーちゃんスライム→ https://linktr.ee/e_chan_slime
MILK SLIME→ https://gsfr3.app.goo.gl/BfrKYZ
m's slime→ https://msslime.base.shop/
aisu屋→ https://aisuya.theshop.jp/
MOON SLIME→ https://moonslime.base.shop/
z.mama Slime→ https://sksshop.thebase.in/
《overseas》
Slime Fantasiesさん→ https://slimefantasies.com/
BABOSLIMESさん→ https://baboslimes.com/
Rodem Slime Shop→ https://www.etsy.com/shop/rodemslime/
Momo Slimes→ https://momoslimes.com/collections/restock
OG slimesさん→ https://www.ogslimes.com/collections/restock
LUMINATI SLIME→ https://www.luminatishop.com/
#もちよすらいむ #mochiyoslime #べらちゃんのslimeしばき部屋 #slime #asmr #asmrsounds #asmrslime #スライム #音フェチ #音フェチ動画 #音フェチスライム #clayslime #slayslime #butterslime #cloudcream #thickslime #thickie #thickieslime #fluffyslime #clearslime #slusheeslime #slushieslime #fishbowlslime #crunchyslime #slimejapan #スライムジャパン #sakuraslime #さくらスライム #aisu屋さん #tiaslime #slimeogproof #ogslimeproof #aobaslime #awesomeslimeproof #awesomeslime #slimefantasies #slimefantasiesproof
#rodemslime #rodemslimeproof #mooncottonslime #slimebyktmproof
mints 在 Mints - Home | Facebook 的推薦與評價
Welcome to MINTS Boutique. We are Malaysia based online boutique. We sell ALL READY STOCKS ! Instag 2nd floor, lot 02-47 , Berjaya Times Square, Jalan... ... <看更多>