Smart Contract Optimization: How Webacy Reduced Gas Costs by 94%

Smart Contract Optimization: How Webacy Reduced Gas Costs by 94%

Today’s announcement is a technical update rather than a product launch, but nonetheless some exciting news we wanted to share. This may also be a great set up tips / learnings for anyone building smart contracts on blockchain.

One of the features of Webacy’s architecture is that everyone gets their own smart contract. It’s decentralized by design, of course, but it also gives users total control over their own safety and asset management. As we all know, writing on-chain costs gas, and well… gas can be expensive.

For example, a couple months ago during the BAYC metaverse land sale, gas spiked so much that the gas fee ($6000 APE) was more expensive than the land itself ($5800 APE). People were actually willing to pay this ridiculous gas fee during the state of the market at the time, but that’s a story for another day.

While in beta, we worked with hundreds of early adopters (you know who you are - thank you!) and protected hundreds of thousands of dollars worth of crypto assets. However, one thing was clear: gas fees were a barrier to entry. While a bit of gas is a small price to pay to protect all your bags, it didn’t make sense for those who maybe only had one or two really important NFTs or valuable tokens. So we set out to lower this barrier to entry - everyone should be able to protect themselves in web3.

Today we’re incredibly proud to announce our updated smart contracts with reduced gas fees.

What it is

Webacy is the protection layer for self-custody. We’re a suite of services that help you secure and manage your crypto assets. Each service is unique, but for the Backup Wallet and Crypto Will, users are able to set up their protections entirely on-chain. To write on-chain, users needed to pay a gas fee.

Starting today, Webacy gas fees are up to 94% cheaper than before!

(This means you can set up your plan for less than $10 in gas with no extra charge if you’re a Grimmie holder or Season Pass partner token holder).

How we did it

With the help of our incredible advisors and smart contract experts, the Webacy team dug in deep to achieve a ridiculous amount of gas savings - all for your benefit.

Here’s just a sprinkle of what the changes included:

  • Structure and variable repacking - We restructured the smart contract variables and structures in order to memory pack them together to allow them to fit into storage slots more efficiently.
  • Utilized custom error types instead of the external eros library to reduce external multi-call and efficiency.  We made use of the latest solidity custom error types built-in to solidity allowing more efficient error codes and reverts returned from our contracts, replacing our previous errors library.
  • Reduced cross-contract calls. We were able to reduce a few of cross-contract calls by restructuring logic that's most important to its own contract to make it more efficient to execute.
  • We remove initial initializations of variables as they can be initialized on call helped us reduce the initial overall gas of the contract.
  • We cached the lengths of arrays for our for loops in order to reduce memory reads in order to execute logic more seamlessly.
  • One of the biggest changes that reduced a majority of gas costs was when we switched our factory deployment standards from CREATE that would deploy a new contract each time to CLONE ( another open zeppelin standard ) that reuses a lot of memory logic and clones existing main contract to reduce overall deployment costs for users by over 80%.
  • We reduced our structures to another level by reevaluating what our data types would be able to foresee and handle by reducing the data type sizes of several variables to overall reduce gas costs.
  • We replaced most of our “require” statements with a more efficient revert-error style of returning errors - A significant change in gas costs.
  • We also re-wrote some of our core-logic to be more efficient that supports our new structures and data types along, ensuring our contracts are more memory efficient for your best use of Webacy.

This level of optimization is bananas, but we’re here for it.

What you should do

If gas fees were a barrier to entry to protecting your web3 wallet, come give Webacy another try.

If you’ve been waiting for the small shove from behind to get your crypto security in check, this is it. The Webacy team offers direct support including 1:1 onboarding calls. Get in touch with us today!

You can connect with Webacy on Instagram and Twitter.