📜 [專欄新文章] 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.
👏 歡迎轉載分享鼓掌
同時也有36部Youtube影片,追蹤數超過361萬的網紅Dan Lok,也在其Youtube影片中提到,Are You Still Giving People Their Time In Order To Help Them? Stop Wasting Your Time And Start Helping People In A Smarter Way. Sharpen Your Persuasio...
「financial order」的推薦目錄:
- 關於financial order 在 Taipei Ethereum Meetup Facebook 的最讚貼文
- 關於financial order 在 IELTS Fighter - Chiến binh IELTS Facebook 的最讚貼文
- 關於financial order 在 管碧玲 (kuanbiling) Facebook 的最佳解答
- 關於financial order 在 Dan Lok Youtube 的精選貼文
- 關於financial order 在 Campus TV, HKUSU 香港大學學生會校園電視 Youtube 的最讚貼文
- 關於financial order 在 Eric Giuliani Youtube 的精選貼文
financial order 在 IELTS Fighter - Chiến binh IELTS Facebook 的最讚貼文
- Chữa đề Writing thật tiếp theo thôi cả nhà ơi - Đề số 10 nhé: Some people think it is more important to spend public money on promoting a healthy lifestyle in order to prevent illness than to spend it on the treatment for people who are already ill. To what extent do you agree or disagree?
Bài mẫu:
The state spending on public health has become a widely perpetual concern. Some individuals argue that these already scarce resources should be reserved for the prevention of lifestyle-related illness. In my opinion, the government should focus more on the prevention of illnesses rather than medical treatment.
On the one hand, certain acute diseases, non-preventable regardless of governmental efforts to promote a healthy lifestyle, still need a state budget allocation for medical care. One of the primary duties of the government is to provide publicly funded healthcare to the whole population. Therefore, covering therapeutic and medical costs for those already developing symptoms of acute conditions would be a significant part of that duty, helping mitigate the financial burden associated with those maladies. In other words, a dearth of investment in treatment would be devastating patients’ individual life and wreaking havoc on overall social welfare.
On the other hand, promoting a healthy lifestyle as a prevention strategy is meant to avoid the entire economic burden of chronic diseases, affecting a significant proportion of the population. Those conditions, occurring across different life course stages, share common preventable risk factors relating to unhealthy behaviors, including poor nutrition, inadequate physical activity, and chronic heavy drinking and smoking. If left unchecked, trends in chronic diseases risk factors combined with a growing and aging population will increase the numbers of people living with chronic conditions, later causing the heavy burden of illness in patients, their families, and the community. Therefore, given a scarcity of state budgets for various public services, the government should directly provide information, including health education campaigns, or regulating information, such as limits on advertising and guidelines on food labelings. As a result, positive changes in individual lifestyle would follow, helping them withstand the ravages of time, and saving the state budget for other economically beneficial needs, such as technological investment, education, and infrastructure, rather than spending on treatment.
In conclusion, while allocating its healthcare budget in treatment, the government should promote a healthy lifestyle to avoid preventable chronic diseases due to its economic rationality.
Words: 341
----
Tháng 9 này, cùng IELTS Fighter Find your Fire - thắp đam mê, kệ Covid, học tập nâng cao kiến thức mỗi ngày nha. Các bạn cùng chờ đón cuộc thi Đại sứ IELTS Junior nè, Livestream học tập mỗi tuần và workshop online cho sinh viên siêu thú vị nữa nha. Theo dõi fanpage IELTS Fighter - Chiến binh IELTS để cập nhật thông tin nóng thường xuyên nhé.
financial order 在 管碧玲 (kuanbiling) Facebook 的最佳解答
財經時報報導:
華盛頓冒著激怒北京的風險,提案改變台灣在美國辦事處名稱
Washington risks Beijing ire over proposal to rename Taiwan’s US office
(Financial Times https://reurl.cc/L735ZL)
根據美國官員內部消息,華盛頓認真考慮同意台灣的要求,讓台灣將《台北經濟文化代表處 Taipei Economic and Cultural Representative Office》更名為《台灣代表處Taiwan Representative Office》
消息指出,Kurt Campbell(白宮亞洲顧問 White House Asia adviser)及許多官員都支持改名。
最終決定尚未定案,若同意,此行政命令將需要由拜登總統親自簽署。
目前美台灣政府尚無發表評論;駐華盛頓的北京大使則表達堅決反對。
The Biden administration is moving towards allowing Taipei to change the name of its representative office in Washington to include the word “Taiwan”, a move likely to trigger an angry response from Beijing.
Multiple people briefed on internal US discussions said Washington was seriously considering a request from Taiwan to change the name of its mission in the US capital from “Taipei Economic and Cultural Representative Office” (Tecro) to “Taiwan Representative Office”.
Kurt Campbell, White House Asia adviser, has backed the change, according to two people with knowledge of the discussions. One said the request had wide support inside the National Security Council and from state department Asia officials.
A final decision has not been made and would require President Joe Biden to sign an executive order, said people briefed on the matter.
financial order 在 Dan Lok Youtube 的精選貼文
Are You Still Giving People Their Time In Order To Help Them? Stop Wasting Your Time And Start Helping People In A Smarter Way. Sharpen Your Persuasion Skills To Impact More People Today: https://stopwastingtime.danlok.link
Wanting to help others is a worthwhile goal - and yet you can only help one person at a time. If you want to make a true impact in this world you need to stop wasting your time and find ways to automate your help. Watch this video for Dan Lok's top tips on how to stop wasting your time and do high-impact activities instead.
? SUBSCRIBE TO DAN'S YOUTUBE CHANNEL NOW ?
https://www.youtube.com/danlok?sub_confirmation=1
? UNLOCK A Better Version Of Yourself, Check Out My Shop: https://shop.danlok.link ?
Check out these Top Trending Playlists -
1.) Boss In The Bentley - https://www.youtube.com/playlist?list=PLEmTTOfet46OWsrbWGPnPW8mvDtjge_6-
2.) Sales Tips That Get People To Buy - https://www.youtube.com/watch?v=E6Csz_hvXzw&list=PLEmTTOfet46PvAsPpWByNgUWZ5dLJd_I4
3.) Dan Lok’s Best Secrets - https://www.youtube.com/watch?v=FZNmFJUuTRs&list=PLEmTTOfet46N3NIYsBQ9wku8UBNhtT9QQ
Dan Lok has been viewed more than 1.7+ billion times across social media for his expertise on how to achieve financial confidence. And is the author of over a dozen international bestselling books.
Dan has also been featured on FOX Business News, MSNBC, CBC, FORBES, Inc, Entrepreneur, and Business Insider.
In addition to his social media presence, Dan Lok is the founder of the Dan Lok Organization, which includes more than two dozen companies - and is a venture capitalist currently evaluating acquisitions in markets such as education, new media, and software.
Some of his companies include Closers.com, Copywriters.com, High Ticket Closers, High Income Copywriters and a dozen of other brands.
And as chairman of DRAGON 100, the world’s most exclusive advisory board, Dan Lok also seeks to provide capital to minority founders and budding entrepreneurs.
Dan Lok trains as hard in the Dojo as he negotiates in the boardroom. And thus has earned himself the name; The King of Closing.
If you want the no b.s. way to master your financial destiny, then learn from Dan. Subscribe to his channel now.
★☆★ CONNECT WITH DAN ON SOCIAL MEDIA ★☆★
YouTube: http://youtube.danlok.link
Dan Lok Blog: http://blog.danlok.link
Dan Lok Shop: https://shop.danlok.link
Facebook: http://facebook.danlok.link
Instagram: http://instagram.danlok.link
Linkedin: http://mylinkedin.danlok.link
Podcast: http://thedanlokshow.danlok.link
#DanLok #StopWastingTime #Motivation
Please understand that by watching Dan’s videos or enrolling in his programs does not mean you’ll get results close to what he’s been able to do (or do anything for that matter).
He’s been in business for over 20 years, and his results are not typical.
Most people who watch his videos or enroll in his programs get the “how-to” but never take action with the information. Dan is only sharing what has worked for him and his students.
Your results are dependent on many factors… including but not limited to your ability to work hard, commit yourself, and do whatever it takes.
Entering any business is going to involve a level of risk as well as massive commitment and action. If you're not willing to accept that, please DO NOT WATCH DAN’S VIDEOS OR SIGN UP FOR ONE OF HIS PROGRAMS.
This video is about STOP WASTING TIME.
https://youtu.be/OQtwa4M9alI
https://youtu.be/OQtwa4M9alI

financial order 在 Campus TV, HKUSU 香港大學學生會校園電視 Youtube 的最讚貼文
【現場直播|Live】 二零二一年度第二次評議會常務會議|The 2nd Ordinary Council Meeting, Session 2021
Date: 28th March 2021 (Sunday)
Time: 14:00 –
Venue: Union Council Chamber UG201, Union Building
Agenda
0. Meeting call to order and sing the Union Song
Section A
1. To read out the correspondences
2. To receive maiden speeches of new Council members
3. To report the motions carried by circulation
4. To receive and adopt the agenda
5. To receive and adopt the minutes of previous Meetings
Section B
1. To receive the Council Chairperson’s Address
2. Questions put to the Union Executives, other Councillors, other Official Observers,
Council Committees, or Union sub-organisations
3. To nominate and appoint student members for University Committees
4. To appoint members of Council Committees, HKUSU Council, Session 2021
5. To appoint acting Union Executives of Session 2021
6. To receive annual reports of Union Executives, Session 2020
a. President
b. Vice-President (Internal)
c. Vice-President (External)
d. Financial Secretary
e. University Affairs Secretaries I
f. Student Welfare Secretary
g. Administrative Secretary
7. To receive the annual reports of Popularly Elected Union Councillors, Session 2020
a. Popularly Elected Union Councillor I
8. To receive the annual reports of Campus Media, Session 2020
a. Undergrad, HKUSU
b. Campus TV, HKUSU
9. To endorse statements issued by Council Committees
10. Any Other Business

financial order 在 Eric Giuliani Youtube 的精選貼文
Sky's the Limit is available on Amazon: https://amzn.com/B08X1B3QGQ
Have you ever dreamed of quitting everything to travel around the world?
Inexperienced and ill-prepared, thirty-four-year-old Eric Giuliani set out to make his way around the world without flying and with little money after quitting his corporate career. With ideas of becoming a globetrotting travel writer, photographer, and filmmaker, he attempts to reinvent himself on the road and begins to barter his way across Africa, then Europe, Asia, Australia, North and South America, and Antarctica.
Sky’s the Limit is the story of Eric’s 1,000-day, 70,000-mile journey, one that is both internal and external—think Eat, Pray, Love meets Bear Grylls. His overland travel is as arduous as it gets and he primarily relies on public transportation—tin-can buses, dilapidated trains, and cargo ships to cross the oceans. His internal journey is equally arduous. Fighting creative insecurities, devastating heartbreak, financial fears, and long stretches of isolation, he repeatedly must dig down deep in order to persevere.
Often driven by intuition and defiant determination, Eric’s adventure pushes him past rocky stretches: a tense, two-day bus ride across a region recently attacked by the terrorist outfit Al Shabaab; a train journey in Europe alongside Syrian refugees Eric is powerless to help; a mixup in Siberia that leaves him stranded in the middle of winter. There are joyful moments as well: swimming with great white sharks in South Africa, falling in love in Australia, a booze cruise through Ha Long Bay, and finding a community of friends in Antarctica. Along the journey, Eric discovers his creativity and also his purpose.
An absorbing, first-hand account of overcoming seemingly impossible obstacles, Sky’s the Limit will inspire readers to dream up thrilling journeys of their own.

financial order 在 What is a Financial Order in Divorce? - Simpson Millar 的相關結果
A Financial Order in divorce is a Court Order which sets out the financial arrangements between you and your ex. For initial advice call 0800 260 5010. ... <看更多>
financial order 在 What is a financial order and why are they important? 的相關結果
A Financial Consent Order creates a legally binding financial agreement between parties that can be enforced in the event that a party breaches ... ... <看更多>
financial order 在 Money and property when you divorce or separate - GOV.UK 的相關結果
Get the court to decide. If you cannot agree on everything, you can ask a court to make a financial order. ... <看更多>