Gas Optimization In Solidity: Strategies For Cost-Effective Smart Contracts
Gas is the “fuel” that powers smart contract execution. This article offers practical strategies for Solidity gas optimization.
🇺🇦 Hacken stands with Ukraine!Learn more
2022 wasn’t entirely favorable for the crypto industry, and no one knows what exactly is further down the road. Due to the ever-changing and sometimes confusing financial landscape, predictions vary from unavoidable collapse to total mass adoption. Most analysts agree that blockchain will change things forever, just like Big Data and AI, but it won’t happen overnight. Is it possible to predict in what direction things are headed anyway? Specific trends in the crypto space let us make these five educated guesses.
Prove Liabilities + Prove Assets = Prove Solvency
FTX’s collapse hindered mainstream adoption and diluted the crypto industry’s image for reliability. Whether through regulation, self-regulation, or a combination of both, the industry will find a way to solve the trust problem. How to increase trust? Cryptographic techniques will restore digital trust in Web3. The three steps to restore confidence are:
A Proof of Reserves Audit is the most likely solution for boosting transparency. The biggest cryptocurrency exchanges and major crypto influencers are behind the idea. The goal is to prove the solvency and collateralization of a crypto entity, ensuring that it can pay back its debts.
Right now, we use the Merkle method to prove solvency. The Merkle sum tree technique makes the process more private than simply providing the list of all deposits and coins (“proof of liabilities”) as well as ownership of the private keys to coins (“proof of assets”). The Merkle tree is a nodes-system where each node consists of a balance and hash pair. Each balance and hash is a sum of the two pairs from the node below. Therefore, the Merkle sum tree technique offers both correctness of information and privacy. This method proves that the entity has the funds to pay back while keeping data private.
An even more innovative approach for transparency is to use ZK-SNARKs. According to Ethereum’s co-founder Vitalik Buterin, ZK-SNARKs are extremely powerful and would “greatly simplify and improve privacy in proof-of-liabilities.
Such a powerful technology is revolutionizing because it is general-purpose. It can be adapted not just for exchanges but also for lending. In some sense, this protocol can help detect fraud or malicious activity in all sorts of lending, possibly completely negating the risks of flash loan attacks.
We can also use this powerful approach to prove assets. We need to prove assets to show that the entity has private keys of X coins to pay back users. Under current circumstances, where exchanges store their coins on cold wallets, proving anything is very expensive and tedious. Another option is to have a few public long-term addresses. This case is fairly simple, most exchanges already use it. But this method is not as private or secure as it can be. We can improve it by having many addresses, using them only for a few transactions, and working with an auditor to “randomly” select addresses to prove ownership. One step forward would be to use ZKP technology (i.e., set all addresses into 1-of-2 multi-sig and run a zero-knowledge proof over the blockchain).
Moreover, the entity under audit can theoretically move the funds into a specific address to prove collateralization but move funds elsewhere after the audit is complete. This moving back and forth would be an unfair practice. Rather than relying on the entity’s integrity, we can do proof of solvency in real time or even establish a fixed routine for proving reserves for all exchanges. Hacken’s Proof of Reserves Audit can be upgraded to having nearly real-time coverage.
The major point is that the revolutionary ZK-rollup technology or the validium concept (a cryptographic method to prevent entities from stealing their users’ funds) would change the landscape for cryptocurrency exchanges. Rather than having Centralized vs. Decentralized Exchanges, we would have a more diverse spectrum of decentralization options where one would have both efficiency (thanks to centralization) and trust (thanks to cryptographic techniques preventing fund abuse).
Overall, Proof of Reserves is a huge next step for the Web3 industry, and it will also push the boundaries of cryptographic techniques to prove transparency.
Market forces are turning security into a necessity. Smart contract audits, bug bounties, and pentests will become a point of parity rather than a point of difference. We will see a massive change towards a security-first mindset, secure software development lifecycle, and operational security.
The purpose of the Secure Software Development Life Cycle is to prevent hacks and exploits from the very start. We’ll see Web3 companies establishing rigid SDL practices that are more common for Web2.
Operational security becomes important again as data breaches plague organizations. Web3 companies will set up OpSec processes to avoid private key loss and other types of data breaches by implementing SOC-2, ISO 27001, and penetration testing.
In the sphere of cybersecurity, the most important points moving forward are
At Hacken, we are now working in four innovative directions to facilitate the adoption of the security-first mindset for Web3 companies:
Hacken is bringing the principles of Web2 control systems and security practices to Web3 but adjusting them for DLT technology.
At the moment, Hacken is the first on the market to launch a comprehensive dApp Audit service to close one of the most vulnerable elements of the DeFi system. We have also started a beta testing service for actively monitoring smart contract threats called Hacken Extractor. This service helps teams respond quickly when the first suspicions arise. Sometimes projects do not even realize that they are being attacked. We envision turning active monitoring into a massive SaaS product for the B2B segment. We are also one of the first to launch Proof of Reserves Audit, an external review of on-chain funds and liabilities to assess the true solvency and collateralization of crypto exchanges and DeFi platforms.
Crypto news hasn’t been lacking high drama. If you’ve missed it, a wave of bankruptcies has shaken the whole industry. Big names like Voyager, Celsius, and FTX are no longer major blockchain market players. To prevent millions from screaming “bubble” after the downfall of these giant DeFi platforms, some investors are pushing for laws and regulations that would make blockchain a safer space and scare away cyber burglars of all sorts.
Strict regulation could be expected any time soon as the governments have been waiting for events like these to implement stringent measures over the blockchain. Lawmakers in the USA and worldwide are trying to get it right.
Even though the government regulation is something that doesn’t sound right when it comes to the blockchain sphere, many experts claim it’s going to be a good thing for the entire industry since it would:
Sadly, there is nothing sustainable about Bitcoin transactions, with each one producing circa 772 kg of carbon dioxide. Every major protocol focuses on greener credentials at the moment. Notably, Ethereum finally completed its so-called Merge, a change from proof of work consensus to proof of stake that is supposed to bring about a 98% reduction in the total amount of energy consumed.
The switch could have been an epic failure, but it turned out to be a success that has made the current crypto winter a little less icy. This victory isn’t a cure-all for crypto ills, but it’s still great news for the blockchain industry in general. Many other POW-based blockchain networks might follow suit and move to a less energy-consuming version to keep afloat, but Bitcoin, the largest market cap of any crypto, is likely to stay aside from the whole “greenification” movement. There is little hope for similar changes within the network since its proponents seem to be committed to the POW algorithm as they believe it to be more decentralized and secure.
Blockchain use cases are vast, and their actual implementation is expanding.
The growth of blockchain will continue to be spurred by increased interest from global corporations across various industries. If juggernauts like Amazon start accepting crypto, it will start a domino effect by adding trust into all things blockchain.
Smaller companies might be interested in blockchain as a secure global identification platform superior to existing flawed identity systems. Governments will use blockchain to replace outdated paper-based systems with DLT systems that offer more transparency and trust.
Smart contracts can be utilized to facilitate the creation of complex insurance policies. Once certain conditions are met, payments will be made automatically, which could transform the entire industry.
Healthcare will benefit immensely from blockchain as blockchain will enable them to work with confidential data more time efficiently, guaranteeing that any third parties won’t process it.
Other environments that can be disrupted by blockchain include:
There will always be skeptics who won’t see the full potential of blockchain and will keep predicting its future demise. However, we have already passed the point of no return regarding blockchain.
When it comes to the future of blockchain, so many talented people at Hacken and many others are working to turn blockchain into a reliable reality that can be used not just for trading but to create value in areas such as finance, investment, logistics, transportation, education, art, healthcare. Blockchain will take all those areas further regarding security, reliability, value, and support.