📜 [專欄新文章] 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.
👏 歡迎轉載分享鼓掌
同時也有30部Youtube影片,追蹤數超過66萬的網紅げんじ/Genji,也在其Youtube影片中提到,<目次> 0:00 オープニング 1:23 今回購入したHERMESのアクセサリーを開封 7:02 ネックレス 12:08 ブレスレット・バングル 15:13 リング 後編の動画はこちらから! ■ 【メンズ必見】人生で買って良かった小物(腕時計、眼鏡、アクセ)全部紹介します! https://yo...
「random number」的推薦目錄:
random number 在 Monster Taipei Facebook 的最讚貼文
MONSTER TAIPEI INTERNATIONAL LOTTERY
全球網路抽選活動
Dino Gangster 恐龍黑幫 腕龍酒保 豪斯.巴克利 - 標準情人配色
「Dino Gangster 恐龍黑幫」是由台灣設計師 Spawnmax 米腸駿筆下的原創作品,以恐龍未滅絕的世代為創作題材,進而展開一連串熱血有趣的恐龍黑幫文化故事。
一年一度的七夕情人節又要到了,相較於之前的怪力豪斯原色版,本次恐龍黑幫推出腕龍酒保 豪斯‧巴克利的標準情人配色,外號是「怪力豪斯」,小清新的文青風格,一改重現江湖氣的對比配色,以粉紅豹紋搭配牛仔褲刷白,還帶著可愛的電子錶,準備來一場牛郎織女般的邂逅。
故事背景:
買完花的豪斯,來到約定的巷口,看到兩個單身狗小盜龍在騷擾等他的新女友
梁龍–“梁靖茹”,瞬間勇氣爆棚來一個箭步,握著花束的左拳一揮!
兩隻衰仔就瞬間被打飛到了幾十丈外,但花束也毀了,形成漫天飛舞的紅花瓣。
豪斯一個華麗轉身,輕聲說道:「沒事吧?寶貝」,女友好氣又好笑地罵著豪斯要他賠一束花給她……
但豪斯早有準備,話鋒一轉:「妳看 現在都幾點了?」
女友一看他的手錶說:「你剛剛打架打壞了嗎? 現在怎麼是 13:14 還5月20咧?!」
豪斯說:「妳再唸一次」
靖茹:「吼呦,討M啦 ~///~」
此次 MONSTER TAIPEI 獨家開放抽選14隻,喜愛恐龍黑幫系列作品的朋友,千萬不要錯過了!
Dino Gangster 恐龍黑幫 品牌介紹:
本該滅絕的地球霸主恐龍,躲過了隕石天災攻擊,無天敵的它們肆無忌憚的持續繁衍著,數千年逐漸演化為人型,也發展出自我流行文化,成立幫派互相爭奪地盤。
恐龍牙齒做為品牌標誌,表示恐龍激烈衝突感,目前出品了四款角色,包含三角龍老大 腹黑-羅伯 . 維克多、暴龍拳王 拳帝-麥可 . 雷克斯、怪力酒保腕龍-豪斯 . 巴克利、劍龍清道夫-漢諾克,富有特色原創設計,不設限的持續發展出更多熱血有趣的故事。
設計師介紹:
台灣原創設計師-Spawnmax 米腸駿,擔任遊戲公司人物及服裝主設計,還是一名插畫家,目前在玩具公司任職,於2017年推出原創故事「小飛腸」系列軟膠,直到2019年推出「恐龍黑幫」系列軟膠,創作題材不斷推陳出新,期待未來會帶給大家更多不一樣的作品。
Facebook: Dino Gangster 恐龍黑幫
https://www.facebook.com/DinoGangsters/
抽選販售商品:
Dino Gangster 恐龍黑幫 腕龍酒保 豪斯.巴克利 - 標準情人配色
尺寸:全高約 29cm (H)
材質:軟膠 soft vinyl、施華洛世奇水晶貼鑽、乾燥花束
售價:TWD.4980/pc
※注意事項:乾燥花束為國外進口之天然色滿天星,自然擺放可維持一年多左右,如有損傷為自然耗損,將不再補送,敬請見諒。
※ MONSTER TAIPEI 獨家開放抽選14隻,頭卡均附上設計師親簽及限量編號。
抽選表單填寫時間:
2021/08/13 (五) 15:00 ~ 2021/08/14 (六) 20:00
抽選表單連結:
https://forms.gle/aEf9P7e1TcLTt2r98
販售規則:
1. 此商品採線上抽選方式販售,欲參加抽選的朋友請填寫 Google 表單,需登入 Google 帳號,一人一個帳號限填寫一次,如有重複填寫資料者或資料填寫不齊全者將直接取消抽選資格。
2.請於表單開放時間內填寫,逾時不候。
3.抽選將會使用電腦亂數程式隨機抽選,抽選結果將於 2021/08/15 (日) 當天 21:00 前以簡訊及 e-mail 通知中選者,未中選者不另行通知。
4.中選者需於收到中選通知後三日內 2021/08/18 (三) 結束前完成付款,如中選者未在時間內完成交易將直接取消購買資格並列入永久黑名單,請務必確認是否能在規定時間內付款再參與抽選活動。
5.中選者購買方式選擇
(1) 台灣地區中選者
a. Monster Taipei實體門市取貨付款 (現金/刷卡) 。
b. 提供上海商銀帳戶匯款郵寄。 (運費$80)
(2) 海外地區中選者
僅提供 PayPal 付款 (需另加 5% PayPal 手續費),依所在地區的不同,運費金額將會另行估算,隨中選信通知附上運費金額。
6.參與抽選的朋友如有中選,請遵守以下規定
(1) 選擇至 Monster Taipei 實體門市自取:請務必於指定時間內攜帶身份證件至門市取貨付款,非本人無法領取,不接受親朋好友代領等行為。
(2) 選擇郵寄:請務必於指定時間內付款,抽選表單上填寫的收件人及地址無法更改,欲更改者視同放棄購買資格。
7.申請抽選將視為皆已同意以上規則,Monster Taipei 保有最終販售及修改之權利。
Monster Taipei 台北怪獸國際有限公司
International Lottery Sale Item:
Dino Gangster Bartender Brachiosaurus House Barkley – Valentine’s Day Ver.
Size: 29cm (H)
Material:Soft Vinyl、Swarovski Rhinestones、Dry Bouquet
Price:TWD.4980/pc
NOTE : The flowers attached are natural color Baby's Breath, imported from abroad, which can last for about a year. All damages are regarded as natural wear and tear, will not sent spare parts, sorry for the inconvenient.
※MONSTER TAIPEI exclusive lottory for 14 pieces, the head card are attached with the designer's signature and limited number.
Opening hours for lottery:
2021/08/13 (FRI) 15:00 ~ 2021/08/14 (SAT) 20:00
Google form link for lottery:
https://forms.gle/aEf9P7e1TcLTt2r98
Sales rules:
1. This item is sold by global online lottery. Friends who want to participate in the lottery, please fill out the Google form by your Google account. Each account is limited to one time only. If you fill in the information repeatedly or fill in the information incompletely, you will be directly disqualified from the lottery. .
2. Please fill in the form within the opening hours, overtime filing will not be accepted.
3. The lottery will be randomly selected using a computer random number program. The results of the lottery will be notified on 2021/08/15(SUN) by SMS and e-mail before 21:00. Those who lost the chance will not be notified.
4. Winners of the lottery need to complete the payment within three days 2021/08/18(WED) after receiving the notification. If they didn't complete the payment within the time limit, the purchase qualification will be directly cancelled and be included in the permanent blacklist. Please confirm whether able to pay within the specified time before participating in the lottery.
5. Way of purchase
(1) Winners in Taiwan :
a. Pay on site and pick up in Monster Taipei store.
b. Delivery inside Taiwan and provide Shanghai Commercial Bank Account to remit. (TWD.80 for shipping)
(2) Winners from Overseas :
Only PayPal payment is available (additional 5% PayPal handling fee is required). Depending on the region, the shipping amount will be estimated separately, and the shipping amount will be attached to the notification.
6. The recipient and address on the lottery form cannot be changed, and those who wish to change will be regard as giving up the qualification.
7. Application for lottery will be deemed to have agreed to the above rules, Monster Taipei reserves the right to final sales and modification.
MONSTER TAIPEI INTERNATIONAL INC.
random number 在 TradingwithRayner Facebook 的最佳貼文
𝗪𝗵𝘆 𝘆𝗼𝘂𝗿 𝘀𝘁𝗼𝗽 𝗹𝗼𝘀𝘀 𝗮𝗹𝘄𝗮𝘆𝘀 𝗴𝗲𝘁𝘀 𝗵𝘂𝗻𝘁𝗲𝗱 𝗮𝗻𝗱 𝗵𝗼𝘄 𝘆𝗼𝘂 𝗰𝗮𝗻 𝗮𝘃𝗼𝗶𝗱 𝗶𝘁
Imagine…
You manage a hedge fund and want to buy 1 million shares of ABC stock. You know support is at $100 and ABC is currently trading at $110.
Now if you were to buy ABC stock right now, you’ll likely push the price higher and get filled at an average price of $115 — that’s $5 higher than the current price.
So what do you do?
Since you know $100 is an area of support, chances are, there will be a cluster of stop loss underneath it (from traders who are long ABC stock).
So, if you could push the price lower to trigger these stops, there would be a flood of sell orders hitting the market (as buyers will exit their losing positions).
With the amount of selling pressure coming in, you could buy your 1 million shares of ABC stock from these traders which gives you a better average price.
In other words, if an institution wants to long the markets with minimal slippage, they tend to place a sell order to trigger nearby stop losses. This allows them to buy from traders cutting their losses, which offers them a more favourable entry price.
Go look at your charts and you’ll often see the market taking out the lows of support, only to trade higher subsequently.
Now you’re probably wondering:
“So how do I avoid it?”
Simple.
Set your stop loss a distance away from support to give it some buffer so your stop loss doesn’t get eaten too easily.
Here’s how…
- Identify the lows of support
- Find the current Average True Range (ATR) value and subtract 1 ATR from the lows of support
The idea is to define the current market’s volatility and then subtract it from the lows of support.
This way, you are giving your stop loss a buffer that’s based on the volatility of the markets (and not just some random number).
Pro Tip:
If you want a tighter stop loss, you can reduce your ATR multiple, like having 0.5 ATR instead of 1.
random number 在 げんじ/Genji Youtube 的最佳貼文
<目次>
0:00 オープニング
1:23 今回購入したHERMESのアクセサリーを開封
7:02 ネックレス
12:08 ブレスレット・バングル
15:13 リング
後編の動画はこちらから!
■ 【メンズ必見】人生で買って良かった小物(腕時計、眼鏡、アクセ)全部紹介します!
https://youtu.be/HBctKM-WVSA
<着用アイテム>
冒頭で着用していたアイテムーーーーーーーー
ベスト
■ LIDNM - GIMA ZIP KNIT VEST
¥ 8,800 Mサイズ着用
https://lidnm-store.com/products/detail.php?product_id=171&utm_source=youtube.com&utm_medium=youtube.com&utm_campaign=YouTube210607GIMAZIPKNITVEST
Tシャツ
■+J - スーピマコットンリラックスフィットクルーT(半袖)
¥1,500 Lサイズ着用 56 OLIVE
https://www.uniqlo.com/jp/ja/products/E436133-000/00?colorDisplayCode=56&sizeDisplayCode=004
全部紹介ーーーーーーーーーーーーーーーーー
シャツ
■ COMOLI - リネンWクロス プルオーバーシャツ
¥57,200
https://cotyle.com/?pid=158979447
ピアス
■ LIDNM - SILVER HOOP PIERCE
¥ 3,850 ※順次発送中!!
https://lidnm-store.com/products/detail.php?product_id=62&utm_source=youtube.com&utm_medium=youtube.com&utm_campaign=YouTube210607SILVERHOOPPIERCE
ネックレス
■ LIDNM - COMBINATION CHAIN NECKLACE
¥ 4,400 ※順次発送中!!
https://lidnm-store.com/products/detail.php?product_id=3&utm_source=youtube.com&utm_medium=youtube.com&utm_campaign=YouTube210607COMBINATIONCHAINNECKLACE
<ご紹介アイテムや店舗>
※価格は購入した際のものです。(中古のアイテムも含む)
HERMESアイテムを購入した店舗はこちら!
■ Fabulous Sounds
https://www.fabuloussounds.com/
■ HERMES - Lima Bangle (Circa. 1990's)
¥460,000
■ HERMES - Smokey Quartz Ring (Circa. 1980's)
¥120,000
■ HERMES - Lima Bracelet (Circa. 1990's)
¥320,000
■ HERMES - Horsebit Bracelet (Circa. 1960's)
¥440,000
■ HERMES - Belt Motif Ring (Circa. 1990's)
¥140,000
■ HERMES - Lima Necklace (Circa. 1990's)
¥200,000
■ Maison Margiela - Logo Tag Necklace
¥64,000
https://www.farfetch.com/jp/shopping/men/maison-margiela--item-15457203.aspx
■ LIDNM - COMBINATION CHAIN NECKLACE
¥ 4,400 ※順次発送中!!
https://lidnm-store.com/products/detail.php?product_id=3&utm_source=youtube.com&utm_medium=youtube.com&utm_campaign=YouTube210607COMBINATIONCHAINNECKLACE
■ LIDNM - MaskCode(Sample)
■ Maison Margiela - Necklace
■ Maison Margiela - Necklace(Artisanal)
■ ARCHIVE STORE
https://archivestore.jp/
■ LIDNM - RANDOM COMBI CHAIN NECKLACE
¥4,400
https://wear.jp/item/33870606/
■ GUCCI
■ TUNAGI JAPAN
¥10,000
https://tunagijapan.base.ec/
■ HERMES - Nousicaa
¥200,000
■ LIDNM - TRIANGLE BANGLE
¥4,400
https://wear.jp/item/40134955/
■ HERMES - Ring
¥120,000
■ Burner - 14 BURNER SELECT 925シルバー
¥13,200
https://zozo.jp/shop/burner/goods-sale/37761647/
■ Maison Margiela - Number Engrave Ring
¥70,000
■ Louis Vuitton by そらちぃ
ーーーーーーーーーーーーー
LIDNMの公式サイトはこちらから!!
https://lidnm-store.com/?utm_source=youtube.com&utm_medium=youtube.com&utm_campaign=YouTubedefaulttop
ZOZO限定プチプラブランドWYM(ウィム)はこちらから!!
https://zozo.jp/brand/wymlidnm/
ーーーーーーーーーーーーー
《Instagram》
https://www.instagram.com/genji_official_/
《げんじのコーデはこちら!》
https://lidnm-store.com/contents/coordinate_list.php?utm_source=youtube.com&utm_medium=youtube.com&utm_campaign=YouTubegenjicode
《お世話になってる美容師さんはこちら!》
https://www.instagram.com/signal8756/?hl=ja
ーーーーーーーーーーーーー
《🌏🌏🌏絶対1度は見てほしい動画🌏🌏🌏》
★『メンズファッションの黄金バランスを公開します。最強コーディネート術です。』
→https://www.youtube.com/watch?v=HZ2kLtpjmxE
★『【超重要】知らないと危険なファッションの一面とは!?』
→https://www.youtube.com/watch?v=Bpq41NzD0Bs
ーーーーーーーーーーーーー
<プロフィール>
毎日ファッションについてのコンテンツを色んなSNSで投稿してるげんじです!
一人でも多くの方にファッションの魅力を知って頂き”日本中をお洒落にする”と本気で思っています🔥🔥🔥!
このチャンネルでは”最新のGU、UNIQLOの情報”や“誰でも一瞬でお洒落になれる方法”などメンズファッションに関わる全てのコンテンツをお届けしています!
そんな活動を続けて、ありがたくも総フォロワー200万人を突破しました!
少しでもファッションが好きでしたら是非チャンネル登録お待ちしております(´▽`)!
ーーーーーーーーーーーーー
動画内の画像は以下を引用しました。
Fabulous Sounds
https://gti.page.link/vSbXWnDzFjzseXSVA
Archive Store
https://gti.page.link/ryA74vzFc8Q4isVL7
Smoky quartz - Wikipedia
https://gti.page.link/bXsNhw1VPWN5fRHH9
効果音:OtoLogic
お問い合わせはこちらまで
d.ogawa1111@gmail.com
じゃあʕ•ᴥ•ʔ
#ファッション #fashion #メンズ #服 #プチプラ #UNIQLO #GU #ブランド #コーデ #お洒落
random number 在 Chris Lewis Youtube 的最佳解答
?? This is Mong Cai central market. It may look like a normal market from the outside and inside, but trust me, this market is one of a kind. According to recourses I read before visiting this market, most of the stalls used to have two workers - 1 Vietnamese and 1 Chinese, in order to communicate with the large number of both Vietnamese and Chinese tourists. Many of the workers speak Cantonese as well, due to Mong Cai being on the border with a Cantonese speaking province of China, Guangxi. However, the market is now almost deserted due to covid, since Vietnam isn't allowing any foreign tourists to enter. Still Max and I found some interesting people and had some funny conversations in English, Chinese, Vietnamese, French, and some random alien language. Come with us on this market hunt.
Check out Max's new channel here: https://www.youtube.com/channel/UCS0tiaCChXRF_XpU5TmlWSQ
Subtitles made and translated by the awesome Loan. Check out her drawings on Instagram: https://www.instagram.com/lucielittlethings/
Il------------------------------------------
Updates from the road:
► Instagram: https://www.instagram.com/chrismixlewis/
------------------------------------------
#Vietnam
random number 在 HimeChar 曉玲 Youtube 的最佳貼文
#MEGABITbistro #MB餐酒館 For new vid alerts: subscribe & tap the bell!
Highlight from my streams https://www.twitch.tv/himechar
See below for my IG - FB - Twitter:
https://www.instagram.com/himechar
https://www.facebook.com/HimeChar
https://twitter.com/himechar
Paypal USD 國外美金贊助跳出 https://twitch.streamlabs.com/himechar
O‘Pay TWD 歐付寶台幣贊助跳出 http://bit.ly/paychar
MEGABIT電玩餐酒館
新北市淡水區中正路一段2號3樓
3rd Floor Fab Mall, Zhongzheng Rd, Danshui, New Taipei City
https://goo.gl/maps/S9MBvax2UDzhA2RGA
11:00-00:00
https://www.facebook.com/megabit.official
https://www.instagram.com/megabit.bistro
四歲的蓓兒是我的瑜珈老師⋯在濕濕的草皮又黏噠噠的泥土上,歡迎來到淡水滬尾藝文休閒園區,我們的後花園。
She's only four but our yoga master, teacher, streamer and random number generator Belldandy leads an outdoor yoga and meditation session - and you can join in! All you'll need is a wet and grassy hill and a high tolerance for pain...
Editor: James 'MOV r0,r0' Staples https://www.youtube.com/channel/UCcn-XPhePJ5D5Uc6ExWG3PA
random number 在 RANDOM.ORG - True Random Number Service 的相關結果
RANDOM.ORG offers true random numbers to anyone on the Internet. The randomness comes from atmospheric noise, which for many purposes is better than the ... ... <看更多>
random number 在 Random Number Generator - Calculator.net 的相關結果
A random number is a number chosen from a pool of limited or unlimited numbers that has no discernible pattern for prediction. The pool of numbers is almost ... ... <看更多>
random number 在 隨機亂數產生器RANDOM NUMBER GENERATOR - 25sprout ... 的相關結果
簡單、快速地產生隨機且不重複的數字,可用於抽獎或是大冒險!The easiest random number generator ever. ... <看更多>