Posts

Showing posts from December, 2018

useful videos

Building And Deploying Ethereum Smart Contracts With Solidity and JavaScript https://www.youtube.com/watch?v=0phCtYMx2Ac Hyperledger Fabric Build Your First Network Walkthrough https://www.youtube.com/watch?v=rtuwuo1dcTY What is Corda blockchain? Simply explained https://www.youtube.com/watch?v=rFZhbvtT284 Build a Fully Decentralized Application with IPFS - Ethereum Dapp Programming Tutorial https://www.youtube.com/watch?v=ADoRVVOSpI8&list=PLS5SEs8ZftgWggD3tKfgwsIPXuIhorXZk

Useful links

Deploy your own smart contract with Truffle and Ganache CLI https://medium.com/haloblock/deploy-your-own-smart-contract-with-truffle-and-ganache-cli-beginner-tutorial-c46bce0bd01e Developing Ethereum Smart Contracts for Beginners https://coursetro.com/courses/20/Developing-Ethereum-Smart-Contracts-for-Beginners Demo of Multi-Channel Network in Hyperledger Fabric https://medium.com/@kctheservant/demo-of-multi-channel-network-in-hyperledger-fabric-640f7158e2d3 chmod 777 /var/run/docker.sock How Operating Systems Work: 10 Concepts you Should Know as a Developer https://medium.com/cracking-the-data-science-interview/how-operating-systems-work-10-concepts-you-should-know-as-a-developer-8d63bb38331f

Storage is Expensive

One of the more expensive operations in Solidity is using storage — particularly writes. This is because every time you write or change a piece of data, it’s written permanently to the blockchain. Forever! Thousands of nodes across the world need to store that data on their hard drives, and this amount of data keeps growing over time as the blockchain grows. So there's a cost to doing that. In order to keep costs down, you want to avoid writing data to storage except when absolutely necessary. Sometimes this involves seemingly inefficient programming logic — like rebuilding an array in memory every time a function is called instead of simply saving that array in a variable for quick lookups. In most programming languages, looping over large data sets is expensive. But in Solidity, this is way cheaper than using storage if it's in an external view function, since view functions don't cost your users any gas. (And gas costs your users real money!).

Struct packing to save gas

There are different types of uints: uint8, uint16, uint32, etc. Normally there's no benefit to using these sub-types because Solidity reserves 256 bits of storage regardless of the uint size. For example, using uint8 instead of uint (uint256) won't save you any gas. But there's an exception to this: inside structs. If you have multiple uints inside a struct, using a smaller-sized uint when possible will allow Solidity to pack these variables together to take up less storage. For example: struct NormalStruct {   uint a;   uint b;   uint c; } struct MiniMe {   uint32 a;   uint32 b;   uint c; } // `mini` will cost less gas than `normal` because of struct packing NormalStruct normal = NormalStruct(10, 20, 30); MiniMe mini = MiniMe(10, 20, 30); For this reason, inside a struct you'll want to use the smallest integer sub-types you can get away with. You'll also want to cluster identical data types together (i.e. put them next to each ot...