Understanding calldata compression and what it means for web3 game devs using Sequence smart wallets

February 19 2024

Understanding calldata compression and what it means for web3 game devs using Sequence smart wallets

Last week, Sequence shared a groundbreaking achievement with our community: we reduced gas costs for Layer 2 (L2) networks by approximately 50% across all Sequence wallet transactions! 

Our Director of Blockchain Research Agustin Aguilar wrote an in-depth article on how we managed to reach this milestone, and we encourage everyone to read it!

This accomplishment was made possible by compressing chain calldata by ~5X, resulting in significant savings for all Sequence Wallets.

The compression techniques will be live from March 1st, 2024 on various L2 networks, including Arbitrum One, Arbitrum Nova, Optimism, and Base.

What is calldata compression?

Data compression operates by identifying repetitive patterns within the data and substituting these patterns with shorter representations. 

Compressed data vs Uncompressed data

While L1 networks like Ethereum prioritize computation and long-term storage, L2 rollups emphasize lower costs for computation and storage but higher costs for input data (calldata) due to the necessity of publishing it onto L1. Compression techniques, such as removing redundancy, using bitmaps, exploiting common function signatures, employing scientific notation for large numbers, and utilizing contract storage for repetitive data, enable the reduction of calldata size, leading to substantial gas savings, for both web3 game developers and players.

Compression of calldata can be used for more than account abstraction (AA) wallets, but given the popularity of our Sequence Wallet solution and smart wallets in general, compressing calldata for these products achieves the highest impact on savings for our partners, players, and the entire ecosystem.

Why Layer 2 networks

When developing a cross-chain wallet, maintaining the same address across different networks is crucial to mitigate the risk of users sending funds to incorrect addresses on the wrong chain. However, achieving this consistency poses challenges, as the initial code of wallet contracts must be identical across networks. Although workarounds exist, having uniform contract implementations across all networks simplifies the wallet architecture.

Wallet developers face a decision: optimize for L1s or L2s? Sequence, for instance, has optimized its wallets for L1s, minimizing costs by passing almost all data as calldata. While this approach makes Sequence wallet solutions the most economical on L1s, it may increase costs on L2s. Nevertheless, the implementation of calldata compression overcomes this challenge and reduces gas costs for L2s, demonstrating ongoing efforts to enhance efficiency across different network types.

How does compression calldata impact web3 game developers?

Game developers can leverage Sequence compression calldata for their L2 games to:

  1. Significantly reduce gas costs for transactions. Operational costs for running game systems on-chain are now much lower. This is valid not only for developers implementing our Sequence Vault solution but also for those leveraging other modules of our web3 stack, like Sequence Relayer and Wallet as a Service.

  2. Making web3 experiences more efficient, scalable, and cost-effective for players. In-game purchases and primary and secondary trading become more convenient and this output likely makes sponsoring gas fees for your player base more desirable. Add something about development flexibility

  3. Enhance game quality and performance. Lower transaction costs translate into increased flexibility and creative freedom, allowing for more complex game mechanics, and smart contract functionalities, among others.

  4. Maintain high levels of security and data integrity for their transactions, since compressing calldata does not require any changes to the wallet contract and cannot result in vulnerabilities.

  5. Reduce barriers to entry for players new to web3. Along with other factors such as security, uptime, and game quality, lower transaction costs also play a key role in onboarding larger groups of web3 gamers.

Lastly, for those who were wondering, compressing transactions does imply only gas savings and does not affect in any way marketplace royalties or other similar fees.

We will soon release more resources about account abstraction and its latest developments for smart wallets. We will address potential challenges posed by ERC-4337 - which significantly increases the calldata size, making transactions more expensive, and preventing important use cases for game developers like having Guilds where AA wallets are signers. We will also showcase potential solutions to overcome these challenges, like ERC-5189, which we proudly authored.

In the meantime, if you wish to read about all the technical details behind how we successfully managed to reduce Sequence transaction costs through L2 calldata compression, you can find a step-by-step explanation in our latest deep dive, which also includes a GitHub repository in case you wish to achieve the same outcome on your smart wallet solution!

Sequence is the leading all-in-one development platform for integrating web3 into games. Onboard, monetize, grow, and retain players with Sequence’s award-winning technology. From collectibles and ownable rewards to fully on-chain experiences, Sequence’s easy-to-integrate platform solves blockchain complexities, so developers can focus on creative execution and delivering amazing player experiences. Trusted by hundreds of games and thousands of developers. Sequence is backed by Take-Two Interactive, Ubisoft, Xsolla, Bitkraft, Brevan Howard, Coinbase, Polygon, and more. To learn more, please visit: https://sequence.xyz/

Written by

Philippe Castonguay

Head of Product @ Horizon Blockchain Games and Sequence

Nicola Fraccaroli

Content Marketing Manager

Stay up to date with Sequence

We'll keep you informed about the latest and best in web3 game development.

Stop fretting web3. Just build.

Create now with the Sequence Builder or chat with a product expert to learn more.