/* SSTORE opcode which writes a data word to storage costs 20000 gas + some amount depending on the type. SLOAD opcode which reads a data word from storage costs 200 gas + some amount depending on the type. Intuition would tell us gas optimizations can be acheived by using smaller data types. However this is only the case inside of structs. Large typse should always be used unless struct packing is possible. */ uint256 public integer256; function write() public { integer256 = 1; // 20430 gas } function read() public returns (uint256) { return integer256; // 656 gas } uint128 public integer128; function write() public { integer128 = 1; // 20648 gas } function read() public returns (uint128) { return integer128; // 671 gas }
0.4.24