📜 [專欄新文章] 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.
👏 歡迎轉載分享鼓掌
同時也有328部Youtube影片,追蹤數超過5萬的網紅Kohki Yamaguchi,也在其Youtube影片中提到,Thank you Storyblocks for sponsoring this episode. Click the link to check out Re: Stock and sign up for the Unlimited All-Access Plan: https://storyb...
「if this is not the case」的推薦目錄:
- 關於if this is not the case 在 Taipei Ethereum Meetup Facebook 的最讚貼文
- 關於if this is not the case 在 IELTS Nguyễn Huyền Facebook 的精選貼文
- 關於if this is not the case 在 Goodbye HK, Hello UK Facebook 的最佳貼文
- 關於if this is not the case 在 Kohki Yamaguchi Youtube 的精選貼文
- 關於if this is not the case 在 Faiz Najib Official ファイズ Youtube 的最佳貼文
- 關於if this is not the case 在 DJ Macky Suson Youtube 的最讚貼文
- 關於if this is not the case 在 what's the meaning of "it is not the case that" 的評價
- 關於if this is not the case 在 python - How do I do a case-insensitive string comparison? 的評價
- 關於if this is not the case 在 Ignoring Case Sensitivity in Power Query - YouTube 的評價
if this is not the case 在 IELTS Nguyễn Huyền Facebook 的精選貼文
TỪ VỰNG CHỦ ĐỀ WORK [Kèm bài mẫu]
🎗PHẦN TỪ VỰNG CHUNG
- work productivity: năng suất làm việc
- a nine-to-five job: công việc giờ hành chính
- poor work performance: hiệu suất làm việc kém
- sick leave: nghỉ phép vì bệnh
- professional work environment: môi trường làm việc chuyên nghiệp
- to get a well-paid job: có được 1 công việc được trả lương tốt
- to earn a high salary: có được mức lương cao
- job satisfaction: sự hài lòng khi làm việc
- to work long hours: làm việc nhiều giờ
- to limit work hours: giới hạn giờ làm việc
- to suffer from various health issues: mắc các vấn đề về sức khỏe
- low productivity: năng suất thấp
- a case in point: 1 ví dụ điển hình
- to frequently feel exhausted: thường xuyên cảm thấy kiệt sức
- to make more errors at work: sai sót nhiều hơn tại sở làm
- to have serious consequences for …: gây ra hậu quả nặng nề cho…
- busy work schedules: lịch trình công việc bận rộn
- to be self-employed: tự làm chủ
- to pursue a career: theo đuổi sự nghiệp
- to learn various skills and experience: học được những kỹ năng và kinh nghiệm
🎗TỪ VỰNG WORKING FROM HOME
- to provide us with flexibility and convenience: cung cấp cho chúng ta sự linh hoạt và tiện lợi
- do not need to go to the office on a daily basis: không cần tới công sở hàng ngày
- to save a large amount of time commuting back and forth to work: tiết kiệm 1 lượng lớn thời gian đi lại
- to have the freedom to choose where and when they want to work: có sự tự do lựa chọn nơi đâu và khi nào họ muốn làm việc
- to require high levels of discipline and commitment: đòi hỏi mức độ kỷ luật và cam kết cao
- to have no supervision and restrictions: không có sự giám sát hay hạn chế nào
- might experience feelings of loneliness and isolation sometimes: thỉnh thoảng có thể trải qua cảm giác cô đơn và đơn độc
- to easily get distracted by things like movies/ online games/…: dễ dàng bị sao nhãng bởi các thứ như phim, games online
- cannot concentrate entirely on their work: không thể hoàn toàn tập trung vào công việc
- to negatively affect their work performance and productivity: ảnh hưởng tiêu cực tới hiệu suất làm việc
- to be difficult to develop social skills (communication, teamwork skills,…): khó phát triển các kỹ năng xã hội (kỹ năng giao tiếp, làm việc đội nhóm,…)
- to have less chance to interact and communicate directly with their colleagues and clients: có ít cơ hội tương tác và giao tiếp trực tiếp với đồng nghiệp và khách hàng
🎗PHẦN BÀI MẪU
People tend to work longer hours nowadays. Working long hours has a negative effect on themselves their families and the society so working hours should be restricted. Do you agree or disagree?
Working longer hours is getting more common in today’s society. I personally believe that this trend not only has a severe impact on the workers themselves, but also on their families and the community as a whole. Therefore, I totally agree with the idea of limiting working hours.
A few decades ago, a person normally worked an average of eight hours per day. Average daily working hours in recent years, however, have significantly increased to ten or even fourteen. This, in my opinion, adversely affects employees’ health and productivity. For example, people who spend longer at work are more likely to suffer from various health issues, ranging from fatigue to more serious problems like anxiety disorders or even stroke . Failing health leads to more sick leave , poor work performance and low productivity. My cousin is a case in point. Working nearly twelve hours on a daily basis, he frequently feels exhausted and makes more errors at work than he used to.
I also think that extended hours of work has serious consequences for families and communities . At the family level, busy work schedules prevent people from taking frequent family trips or even just having meals together. Relationships among members are greatly weakened if they cannot make time for each other. In terms of community life, overworked people do not devote time to voluntary activity that brings benefits for their society. My uncle, for example, hardly has time for local community service projects such as conservation work or working with a charity because he works more than sixty hours per week.
In conclusion, I would argue that working time should be reduced since the frequency of long working hours exerts an adverse effect on employees, their family bonds and their community.
(293 words, written by Nguyen Huyen)
https://ielts-nguyenhuyen.com/tu-vung-ielts-chu-de-work/
#ieltsnguyenhuyen #ieltsvocabulary #ieltswriting
if this is not the case 在 Goodbye HK, Hello UK Facebook 的最佳貼文
政府自行放棄權力
英國政府今日突然(又再)U-Turn,擱置放咗風好耐,响國內大型活動或者服務場所用"Vaccine Passport"嘅政策,由接任無耐嘅衛生大臣Sajid Javid解釋,
“If the government is going to propose anything that is going to infringe on people’s freedoms it better have a really, really good case. And unless you’ve got that case, you should not be proposing it. That’s why we don’t think vaccine passports are necessary at this point. We’re keeping it in reserve, but we’re not going to go ahead.”
(如果一個政府準備提議任何侵犯國民自由嘅政策,就必須要有一個非常非常好嘅原因。除非揾到一個咁嘅理由,否則就唔應該提出。呢個就係點解我地(政府)唔覺得疫苗護照响呢個時候係必須,現時只會保留備用,唔會執行。)
另外,英國政府响呢個星期內宣布自行放棄上年因為疫情緊急立法(Coronavirus Act)給予權力,包括以抗疫理由有權強行關閉酒吧、食肆同學校,禁閉受感染人士,响活動上加入限制呢响啲正常日子政府唔應該有嘅無限法律就係法律嘅權力,只係保留有權要求感染人士自我隔離。肥波係咁講。
“These extraordinary times required necessary but intrusive measures. But I’m determined to get of rid of any powers we no longer need because of our vaccine defences."
(响非常時候,(政府)係要呢啲必需但有侵擾性嘅權限,但响疫苗嘅保障之下已經唔再需要,所以我決定放棄呢啲權力。)
Patreon原文:
政府放棄侵犯國民自由嘅權力
https://bit.ly/3C51MWZ
#自由原則
#民主政府
#英國人是不能管的
報導:
《The Times》Covid vaccine passports scrapped for winter by Boris Johnson
https://www.thetimes.co.uk/article/ccc2072c-1346-11ec-a8a6-db0b408d06d6
《The Telegraph》Boris Johnson set to repeal draconian Covid-19 powers that shut schools and pubs
https://www.telegraph.co.uk/politics/2021/09/11/boris-johnson-set-repeal-draconian-covid-19-powers-shut-schools/
**************************************
📢乞食廣告:文字、時間與心血有價
🥣乞兒兜:
https://www.patreon.com/goodbyehkhellouk
**************************************
if this is not the case 在 Kohki Yamaguchi Youtube 的精選貼文
Thank you Storyblocks for sponsoring this episode. Click the link to check out Re: Stock and sign up for the Unlimited All-Access Plan: https://storyblocks.com/Kohkiyamaguchi
So here's my overall setup and what I use on a day to day photography shoot.
If I'm not shooting for YouTube, I leave my FX3 and RS2 behind.
Super curious to see what your favorite gear is so leave a comment below, maybe it will inspire me to get it :D
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
My Instagram: https://www.instagram.com/Kohki
My Store: https://www.kohkipresets.com
My Website: https://www.kohkicontent.com
My Gear: https://www.amazon.com/shop/kohki
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Links to all gear in this video:
Wandrd PRVKE Backpack
https://wandrd-pacific.com/products/prvke
Stone Island Map Bag
https://www.stoneisland.com/ca/stone-island/waist-bag_cod17040736qp.html
MXDVS Accessories
https://store.mxdvs.co
DJI Ronin RS2
https://store.dji.com/jp/product/rs-2?vid=96711
Sirui Tripod
https://www.ebay.com/itm/323856166243?mkevt=1&siteid=1&mkcid=2&mkrid=21581-161791-616585-7&source_name=google&mktype=pla_ssc&campaignid=12961564719&groupid=121317197266&targeted=pla-1248581038030&MT_ID=&adpos=&device=c&googleloc=1009300&itemid=323856166243&merchantid=116792603&geo_id=104&gclid=CjwKCAjwgviIBhBkEiwA10D2j7jw75bYWSA-ONSukePdSTGWZSdawZ7xkotyipeG9KB6Q_eWXbrbSRoCIPQQAvD_BwE
Sony A7RIII
https://www.bhphotovideo.com/c/product/1645237-REG/sony_ilce7rm3a_b_alpha_a7r_iii_mirrorless.html?gclid=CjwKCAjwgviIBhBkEiwA10D2j_G68HxWqQfW0gGkb2lg8vtWUMkXZWcrjGvHRnlzvaAEeuJhBGOHERoClR8QAvD_BwE
Small Rig L bracket
https://www.smallrig.com/smallrig-l-bracket-for-sony-alpha-7-iii-alpha-7r-iii-alpha-9-camera-2122.html?sku=2122D&gclid=CjwKCAjwgviIBhBkEiwA10D2j96SkOmOEoKjMD6HBr5D_foBlaXY9KDz4hdx01YDxsz9OeYPK12vZxoCHNUQAvD_BwE
Sony FX3
https://www.bhphotovideo.com/c/product/1624226-REG/sony_ilme_fx3_fx3_cinema_camera.html
Sony GM 16-35mm f2.8
https://www.bhphotovideo.com/c/product/1338516-REG/sony_sel1635gm_fe_16_35mm_f_2_8_gm.html
Sony Zeiss 35mm f1.4
https://www.bhphotovideo.com/c/product/1126137-REG/sony_sel35f14z_distagon_t_fe_35mm.html
Sony Zeiss 55mm f1.8
https://www.bhphotovideo.com/c/product/1008124-REG/sony_sel55f18z_sonnar_t_fe_55mm.html
Sony GM 70-200mm f2.8
https://www.bhphotovideo.com/c/product/1222776-REG/sony_sel70200gm_fe_70_200mm_f_2_8_gm.html
Voigtlander 10mm f5.6
https://www.bhphotovideo.com/c/product/1219550-REG/voigtlander_ba334b_heliar_hyper_wide_10mm_f_5_6.html
Sandisk SD card
https://www.bhphotovideo.com/c/product/1617741-REG/sandisk_sdsdxdk_128g_ancin_128gb_extreme_pro_uhs_ii.html
Lexar SD card
https://www.bhphotovideo.com/c/product/1592046-REG/lexar_lsd2000128g_bnnnu_128gb_2000x_sd_uhs_ii.html
Memory Card Case
https://www.amazon.com/Beeway®-Memory-Card-Carrying-Holder/dp/B01ESSWXH2/ref=rvi_2/136-9178805-2200928?pd_rd_w=iScQp&pf_rd_p=c0296674-5a83-4ad6-b035-0702d2b359df&pf_rd_r=FCVP2SESNXTSKEQC8H4D&pd_rd_r=70488089-0360-44cf-93f8-12ec7778582b&pd_rd_wg=SUHZT&pd_rd_i=B01ESSWXH2&psc=1
Nisi Black Mist Filter
https://nisifilters.jp/product/black-mist-1-4/
Marumi Circular PL Filter
https://www.bhphotovideo.com/c/product/973423-REG/marumi_amxcpl82_82mm_exus_circular_polarizer.html
Nisi Step-Up Ring
https://nisiopticsusa.com/product/nisi-ti-pro-77-82mm-titanium-step-up-ring/
PolarPro VND Filter
https://www.bhphotovideo.com/c/product/1601822-REG/polarpro_82_2_5_vnd_ed2_pmvnd_signature_edition_ii.html?gclid=CjwKCAjwgviIBhBkEiwA10D2jy28vttAwMGno3dHq4v3dF51U0h5EiJkGu1RWkCXWNEFrbkiLa_W_RoCUwwQAvD_BwE
TYCKA Filter Pouch
https://www.amazon.com/TYCKA-Removable-Water-Resistant-Dustproof-Adjustable/dp/B07T8HTR17
Giottos Rocket Dust Blower
https://www.bhphotovideo.com/c/product/318545-REG/Giottos_AA1910_Rocket_Air_Blower.html
Aputure Light
https://www.bhphotovideo.com/c/product/1268206-REG/aputure_al_m9_amaran_pocket_sized_led.html?gclid=CjwKCAjwgviIBhBkEiwA10D2j339QH7ED6Pd9Y-9WAdroazmIiQNX4_hSbjPs-H840RhyOQW-4M3RRoCGnUQAvD_BwE
LensSkirt Lens cover
https://lenskirt.com/lenskirt/
Anker Battery Bank
https://us.anker.com/collections/portable-power/products/a1263
*I do NOT receive any commission from these links.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Chapters:
0:00 Intro
0:39 Camera Bag
1:58 Small essentials
2:30 Messenger Bag
3:11 Gimbal / Tripod
3:46 Cameras
4:46 Lenses
8:35 AD
9:47 Batteries
10:23 SD cards
11:04 Filters
13:10 Accessories
14:49 End
#WhatsInMyCameraBag

if this is not the case 在 Faiz Najib Official ファイズ Youtube 的最佳貼文
I know I’m late but here’s a full review of my lantern diffuser ?❤️ in case if you guys are all interested on getting your very own essential oil kit you can head on to Instagram and search @cincessminyak they’ll help you with everything that you need!
First of all, this is not a sponsored video, Alhamdulilah I bought this for myself ??? #selflove #whathaveigotmyselfinto
I remember telling my mom, MAMA THESE ARE JUST OILS!! later did she know I fell in love with it after a while, I was such a hypocrite ? essential oils really helped me a lot when it comes to work, sleep and let’s just say, it is one of the things that gave me peace in life too ✨
I’ve been wanting this and have been waiting for this for a long time and thank you so much Aunty @ziezizag & aunty @dillazag for helping me with everything, Alhamdulilah I’m so happy :’)
I’ll be posting the longer unboxing video next Friday so please stay tune!
#SelfLove #NotSponsored
Also stay tune to my next Essential Oil Diffuser Unboxing Video where I’ll be unboxing the owl ? diffuser that my friends sent me as my 19th Bday Gift! Coming out soon so stay tune to that ❤️❤️ #FEATHERTHEOWL #YOUNGLIVING

if this is not the case 在 DJ Macky Suson Youtube 的最讚貼文
I stumbled upon this fancy restaurant, Dos Mestizos which you can locate at the Main road, Station 1. Across Seawind Resort.
I was fascinated with how they seem to always get people to dine in and have drinks. On May 12, 2021, I visited the place and dined in and it was not a pleasant experience as I expected.
I am DJ Macky Suson, and I have been here in Boracay for two weeks. After living in Singapore for 10 years and suffered from mental health disorders, I chose Boracay as my place to recover. I have decided to review the places I go to, to help this beloved island improve on things it offers- food, a place to stay, drinks, activities, price and most importantly, the service.
I was greeted by the owner, if I am not mistaken with warm welcome which I expected as I always see him at the place talking to people. Dos Mestizo’s signature ‘Mestizo’ is traditional Spanish dishes elevated by complementing Filipino flavors and other carefully selected ingredients imported from Europe. The menu was not that comprehensive and all I could see was Paella. And so I thought, that’s probably what they are pushing and that’s their best selling food. I ordered a glass fresh pineapple juice, PAELLA VALENCIANA, small. The price was roughly 30 Singapore Dollars and I was expecting for it to be really good.
There was a complimentary bread that’s served and I actually loved it, specially the sauce. After finishing it, I thought, the paella could be better. It was not the case.
In Barcelona, they have a fast food for paella and most locals there said it’s bad. The truth is, my paella experience at that fast food in Barcelona was a lot way better than in Dos Meztisos.
PAELLA VALENCIANA looked great. I wish it tasted great but it was not the case. It was really dry to begin with. The rice seemed to be hit by El Niño as it was as dry as the season. The overall taste was okay. I mean for 30 Singapore Dollars, it’s unacceptable. The serving was good for 1 adult and one kid. The nightmare happened when I ate a portion of meat which tasted rotten. It seemed like it was placed in the fridge for months and they did not notice. It destroyed the entire experience. But at that time, I wanted to throw up but I could not because the owner was literally in front of me and so with other 3 guests.
This place is probably great for drinking but for food, I would not recommend for people to come here. I am happy I did not have food poisoning.
Next: I went to Ambassador in Paradise and tried their Night in Ambassador Cocktail. Was it great? Follow for the review. "Boracay Videography Service"
"Boracay Videographer"

if this is not the case 在 python - How do I do a case-insensitive string comparison? 的推薦與評價
... <看更多>
if this is not the case 在 Ignoring Case Sensitivity in Power Query - YouTube 的推薦與評價

... Case and Removing Duplicates 8:22 A final note 9:22 My Courses ===== WHO AM I? ===== A lot of people think that my name is Goodly, it's NOT ... ... <看更多>
if this is not the case 在 what's the meaning of "it is not the case that" 的推薦與評價
"It is not the case" is a more formal way of saying "it is not true". ... <看更多>