Things i have learned in my journey learning Ethereum development - Notes 2
![ethereum-notes.jpg](https://steemitimages.com/DQmfM8HheKVWSuxQJ1ZXfm4evcqmG6xZpY6ptkBjWEmzHjW/ethereum-notes.jpg)
Modifiers
✍ modifiers are resuaable codeblocks that can be used to change the behaviour of a function. It ‘s a kind of decorator.
✍ Modifiers are created with the key ‘modifier’
✍ modifiers can accept params
✍ Local variables declared in modifiers are not accessable in function where the modifier is applied
✍ Modifiers must have an _ (underscore) inside of it since it is a placeholder for the function body. If it is no present the compiler will give an error
✍ You can apply multiple modifiers to a function and the order is important becuase modifiers are applied according to the order they are declared from left to right
✍ The throw keyword in modifiers ends the execution so the body function will not be executed
✍ Function body gets executed once irrespective of the number of modifiers
Events:
✍ a transaction is sent from the dapp to the ethereum network. When the transaction is mined, data from the events are written in the logs. This logs can be accessible from the Dapps
✍ Events generated by the Solidity contract are stored in all ethereum nodes
✍ Events are part of the ABI definition
✍ Events arguments are stored in the logs
✍ you declare an event with the keyword event
✍ Events generated by the Solidity contract are stored in all ethereum nodes
Contracts lyfecycle
✍ a contract once developed, gets deployed in the ethereum netwrork. Both a external owned account or another contract can send a message to it. All these transactions become part of of the shared distributed ledger once mined.
✍ contracts can be programmed to self destroy
✍ Once the contract has self destroyed, it is no more possible to call functions on that contract and therefore no more transactions can be done with that contract. The old transactions remains in the history.
✍ Once destroyed any funds in the contract are refund to an address that is specified when calluing the suicide function.
✍ funds sent to a self destructed contract will be lost. In order to prevent this you can call a get function in order to know if the contract is dead