It's our responsibility as developers to do everything we can to reduce our gas footprint on #ethereum, especially with prices so high. Here's an example of the steps we take to save you money: (a thread 👇)
An Ethlings Wearable has 5 pieces of data. Its bonding curve scalar and expiration, its total supply, its reserve balance, and the total royalties accrued.
In #Solidity, all of these values are stored as a number comprised of 256 bits. But Ethereum charges us gas for every bit we use. It's in our users best interest that we optimize every bit of storage!
If we're able to somehow condense our 5 pieces of data into a single one, we could save our users a lot of gas.
So what did we do? The curve's scalar is a value from 0-3 so that only takes 2 bits (00, 01, 10, or 11). The expiration is saved in seconds and we can store that in 40 bits (this gives us roughly 32,000 years of flexibility)
We can assume that the supply will never eclipse 1,000,000 (another 20 bits) so we have 256 - 2 - 40 - 20 = 194 bits left over. That's 97 bits for our remaining royalty and reserve balances.
So we wrote some code to encode all 5 of these values into a single 256 bit space. And it was under 100 lines of code! This extra effort is just one of the ways we're being diligent about gas costs. Image
We'll be sharing more about our development journey here and in our Discord. Follow along for more tips and stories! discord.gg/MW856HpFhq

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Ethlings

Ethlings Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @ethlings

10 May
Why @graphprotocol is such an important part of developing user-centric blockchain apps. A thread (👇)
Databases are a standard part of traditional software. You can use them to store and organize data. And what's really valuable about them is your ability to search and retrieve information in a way that makes sense.
An example might be a simple social network. Imagine how hard it might be to show a user feed if you couldn't just ask a database "Send me the most recent 10 posts by people I follow."
Read 8 tweets
10 May
We're proud that the Ethlings discord community is so collaborative and thoughtful.

Here are 18 #NFT learning resources curated by the community: tweets, articles, podcasts, and videos to suit your preferred learning style.

(pls also share *your* favorite resources below)

👇🏾
1/
Non-fungible tokens from @ethereum
(The Ethereum community has built a number of constantly evolving guides on DeFi & other topics too. Highly recommend)
ethereum.org/en/nft/#what-a…
2/
NFTs - the Modern Finance Podcast by @kevinrose
(You can't go wrong with Kevin's podcasts. He's interviewed the Larva Labs & Art Blocks founders, Beeple, Gary Vee, etc)
modern.finance/nfts-blockchai…
Read 20 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!

:(