Sending Ether Cheat Sheet
TLDR
Address.sendValue(addr, amount)
(bool success, ) = addr.call{value: amount}("")
Address.sendValue(addr, amount)
(bool success, ) = addr.call{value: amount}("")
Using newer compiler versions and the optimizer gives gas optimizations and additional safety checks for free!
The advantages of versions 0.8.*
over <0.8.0
are:
0.8.0
(can be more gas efficient than some
library based safemath).0.8.2
, leads to cheaper runtime gas.
Especially relevant when the contract has small functions. For# quine.etk | |
# ⬜ => ⬜ | |
# A quine is a computer program which takes no input and produces a copy of its own source code as its only output. | |
# 0x80...f3 is the compiled code excluding the push16 instruction (from dup1 to return) | |
push16 0x8060801b17606f5953600152602136f3 | |
# --- stack --- | |
dup1 # code code | |
push1 128 # 128 code code |