📜 [專欄新文章] 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.
👏 歡迎轉載分享鼓掌
同時也有184部Youtube影片,追蹤數超過26萬的網紅Food Adventure,也在其Youtube影片中提到,#fishcutting_skills #fishcutting_videos #fishcuttingskill Japanese Street Food - Giant Japanese Cod Cutting for SASHIMI Okinawa Japan https://youtu.b...
「long tail」的推薦目錄:
- 關於long tail 在 Taipei Ethereum Meetup Facebook 的最讚貼文
- 關於long tail 在 Hapa Eikaiwa Facebook 的最佳貼文
- 關於long tail 在 kaleidoscope1856 Facebook 的最佳解答
- 關於long tail 在 Food Adventure Youtube 的最佳解答
- 關於long tail 在 Food Adventure Youtube 的最佳解答
- 關於long tail 在 Food Adventure Youtube 的最佳解答
- 關於long tail 在 Longtail - Home | Facebook 的評價
- 關於long tail 在 Large-Scale Long-Tailed Recognition in an Open World 的評價
long tail 在 Hapa Eikaiwa Facebook 的最佳貼文
=================================
「work hard」だけじゃない「一生懸命働く」の英表現
=================================
一生懸命働くことを「work hard」と表現することが一般的だと思いますが、ネイティブの会話では他にも様々な言い方が存在します。そこで今回は、アメリカ人の日常会話で良く使われている口語的な表現を2つご紹介します。
--------------------------------------------------
1) Work one's tail off
→「一生懸命働く / 身を粉にして働く」
--------------------------------------------------
休む間もなく必死に働くことを「Work one's tail off」と表します。アメリカ人同士の日常会話では、tail(しっぽ)をbutt/ass(お尻)に置き換えて、「Work one's butt off」や「Work one's ass off」と表現することもよくありますが、assはちょっと下品な響があるので、「Work one's ass off」は仲の良い相手に対してのみ使うようにしましょう。Tailとbuttは、どのようなシチュエーションで使っても問題ありません。
<例文>
He is working his tail off!
(彼は一生懸命働いている。)
I worked my butt off to finish it in time.
(時間内に仕上げるために身を粉にして働きました。)
We worked our asses off this month.
(今月は一生懸命働きましたね。)
〜会話例〜
A: What a long day. I'm exhausted!
(今日は忙しくて長い一日だった。クタクタだよ。)
B: Yeah we worked our tails off today. Why don't we go grab a drink?
(うん、今日は一生懸命働きましたね。一杯行きますか?)
--------------------------------------------------
2) Work diligently
→「熱心に取り組む / 一生懸命働く」
--------------------------------------------------
Diligentlyは「熱心に」や「勤勉に」を意味することから、「work diligently」で一生懸命働くことを表します。
<例文>
I'm looking for someone who works diligently.
(一生懸命働く人を探しています。)
We are working diligently to solve this issue.
(この問題を解決する為に、私たちは一生懸命頑張っています。)
〜会話例〜
A: What do you think about our new secretary?
(新人の秘書についてどう思いますか?)
B: I think she's doing great. She's a very diligent worker.
(よく頑張っていると思います。とても熱心に働いています。)
ブログ記事URL:https://hapaeikaiwa.com/?p=18635
~~~~~~~~~~~~~~~~~~~
無料メルマガ『1日1フレーズ!生英語』配信中!
通勤・通学などのちょとした合間を利用して英語が学べるメルマガ『1日1フレーズ!生英語』を平日の毎朝6時に配信中!ただ単にフレーズを紹介しているだけではなく、音声を使った学習プロセスが組み込まれているので、メルマガを読むこと自体が学習方法!
https://hapaeikaiwa.com/mailmagazine/
~~~~~~~~~~~~~~~~~~~
long tail 在 kaleidoscope1856 Facebook 的最佳解答
🦁 M⃞ E⃞ R⃞ L⃞ I⃞ O⃞ N⃞ 🐠
Do you know what is a Merlion and its origin?
For a really long time, I used to think that Merlion is the combined form of Mermaid and lion. It does make sense though, right?
So the Merlion is the official mascot of Singapore, depicted as a mythical creature with the head of a lion and the body of a fish.
It has been said that the Merlion reflects the legend of Sang Nila Utama, a Malay prince, who discovered a fishing island called Temasek (which mean “fish town” in Javanese). It was there that he met with a majestic creature, a lion, which purported him to name the island Singapura which translated to “Lion City” in Sanskrit. So the Merlion reflects the lion that the prince discovered.
With Sang Nila’s tale as a basis, the Merlion was designed by Fraser Brunner as an emblem for the Singapore Tourism Board, adding a fish tail to the statue to signify Singapore’s humble beginnings as a fishing village.
This sculpture is located in front of Fullerton Hotel and overlooking the Marina Bay. The night view of this place is simply spectacular!
You will also find a Merlion cub in this park. Other than these two Merlion, there are 5 more Merlion including the one in Sentosa.
Quick Quiz: Is it a male Merlion or female, eh? 🤣
❀
❀
❀
❀
❀
❀
❀
❀
❀
❀
❀
❀
#singapore #singaporelife #singaporeinsiders #singaporeblogger #singaporediaries #singapore_insta #singaporeskyline #singaporetrip #singaporetravel #singaporephotographer #exploresingapore #topsgshots #wanderlustsingapore #visitsingapore #yoursingapore #earthfocus #exploresingapore #awesome_earthpix #beautifuldestinationsaroundworld #girlstravel #prettylittletrips #travelbloggers #kaleidoscopic_journey #asia_vacations #sgig #natgeotravel
long tail 在 Food Adventure Youtube 的最佳解答
#fishcutting_skills #fishcutting_videos #fishcuttingskill
Japanese Street Food - Giant Japanese Cod Cutting for SASHIMI Okinawa Japan
https://youtu.be/TepmUe-uiSM
GIANT Cownose Ray Fish Cutting| Monster SeaFood
https://youtu.be/UPdJLmh6oD8
Live Giant Slipper Lobster Sashimi -Taiwanese street food
https://youtu.be/J5h_644YT68
Amazing Super Fast Cutting And Slicing Knife Skills | Live Eel Fillet for Grilled Eel Barbecue
https://youtu.be/fjRObSYtbpw
Giant Long Tail Red Snapper Cutting Show - Sushi & Sashimi Taiwanese street food
https://youtu.be/ch6JnOjxBEw
How to Make Lavender jobfish sashimi - Taiwanese Street Food
https://youtu.be/w1vLSQg2_PY
Live RAINBOW LOBSTER Cooked Two Ways 龙虾 ロブスター 랍스터-Taiwanese street food
https://youtu.be/JNftc-hxbKE
How To Fillet a Whole Salmon - How To Make Sashimi Series
https://youtu.be/gnUsiahkv08
#fishcutting_skills #fishcutting_videos #fishcuttingskill
long tail 在 Food Adventure Youtube 的最佳解答
#fishcutting_skills #fishcutting_videos #fishcuttingskill
Amazing Giant Mahi Mahi cutting skills- fried fish steak Taiwanese street food
https://youtu.be/24zpdLVZes0
Taiwanese street food - Giant Bluefin Tuna Fish Cutting show for Sashimi Taiwan
https://youtu.be/kUTbBeb2AR4
Japanese Street Food - Giant Japanese Cod Cutting for SASHIMI Okinawa Japan
https://youtu.be/TepmUe-uiSM
Live eel cutting for grilled eel dishes - Japanese people's favorite food
https://youtu.be/zRIHdB7D3LA
How to fillet eel for grilled eel rice -Japanese food
https://youtu.be/7EKRaTt3k6Q
Giant eel cutting skills - Fried giant eel Taiwanese street food
https://youtu.be/WsiPQ0vXJW4
#fishcutting_skills #fishcutting_videos #fishcuttingskill
GIANT Cownose Ray Fish Cutting| Monster SeaFood
https://youtu.be/UPdJLmh6oD8
Live Giant Slipper Lobster Sashimi -Taiwanese street food
https://youtu.be/J5h_644YT68
Amazing Super Fast Cutting And Slicing Knife Skills | Live Eel Fillet for Grilled Eel Barbecue
https://youtu.be/fjRObSYtbpw
Giant Long Tail Red Snapper Cutting Show - Sushi & Sashimi Taiwanese street food
https://youtu.be/ch6JnOjxBEw
How to Make Lavender jobfish sashimi - Taiwanese Street Food
https://youtu.be/w1vLSQg2_PY
Live RAINBOW LOBSTER Cooked Two Ways 龙虾 ロブスター 랍스터-Taiwanese street food
https://youtu.be/JNftc-hxbKE
How To Fillet a Whole Salmon - How To Make Sashimi Series
https://youtu.be/gnUsiahkv08
Amazing Super Fast Cutting And Slicing Knife Skills | Live Eel Fillet for Grilled Eel Seafood Barbec
https://youtu.be/fjRObSYtbpw
Live Giant Slipper Lobster Sashimi -Taiwanese street food
https://youtu.be/J5h_644YT68
Japanese Street Food - Giant Japanese Cod Cutting for SASHIMI Okinawa Japan
https://youtu.be/TepmUe-uiSM
Taiwanese Street Food - Giant GROUPER FISH Cutting Skills - Seafood Taiwan
https://youtu.be/C4HLwiRwl4Q
How to fillet COBIA FISH for Sashimi - fish cuttinf skill -Taiwanese street food
https://youtu.be/C4thuGXvvRs
Salmon Cutting Skills - How to Cut a Salmon for Sashimi & Sushi
https://youtu.be/oGQECZFvnVY
GIANT CROCODILE CUTTING - Crocodile Meat - Taiwanese Street food
https://youtu.be/UpXJIZvv7eM
Cutting live Giant Slipper Lobster Sashimi-How to Cook Slipper Lobster
https://youtu.be/c13YiirE28U
Cutting live Cuttlefish at seafood market 烏賊花枝生魚片- Taiwan street food-台灣街頭小吃
https://youtu.be/AlrYP8uKGo0
Japanese Street Food - Fish fillet for Sashimi Okinawa Japan
https://youtu.be/iC-I_JfxtE8
Knife cuts giant Long-Tail Red Snapper for Sushi & Sashimi
https://youtu.be/69cOKkrRZ4I
GIANT CROCODILE CUTTING - Crocodile Meat - Taiwan Street food
https://youtu.be/-WXIqujj7nQ
long tail 在 Food Adventure Youtube 的最佳解答
#Sashimi #seafood
Amazing Giant Mahi Mahi cutting skills- fried fish steak Taiwanese street food
https://youtu.be/24zpdLVZes0
Taiwanese street food - Giant Bluefin Tuna Fish Cutting show for Sashimi Taiwan
https://youtu.be/kUTbBeb2AR4
Japanese Street Food - Giant Japanese Cod Cutting for SASHIMI Okinawa Japan
https://youtu.be/TepmUe-uiSM
Live eel cutting for grilled eel dishes - Japanese people's favorite food
https://youtu.be/zRIHdB7D3LA
How to fillet eel for grilled eel rice -Japanese food
https://youtu.be/7EKRaTt3k6Q
Giant eel cutting skills - Fried giant eel Taiwanese street food
https://youtu.be/WsiPQ0vXJW4
GIANT Cownose Ray Fish Cutting| Monster SeaFood
https://youtu.be/UPdJLmh6oD8
Live Giant Slipper Lobster Sashimi -Taiwanese street food
https://youtu.be/J5h_644YT68
Amazing Super Fast Cutting And Slicing Knife Skills | Live Eel Fillet for Grilled Eel Barbecue
https://youtu.be/fjRObSYtbpw
Giant Long Tail Red Snapper Cutting Show - Sushi & Sashimi Taiwanese street food
https://youtu.be/ch6JnOjxBEw
How to Make Lavender jobfish sashimi - Taiwanese Street Food
https://youtu.be/w1vLSQg2_PY
Live RAINBOW LOBSTER Cooked Two Ways 龙虾 ロブスター 랍스터-Taiwanese street food
https://youtu.be/JNftc-hxbKE
How To Fillet a Whole Salmon - How To Make Sashimi Series
https://youtu.be/gnUsiahkv08
Amazing Super Fast Cutting And Slicing Knife Skills | Live Eel Fillet for Grilled Eel Seafood Barbec
https://youtu.be/fjRObSYtbpw
Live Giant Slipper Lobster Sashimi -Taiwanese street food
https://youtu.be/J5h_644YT68
Japanese Street Food - Giant Japanese Cod Cutting for SASHIMI Okinawa Japan
https://youtu.be/TepmUe-uiSM
Taiwanese Street Food - Giant GROUPER FISH Cutting Skills - Seafood Taiwan
https://youtu.be/C4HLwiRwl4Q
How to fillet COBIA FISH for Sashimi - fish cuttinf skill -Taiwanese street food
https://youtu.be/C4thuGXvvRs
Salmon Cutting Skills - How to Cut a Salmon for Sashimi & Sushi
https://youtu.be/oGQECZFvnVY
GIANT CROCODILE CUTTING - Crocodile Meat - Taiwanese Street food
https://youtu.be/UpXJIZvv7eM
Cutting live Giant Slipper Lobster Sashimi-How to Cook Slipper Lobster
https://youtu.be/c13YiirE28U
Cutting live Cuttlefish at seafood market 烏賊花枝生魚片- Taiwan street food-台灣街頭小吃
https://youtu.be/AlrYP8uKGo0
Japanese Street Food - Fish fillet for Sashimi Okinawa Japan
https://youtu.be/iC-I_JfxtE8
Knife cuts giant Long-Tail Red Snapper for Sushi & Sashimi
https://youtu.be/69cOKkrRZ4I
GIANT CROCODILE CUTTING - Crocodile Meat - Taiwan Street food
https://youtu.be/-WXIqujj7nQ
Cuts Octopus alive to yummy Fried Octopus
https://youtu.be/EYkMkYnSjGE
Live Giant Crabs cutting for steamed Crab - Taiwan street food
https://youtu.be/EkzIf6IWNMk
long tail 在 Large-Scale Long-Tailed Recognition in an Open World 的推薦與評價
Pytorch implementation for "Large-Scale Long-Tailed Recognition in an Open World" (CVPR 2019 ORAL) - GitHub - zhmiao/OpenLongTailRecognition-OLTR: Pytorch ... ... <看更多>
long tail 在 Longtail - Home | Facebook 的推薦與評價
大家好,我是Kin 林明健,LONGTAIL 餐廳酒吧的主廚與經營者。 從香港的蘭桂坊到巴黎、紐約、上海米其林星級名店, 20 多年來我不斷累積自己的的廚 ... ... <看更多>