📜 [專欄新文章] 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.
👏 歡迎轉載分享鼓掌
同時也有110部Youtube影片,追蹤數超過1萬的網紅もちよ/ mochiyo,也在其Youtube影片中提到,#スライムジャパン #slimejapan スライムジャパンさんの「アイスクリームタコス」 "Ice cream taco" by Slime Japan. 0:00 〜 OP 0:30 〜 本編開始 the beginning of the main part 0:39 〜 ベーススライ...
「at such short time」的推薦目錄:
- 關於at such short time 在 Taipei Ethereum Meetup Facebook 的最佳解答
- 關於at such short time 在 Facebook 的最讚貼文
- 關於at such short time 在 COMPUTEX TAIPEI Facebook 的最讚貼文
- 關於at such short time 在 もちよ/ mochiyo Youtube 的最佳解答
- 關於at such short time 在 もちよ/ mochiyo Youtube 的精選貼文
- 關於at such short time 在 Beixin & Robin Youtube 的精選貼文
- 關於at such short time 在 Can I use: "We only have known them for a short time"? 的評價
at such short time 在 Facebook 的最讚貼文
Totally enjoying the little pockets of fresh air while we are allowed to travel within our own state. So packed the little old lady up, start the truck and off to KKB we went.
Being stuck in a confine space for a long time does mess with your head that’s for sure but then again and agony of having to choose either to take that risk and move out of our comfort zone is another headache all together. With all these different variants of the virus in the air. It’s a to do or not to do decision.
With this new norm I guess you just have to take that step out but with all the right taken measures. Choose the right places, stay away from the crowds and remember to always wash your hands, disinfect and mask up when your out in public. I’m glad I came across this beautiful property mom gets to be in the outdoors with the comfort of the indoors and away from other people.
So if you are thinking of going out for a little short holiday I say go for it. But always remember to stay safe and be safe.
P/S A big shout out to Abang Rajan. Who helped us check in and settle down with a breeze. Such a champion.
All shots taken with the latest GoProHERO10 with no touch ups at all..
@gopro @gopromysg @isuzumy @sundayafternoons_hats @montanic_adventure @malaysia.truly.asia @discoverselangor
#bakizainal #GoProAmbassador #GoProHERO10 #goprostayawesome #isuzudmax #isuzu #isuzumy #kualakububharu #kkb #woodhousekkb #malaysia #selangor #discoverselangor
at such short time 在 COMPUTEX TAIPEI Facebook 的最讚貼文
According to a Research and Markets report, the AR and VR markets are forecasted to grow at a CAGR of 38.1% and 27.9% respectively from 2020 to 2025 under the influence of the pandemic 📈 One can certainly tell from the winners of this year’s COMPUTEX d&i Awards that AR and VR applications are changing the way people interact in increasingly diverse fields 🙋
The J7EF Plus AR glasses from Jorjin Technologies create a more intuitive way for human-computer interaction, providing better remote management for fields such as manufacturing and logistics. Yajantech offers AR SDK (Software Develop Kit) that allows for the introduction of AR solutions to applications such as smart manufacturing and modeling in a short period of time. Retina Stereotactic Surgery Navigation System from Eped integrates smart healthcare technologies and is compatible with AR glasses, which enable doctors to perform minimally invasive surgeries with success! Tune into COMPUTEX for more first hand information on the latest forward-looking technologies! 🏃♂️
根據市調公司 Research and Markets 預測,在疫情影響下,2020 年至 2025 年間,AR 市場的年複合成長率達 38.1%,VR 市場則以 27.9% 速度成長📈而從 COMPUTEX d&i Awards 得獎產品中也可以發現,AR/VR 應用場域更加多元,不斷改變人們互動模式🙋
佐臻股份有限公司推出 J7EF Plus AR 智慧眼鏡,可創造更直覺的人機互動方式,提升如工業、物流等各領域的遠距管理體驗;雅匠科技的跨平台 AR SDK(軟體開發套件),讓智慧製造、建築建模及其他多元應用情境,能在短時間內輕鬆導入 AR 解決方案;EPED Inc. International 醫百科技的雷帝納 Retina 手術導航系統,結合智慧醫療技術和服務,甚至可搭配 AR 眼鏡,協助醫師更精準地執行各類微創手術!想第一手接觸更多國際性的前瞻技術,別忘了持續鎖定 COMPUTEX 展會🏃♂️
at such short time 在 もちよ/ mochiyo Youtube 的最佳解答
#スライムジャパン #slimejapan
スライムジャパンさんの「アイスクリームタコス」
"Ice cream taco" by Slime Japan.
0:00 〜 OP
0:30 〜 本編開始
the beginning of the main part
0:39 〜 ベーススライムを触る
touch the base slime
2:42 〜 DIY TIME
3:24 〜 触り始め
begin to touch
3:47 〜 容器から出す
take out of a container
3:51 〜 両手でガッツリ遊ぶ
play with both hands
7:21 〜 あたたたたたたいむ
mochiyo beam
7:25 〜 もこもこテクスチャーで遊ぶ
play with a fluffy texture
7:51 〜 もこもこにして容器に還元
fluff up and return to the container
7:54 〜 もこもこ
fluffy
【テロップ書き起こし】
こちらは「スライムジャパン・第一章」最後のDIYクレイスライムです
This is the last DIY clay slime in "Slime Japan Chapter 1"
ベースのスライムはツヤとろのグロッシースライムです!
The base slime is oozy glossy slime!
滑らかでまろやかなテクスチャーです
This is a smooth and mellow texture.
極上タップ音が鳴り響く〜!
The best tapping sound reverberates!
パキポキのバブル音も幸せです!
The loud bubble sound is also happy!
しっとりしていて手離れが良い触り心地です!
It's moist and easy to peel off from your hands!
これはベースだけでもコレクションしたい!!
I also want to collect this base slime!
それではもうしばし、ベーススライムの様子をお楽しみください!
Let's enjoy the video of playing with base slime for a while!
付属品達
Accessories
タコスの生地のポリマークレイです
Polymer clay for taco fabric.
硬くて、ハンドガムみたいな伸び方をする粘土です
It is a clay that is hard and stretches like hand gum.
打って変わってこちらはシュワシュワで軽いクレイです!
On the other hand, this is a sizzle and light clay!
ポリマークレイを餃子の皮みたいに伸ばしていきます
Spread the polymer clay like Gyoza dough.
タコスに挟まれるアイスクリームを成形していきます
I made ice cream parts with clay.
美味しそうなクラッシュキャンディーを振りかけていきます
Sprinkle with delicious crushed candy.
カラフルなチョコスプレーを振りかけます
Sprinkle with a colorful chocolate spray.
アイスクリームのチャームを乗せます!
Put the ice cream charm on the slime!
いただきまーーす!
Let's eat! Here we go!
最高の癒し……
The best healing ...
あんなに硬いクレイだったのに、驚くほどすんなり混ざります
Even though it was such a hard clay, it mixes very smoothly.
一瞬で混ざってしまいました!
It got mixed in an instant!
膜がしっかりしていて、バブル音がなりやすいです!
The film is thick and it is easy to make bubble sound!
机にしっかり張り付いて、よく伸びるテクスチャーです!
It is a texture that sticks well to the desk and stretches well!
音が気持ち良すぎる!!
The sound is too satisfying!!
ベタつきが全くなくて、しっとりもちもちです
It is not sticky at all and is moist and chewy.
これは長時間ずっと遊んでいられる大好きなテクスチャーです!
This is my favorite type of texture that I can play for a long time!
空気を含むとフワッとして、細かいバブル音が鳴ります!
When it contains air, it becomes fluffy and makes a fine bubble sound!
ホウ砂で少し調節してみます!
Let's activate it with borax!
レモン・ストロベリー・バニラケーキの美味しい香りでした!
It was a delicious scent of lemon, strawberry and vanilla cake!
アタタタタタタタァァッッ!!
Hissatsu! Mochiyo Beam!!!!
ここからは細かいバブル音もお楽しみください!
Please enjoy the fine bubble sound from now on!
それでは引き続きASMRをお楽しみ下さい!
Please continue to enjoy ASMR!
ごちそうさまでした!
Thank you for the meal!lol
ご視聴ありがとうございました!
Thank you for watching!!!!
〜*〜〜*〜〜*〜〜*〜〜*〜〜*〜
サブチャンネル【もちよの研究室】はコチラ!
↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
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/
#もちよすらいむ #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
at such short time 在 もちよ/ mochiyo Youtube 的精選貼文
【モラトリアムコレクション 第1弾!】
「社会の歯車」
"a cog in the society"
texture : マイクロビーズクランチ
飾り : 歯車4つ(形は超ランダムです)
香り : 無難なフルーツミックス
サイズ : 8oz
価格 : 1580円
このスライムは6月6日日曜日の21時からの「モラトリアムコレクション」で、BASEにて販売します! 詳細は概要欄や今後公開される動画でご確認ください♪
BASEショップやインスタグラムのURLはこちらから → https://linktr.ee/mochiyoslime
0:00 〜 OP
0:30 〜 本編開始
the beginning of the main part
0:54 〜 触り始め
begin to touch
1:18 〜 容器から出す
take out of a container
1:21 〜 片手で触る
touch with one hand
1:35 〜 両手でガッツリ遊ぶ
play with both hands
4:14 〜 あたたたたたたいむ
mochiyo beam
4:17 〜 もこもこテクスチャーで遊ぶ
play with a fluffy texture
5:42 〜 もこもこにして容器に還元
fluff up and return to the container
5:46 〜 もこもこしゅわしゅわ
fluffy & sizzly
6:12 〜 もこもこしゅわしゅわ おすすめ!
fluffy & sizzly
【日本語 Japanese】
もちよすらいむ初のマイクロビーズスライムです。
アンティーク調の歯車を4つあしらいます。
このスライムは「社会の歯車になったら俺の良さが死んじゃう!」と駄々をこねて就活をサボる、ニート予備軍の青年のスライムです。
下の派手なクリアスライムが青年のユーモア溢れる多彩な個性で、上のマイクロビーズが「すでに社会に迎合した大人達からの圧」です。
さあ!モラトリアムを超えて、相反する2つの層が混ざります!
そこには一人の青年の葛藤があるのです!(もちよの脳内では)
こうやって混ざってく様子は、言わば人生の縮図です。
ああ……あっという間に混ざってしまいました…。
このスライムのミソは「混ざっても可愛い」というところです
クリアスライムに混ざっていたホログラムがいい味出してます
つまり、社会に迎合しても、青年の力強い個性は消えなかったのです!
という複雑な物語を考えながらこのスライムを作りました笑
素敵な個性のあるひとは、素敵な個性のある歯車になれる
歯車だとしても、自分らしくあれるなら悪くないじゃないか
私はこのことに気付いてからやっと就活を頑張る気になれました。
……いい加減テクスチャーについて話しますね笑
こちらはクリアベースのマイクロビーズスライムです。
ベース多めなので伸ばして遊びやすいです。
ビーズのおかげでバブル音が鳴りやすいです。
細かな粒々の感触はクセになる気持ちよさです。
手離れはビーズが落ちないギリギリを攻めました。
ですので「完璧にビーズは落ちません」とは言い切れません。
もしかしたら一粒か二粒くらい手に残る可能性があります。
その分いくらか手離れがよくなっているので、是非沢山遊んでいただきたいです!
アタタタタタタタァァッッ!!
実はこのスライム、とんでもなく膨らみます。
是非 5:43 に飛んでみてください笑 驚きの膨らみです笑
このバブル音がストレス発散になり、皆様の活力になりますように……
皆様お気づきの通り、今回の「モラトリアムコレクション」は、絶賛モラトリアム期にあった私自身の葛藤をスライムに落とし込んでいます。
今の私にしかできない、一回きりのコレクションですので、どうかお見逃しなく!
2.5倍くらいになりました!
このじゅわぱちと、もこもこもとても楽しいです。
細かいバブル音も気持ちがいいです。
香りはシェフの気まぐれフルーツミックスです。
甘くて無難な感じの香りが優しく香ります。
【英語 English】
Mochiyo slime's first micro-foamed bead slime.
Decorate slime with four antique cogs.
This is a slime of a young man who skips job hunting by saying "My goodness will die if I become a cog of the society!"
The lower layer of clear slime expresses the humorous personality of young men, and the upper layer of microbeads is "pressure from adults who have already accepted society."
Overcoming the Moratorium, the two conflicting layers mix!
There is a youth mental conflict there! (In mochiyo's brain)
The mixture of the two layers is the ultimate commentary on life.
Ah ... the two layers got mixed up in no time ...
The heart of this slime is that it is cute even when mixed.
The hologram that was mixed with the clear slime just tasted good.
The youth's powerful personality did not disappear even when he accepted the society!
I made this slime while thinking about such a difficult story lol
A unique and wonderful person can be a unique and wonderful cog.
Even if I'm a cog, it's not bad if I can be myself.
After I realized this, I finally felt like trying my best to find a job.
...... I'll talk about textures soon lol
This is a clear-based micro-foamed beads slime.
There is a lot of base slime,so it is easy to stretch and play.
Thanks to the beads, it is easy to make a bubble sound.
The feel of the micro-foamed beads is addictive.
I attacked the line where the beads do not fall out.
So I can't say "the beads won't fall off perfectly".
Maybe one or two beads will remain in your hand.
It's easier to peel off from your hands, so I hope you'll play a lot!
Hissatsu! Mochiyo Beam!!!!
Actually, this slime fluffs up ridiculously.
Please skip at 5:43 lol It's super fluffy lol
May this bubble sound release stress and energize everyone ...
As you may have noticed, this "Moratorium Collection" is a slime collection of my own mental conflict over the past year.
This is a one-time collection that only I can do now, so please don't miss it!
Inflated about 2.5 times!
This sizzless and fluffness are also very fun.
The fine bubble sound is also satisfying.
The scent is the chef's whimsical fruit mix.
A gentle scent with a sweet and safe feeling.
〜*〜〜*〜〜*〜〜*〜〜*〜〜*〜
サブチャンネル【もちよの研究室】はコチラ!
↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
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
動画を見てくださりありがとうございます💕そしてこの概要を最後まで読んでくださりありがとうございます💕
是非チャンネル登録をして、これからももちよの動画をお楽しみください💁♀️
〜*〜〜*〜〜*〜〜*〜〜*〜〜*〜
#もちよすらいむ #mochiyoslime
at such short time 在 Beixin & Robin Youtube 的精選貼文
When we read about Beyond Expeditions' Back-to-Basics: Woodcraft & Bushcraft Experience, we knew we had to sign ourselves up!
The day started with a short boat ride to Pulau Ubin, an island off eastern Singapore, where we spent a rejuvenating day away from civilisation. We picked up basic bushcraft (wilderness survival skills) from the super knowledgeable Scott, took turns to saw and chop fallen firewood, learnt some woodcraft from the talented Frederick, and made ourselves a scrumptious aglio olio lunch over open fire.
What a day it was, and what a workout too! We had such a good time we frankly didn't even stop to check our phone once.
A big thank you to Beyond Expeditions for the hospitality, and Seek Sophie for organising this experience.
Wanna try your hand at Bushcraft & Woodcraft too?
Sign up with Beyond Expeditions:
https://beyondexpeditionssg.com/events/2020/11/1/back-to-basics-chopstick-carving-amp-bushcraft-experience
Or book the experience through Seek Sophie:
https://www.seeksophie.com/options/wilderness-survival-experience
Featuring:
Shawne Koh - https://www.youtube.com/user/shawneydepp
May our videos be a form of escapism and source of zen for you, and encourage you to appreciate the little, simple things in life. Even in these turbulent times, there is still much beauty in this world if we keep our hearts and minds open.
Cheers!
---------
x Connect with Us
Instagram - https://instagram.com/beixinandrobin
Beixin's instagram - https://instagram.com/beixin
Robin's instagram - https://instagram.com/robinlamhj
Facebook - http://www.facebook.com/beixinandrobin
x Gear List:
Main Camera - Canon EOS R
Main Lens - Canon RF 28-70mm f2
Tele Lens - Canon RF 70-200mm f2.8
Mic - Rode Videomic Pro NTG
Drone - DJI Mavic 2 Pro
x Music
Artlist - https://artlist.io/Robin-58878
(Get 2 months free)
x Software
Adobe Premiere Pro
Contact us at hello@beixinandrobin.com.
at such short time 在 Can I use: "We only have known them for a short time"? 的推薦與評價
The key to placing "only" in a sentence lies in choosing the part of the sentence to focus on. "only" places focus on the word, ... ... <看更多>