Last week we had our monthly blockchain developers meetup.
This time we were focusing more on the best approaches, tips and tricks for gas optimisation and best practices and architectures when developing decentralized applications.
Our focus was mostly on Ethereum’s Solidity and EVM since most people of our community are familiar with it.
As usual we started with covering the news from the development space. We share them all over our channels and groups, but for those who do not follow regularly – this is what was new during the last month:
- Truffle released new version v5.0.13 – decoder improvements
- Ganache with new release v2.0.1
- Embark – new beta 4.1.0-beta.0
- Truffle Teams, zero-configuration continuous integration for Eth code
- ZoKrates v0.4.4 – building identity-based snarks. adds BabyJubJub
- ZEXE on Plasma from Edcon hackathon
- Waellet – aeternity browser extension released first initial beta
- Easily embed a Status chat room in your website
Tricks and tips
We talked a lot about gas optimization via variables packing, deployment gas optimization, and other interesting tricks. Here’s some of the tricks and tips we covered:
Any non-trivial contract will have errors in it. Your code must, therefore, be able to respond to bugs and vulnerabilities gracefully.
Prepare for failure
– Write clean, consistent good code (If you repeat certain operations often, make them a function)Lowering deployment cost
– Move logic to Libraries if appropriate (They are published separately)
– Use modifiers for common checks
– Do as little as possible in the constructor
When you add a function modifier, the code of that function is picked up and put in the function modifier in place of the _ symbol. This can also be understood as “The function modifiers are inlined”. In normal programming languages, inlining small code is more efficient without any real drawback but Solidity is no ordinary language. In Solidity, the maximum size of a contract is restricted to 24 KBModifiers can be inefficient
The recording will be available soon.
Also published on Medium.