📜 [專欄新文章] 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.
👏 歡迎轉載分享鼓掌
同時也有424部Youtube影片,追蹤數超過38萬的網紅CH Music Channel,也在其Youtube影片中提到,《Walpurgis》 wonderland / 僅屬兩人的仙境 作詞 / Lyricist:梶浦由記 作曲 / Composer:梶浦由記 編曲 / Arranger:梶浦由記 歌 / Singer:Aimer 翻譯:CH(CH Music Channel) 意譯:CH(CH Music C...
「story creator」的推薦目錄:
- 關於story creator 在 Taipei Ethereum Meetup Facebook 的最讚貼文
- 關於story creator 在 มุนินฺ Facebook 的最讚貼文
- 關於story creator 在 Facebook 的最佳貼文
- 關於story creator 在 CH Music Channel Youtube 的最讚貼文
- 關於story creator 在 Eiki Akiyama Youtube 的精選貼文
- 關於story creator 在 Eiki Akiyama Youtube 的最佳解答
- 關於story creator 在 Facebook Story Maker- Make stunning FB Stories online for free 的評價
- 關於story creator 在 Story Creator - Book maker, How to memorize things, App 的評價
story creator 在 มุนินฺ Facebook 的最讚貼文
DADDY TIME CAPSULE
▲●■
ชวนมาดูโปรเจค NFT MEDIA ART SERIES ของมุนินฺกันค่ะ
เรื่องนี้ เราเล่าเรื่องในโลกอนาคตของผู้ชายคนหนึ่ง โลกที่เทคโนโลยีพัฒนาถึงขีดสุด
ทุกอย่างรวดเร็ว และแม้จะอยู่ก้ำกึ่งความจริงกับความฝัน แต่แทบทุกสิ่งนั้นได้อย่างใจ
เขาสามารถประสบความสำเร็จ มีเพื่อนฝูงและคนรักมากมายได้ทุกเมื่อ
แต่ในทุกวันเขากลับโหยหาการได้ใช้เวลาช่วงหนึ่งเข้าไปดื่มด่ำในความทรงจำของพ่อกับแม่
ผ่านสมบัติและของสะสมมากมายจากโลกในอดีต
แม้เขาจะไม่มีความรู้ในการซ่อมแซมของเหล่านั้น
แต่เขารู้จักและมีเงินมากพอจะจ่ายเพื่อซ่อมมันกลับมา
เทคโนโลยีทำให้ทุกอย่างยังจับต้องได้และมีชีวิต
การจ่ายที่คุ้มค่าที่สุดของคนในโลกนั้นคือ
พวกเขาจ่าย เพื่อสร้างใครบางคนที่จากไปแล้ว กลับขึ้นมาจากความทรงจำ
ซีรี่ส์แอนิเมชั่นขนาดสั้นประกอบเพลงชุดนี้มีทั้งหมด 8 ชิ้น
อยากจะชวนทุกคนไปรู้จักโลกใหม่ ที่จะขนานไปกับโลกที่เล็กลงทุกวันของพวกเรา
เป็นการ์ตูนมุนินฺในสัมผัสที่ใหม่หมดจด
แต่อบอุ่นและเต็มไปด้วยความรู้สึกที่ทุกคนคุ้นเคยแน่นอน
ฝากโปรเจคนี้ไว้กับทุกคนด้วยนะคะ💌
Story & Illustrated : มุนินฺ
Co-Director : http://vimeo.com/farnsasiphonc
Animation Director :Unstop
Art Assistant :Kanis
Sound Creator :Soul Beaver
The Auction has begun! Please visit
▲●■ http://foundation.app/@munins
story creator 在 Facebook 的最佳貼文
#葉郎每日讀報 #娛樂產業國際要聞揀1加2條
│Paramount 耗費破紀錄的10億美元確保《South Park 南方四賤客》成為自家串流台柱而不會投敵│
• Reese Witherspoon 的製作公司 Hello Sunshine 在串流大戰的併購潮中獲得9億美元身價看來只是第一步,上週好萊塢還爆出另外一紙交易金額超過9億的好萊塢合約:ViacomCBS 以9億美元的合約與《South Park 南方四賤客》的 South Park Studio 和兩位創辦人 Trey Parker 和 Matt Stone 續約,該製作公司還將專門為 ViacomCBS 的串流平台 Paramount+ 製作14部《南方四賤客》動畫電影。然而這9億美元並不含動畫影集和電影的製作費,所以彭博新聞預估 ViacomCBS 這一紙合約總計要用掉白花花的10億美元,遠超過 Netflix 先前與《American Horror Story 美國恐怖故事》製作人 Ryan Murphy 的3億美元合約。《南方四賤客》兩位原創者 Trey Parker 和 Matt Stone 因而擠身成為電視史上最成功的創作者之二。
• 不過才一週前,ViacomCBS 旗下的 CBS 才與 Star Trek 宇宙的總舵手 Alex Kurtzman 簽下9位數新合約。Paramount+ 上路半年以來一直被貼上 Star Trek 頻道的暱稱,然而今天突然出現局勢變化。這一紙 South Park Studio 簽訂的天文數字合約儼然有一種改朝換代的味道,要讓長期在別人的串流平台播出的《南方四賤客》開始準備當家作主成為 Paramount+ 的招牌節目。
• 彭博新聞今天刊出的 Matt Stone 提供了不少 ViacomCBS 大動作續約的內情:這對創作組合在完全沒有人看好網際網路的年代,就在律師堅持下要求保有《南方四賤客》電視以外的所有權利的50%。2019年 WarnerMedia 以5億美元簽走《南方四賤客》的美國地區串流授權(上架至 WarnerMedia 的 HBO Max 服務)時,兩人就因為這個條款合計拿下近半數授權費。雖然 ViacomCBS 也分得另一半的授權費,但對 ViacomCBS 來說最大的惡夢是 HBO Max 可能在嘗到甜頭之後進一步直接委託 South Park Studio 製作其他衍生內容或是獨立於《南方四賤客》以外的內容,甚至是直接出資買下該公司 。
• 不尋常的是 ViacomCBS 沒有選擇像 Amazon 買下製作和發行龐德電影的 MGM 那樣,直接買下 South Park Studio 。Matt Stone 說他也不知道為什麼 ViacomCBS 選擇簽訂天文數字的合約協議而非出價直接併購他們的公司。他也說自己還沒有打算脫離《南方四賤客》這個節目,但也許真有一天會出售自己手上的相關股份。
• 《南方四賤客》不是 ViacomCBS 唯一出售串流權利給別人播出的自家節目,廣受歡迎的 《Yellowstone 黃石公園》現在在 Peacock 上。甚至連整個 Paramount + 最大招牌 Star Trek 宇宙的多部電影也在近日下架,不知道賣到哪一家平台上打工去。在決定傾整個集團之力投入串流競爭之前,ViacomCBS 就像現在的 Sony Pictures 一樣,樂得賺串流財。不只大量授權節目給其他串流,甚至還成立串流製作部門專門替串流業者拍片。許多 VIacomCBS 節目串流授權合約早在 Paramount+ 開台之前就已經簽訂,這也使得 ViacomCBS 對於串流的緩慢行動付出了慘痛的代價。如果《南方四賤客》的 HBO Max 合約發生在現在,ViacomCBS 肯定會極力阻止這個重量級文化現象成為別人家品牌的一部份。
• Observer 提供的表格顯示 ViacomCBS 的節目去別人家別的串流平台打工的表現非常突出:Peacock 上最受歡迎的節目中來自 ViacomCBS 授權的佔比高達 27.7%,在 Netflix 上有 25.6%,在 Amazon Prime Video 上也有24.8%。這些數據顯示,ViacomCBS 的節目大賺串流財的同時也在養大 Paramount+ 的敵人,並將這些敵手與起步更晚的 Paramount+ 的距離越拉越遠。
◇ 新聞來源:
‘South Park’ Co-Creator Matt Stone on his $900 Million Deal(https://flip.it/jfBGE3)
Can ViacomCBS Transform The Star Trek Channel Into South Park Central?(https://flip.it/PL_7vC)
ViacomCBS Is Hurting Paramount+ By Licensing Its Content Elsewhere(https://flip.it/RIKEaa)
───────────────
其他也可以知道一下的事:
│Delta 病毒株的威脅潛伏使上週末上映的自殺突擊隊票房低於預期│
◇ 新聞來源:Box Office: ‘The Suicide Squad’ Opens to Lowly $26.5M as Moviegoers Stay Home Amid Delta Variant(https://flip.it/knLBqA)
│奧運轉播不再是電視上最受歡迎的節目,然後呢?│
◇ 新聞來源:The Olympics Have Fallen Out of Much-Watch Status — Will They Ever Win Viewers Back?(https://flip.it/6dSBgV)
story creator 在 CH Music Channel Youtube 的最讚貼文
《Walpurgis》
wonderland / 僅屬兩人的仙境
作詞 / Lyricist:梶浦由記
作曲 / Composer:梶浦由記
編曲 / Arranger:梶浦由記
歌 / Singer:Aimer
翻譯:CH(CH Music Channel)
意譯:CH(CH Music Channel)
English Translation: thisisars
背景 / Background - ひとば - 標本:
https://www.pixiv.net/artworks/82963977
上傳你的字幕吧!/ Submit your subtitles here!
https://forms.gle/MSsAM2WHpT31UuUh8
版權聲明:
本頻道不握有任何音樂所有權,亦無任何營利,一切僅為推廣用途。音樂所有權歸原始創作者所有。請支持正版。
Copyright Info:
Be aware this channel is for promotion purposes only without any illegal profit. All music's ownership belongs to the original creators.
Please support the original creator.
すべての権利は正当な所有者/作成者に帰属します。あなたがこの音楽(または画像)の作成者で、この動画に使用されたくない場合はメッセージまたはこのYoutubeチャンネルの概要のメールアドレスにご連絡ください。私はすぐに削除します。
如果你喜歡我的影片,不妨按下喜歡和訂閱,你的支持就是我創作的最大原動力!
If you like my videos, please click like and subscribe! Thx :)
粉絲團隨時獲得最新訊息!
Check my Facebook page for more information!
https://www.facebook.com/chschannel/
中文翻譯 / Chinese Translation :
https://home.gamer.com.tw/creationDetail.php?sn=5269021
英文翻譯 / English Translation :
https://genius.com/Genius-english-translations-aimer-wonderland-english-translation-lyrics
日文歌詞 / Japanese Lyrics :
迷いの森にあるほんとう 探しに行く月のひかり
羊歯を踏んで足を濡らして ひたりほとり夏の小道
よく笑って泣いて見つめあって おそるおそる恋に堕ちた
ふたり歩き出した違う方へ 呼び合う声だけもどかしく
find me in the wonderland
そろそろ手を汚して 自分の欲しいものを 追いかけてみる
みつあみをほどいて 同じ星を齧る ふたりになる
寂しがって夜になって まだ明るい夢のほとり
食べかけで残した心だって ここから始まるうたになる
世界は君のものさ、どこへ行こうか、貴方は笑う
踏み外してみようか、後ろめたさが私を誘う
find me in the wonderland
どうしたって 生まれ変わるほどの 強い意志が必要だわ
慎重ないのちだった 私だけじゃ道は見つからない
星を数え繋ぎ合わせ まだ知らない夏の星座
見つめあって泣いて朝になって ここから始まる物語
もう一人じゃないのよ、夢のようでしょ、私は歌う
寂しさはひるがえり旗の元へと二人は集う
何も思い通りにならないことが始まったから
踏み外してみようか、目隠し鬼の手の鳴る方へ
in your wonderland
あなたが迷う場所に あかりを灯すために
花束一つ抱いて りりしく笑いましょう
もう一人じゃないのよ、とても怖いね、幸せなんて
寂しさはひるがえり旗の元へと二人は集う
世界は君のものさ、手が届いてあなたがいて
踏み外してみようか、愛するひとが私を誘う
find me in the wonderland
in your wonderland
綺麗な吐息になって
あなたの歌をうたって
中文歌詞 / Chinese Lyrics :
皎潔的月光為我照亮此行、於迷幻之森捕獵真心
踩踏著草蕨、潤濕了雙足,行於令人陶醉的夏日小徑岸邊
曾互相歡笑、哭泣、注視彼此,才使得我們惶恐地墜入愛戀
卻漸漸步入相異路途,竟連呼喊之聲都令人無比焦躁
請步入仙境尋覓迷失的我吧
雙手漸漸開始沾染污穢,試著放縱自身索求慾望
解開扎起的髮辮,成為共食星斗的戀人,相濡以沫
寂寞的心、鋪張的夜色,仍遊走於璀璨的夢的畔邊
早已被啃咬殘缺的心,將自此幻化為歌謠
「你已擁有了全世界,我們要去哪呢?」你莞爾而笑
「要不試著背離正道呢?」罪惡感正如此略誘著我
請步入仙境尋覓孤單的我吧
尚須一份不論如何都欲潰爛重生的強烈意志
曾嚴謹拘束的生命,卻僅自身無法尋見方向
細數繁星、相相連繫,嘗試探尋尚不知悉的夏季星座
彼此相視而泣直至天明,兩人的故事自此展開
「我已不再孤身一人,就彷彿夢一般對吧?」我唱著
寂寥的心隨風飄揚,使彼此相遇於同面旗下
乃因不如己意才使得兩人的生命交織展開
不妨背離正道、作個矇眼鬼循向掌鳴之處
步向有你所處的仙境
僅為了在你迷失之地,綻亮一絲光芒
我將為此獻上花束,兩人一同凜然而笑吧
「我已不再孤身一人,但這份幸福仍會讓人感到恐懼吧?」
寂寥的心隨風飄揚,使彼此相遇於同面旗下
「你已擁有了全世界。」向著觸手可及的你說著
「要不試著背離正道呢?」心愛之人如此略誘著我
請步入仙境尋覓重生的我吧
在那僅有兩人的仙境
化作絢麗的吐息
唱著屬於你的歌謠
英文歌詞 / English Lyrics :
Within a forest of delusion, I search for truth
The light of the moon illuminating my hunt
I step over ferns, my feet becoming wet
The water puddling on the edge of a summer path
Having shared laughter, tears, and gazes between us
Warily, cautiously, I fell in love
Along the separate paths the two of us walked
Is vexingly, only the sound of our voices calling to each other
Find me in the wonderland
Before long, my hands grow dirty
As I chase after that which my self desirеs
My braid becoming undone
We bitе down into the same star, and become a pair
A lonesome, solitary night arrives
The shore of dreams still brightly lit
A heart is left half-eaten and tossed aside
From here forth begins a transformation into song
This world is your plaything, and wherever I go
You are there, laughing
Should I try and step off the path, the unease shall beckon to me
Find me in the wonderland
Even if I must be reborn anew
I cannot go on without a strong, unshakeable will
My life has been a cautious, prudent one
And thus, only I am unable to find a path
Counting the stars, connecting them together
Into an as-yet-unknown summer constellation
Gazing at each other, I cry, and morning comes
From here forth begins a story
I'm no longer on my own, aren't I? Isn't this like a dream? I sing
Desolation flutters in the wind, and we meet at the base of its flag
Since nothing is beginning to go as I had expected
I shall try and step off the path, to the source of the hunter's clap
In your wonderland
For the sake of kindling a light in the place you wander, lost
You held a bouquet in your arms, chivalrously, let's have a laugh
I'm no longer on my own
It is incredibly frightening, about happiness
Desolation flutters in the wind, and we meet at the base of its flag
This world belongs to you, I reach out my hand and you are there
As I step off of the path, my beloved beckons to me
Find me in the wonderland
In your wonderland
Becoming a beautiful breath
Singing a song about you
story creator 在 Eiki Akiyama Youtube 的精選貼文
#shorts
In this video I'll be showing you some BTS footage of a project we did on a luxury yacht.
We traveled for a full day inside the Osaka Peninsula and we had a blast talking with the captain. He was such a genuine guy, giving us lessons about life and the ocean. Traveling on a yacht has been a dream of mine and I will never forget this experience with him.
Check out the full video in the link below!
https://youtu.be/U6Gzflum6HU
If you want to learn more about my travels, check out my other socials!
Instagram - https://www.instagram.com/eiki_akiyama/
Work - [email protected]
Mai Yamada - https://www.instagram.com/maidon513/
Ryuto Tamashiro - https://www.instagram.com/ryuto_tamashiro/
【Other Videos】
Rediscover Japan - A different side of Japan
https://youtu.be/8q4JoAivW-I
Against the Waves - A story behind Kaiki Yamanaka (A Surfer's Documentary)
https://youtu.be/066L83m4bi8
Follow What You Love
https://youtu.be/Ye5yp4YPGlM
【About Myself】
I guess I'm a filmmaker, adventure photographer, storyteller, and content creator...
I'm based in Tokyo, doing freelance video work for both Japanese and international clients.
My interest for video grew when I first went backpacking on my own. In the beginning it was just for fun, but I slowly found myself loving to express through visuals.
#yacht #boat #travel #japan #osaka
story creator 在 Eiki Akiyama Youtube 的最佳解答
In this #shorts I'll be breaking down the text message animations I used in my recent film.
Everything is done inside After Effects and the process is quite simple once you get the hang of it.
Check out the actual edit in the link below!
https://youtu.be/U6Gzflum6HU
If you want to learn more about my travels, check out my other socials!
Instagram - https://www.instagram.com/eiki_akiyama/
Work - [email protected]
Mai Yamada - https://www.instagram.com/maidon513/
Ryuto Tamashiro - https://www.instagram.com/ryuto_tamashiro/
【Other Videos】
Rediscover Japan - A different side of Japan
https://youtu.be/8q4JoAivW-I
Against the Waves - A story behind Kaiki Yamanaka (A Surfer's Documentary)
https://youtu.be/066L83m4bi8
Follow What You Love
https://youtu.be/Ye5yp4YPGlM
【About Myself】
I guess I'm a filmmaker, adventure photographer, storyteller, and content creator...
I'm based in Tokyo, doing freelance video work for both Japanese and international clients.
My interest for video grew when I first went backpacking on my own. In the beginning it was just for fun, but I slowly found myself loving to express through visuals.
#aftereffects #text #animation #transition
story creator 在 Story Creator - Book maker, How to memorize things, App 的推薦與評價
I am so excited! The week before the Super Bowl is my favorite week in my classroom! You can read a couple posts about my party last year HERE and HERE. ... <看更多>
story creator 在 Facebook Story Maker- Make stunning FB Stories online for free 的推薦與評價
Make beautiful FB stories within minutes using Taler's online design platform ... Facebook Story creator ... Design a stunning Facebook Story in seconds ... ... <看更多>