Focus mode

Smart Contract Development with Solidity

Modifiers

Code from video: https://solidity-by-example.org/function-modifier/ 

You can access the video content in Turkish prepared by İTÜ Blockchain here: https://www.youtube.com/watch?v=58MDeT4hoig&list=PLby2HXktGwN4Cof_6a8YwlMrboX8-hs73&index=9&t=2s 

Modifiers can be used to change the behaviour of functions in a declarative way. For example, you can use a modifier to automatically check a condition prior to executing the function. Modifiers are code that can be run before and / or after a function call.

Modifiers can be used to:

  • Restrict access
  • Validate inputs
  • Guard against reentrancy hack

When reading the code of a smart contract, you will see multiple types of modifiers. These modifiers help control the visibility and usability of the connected function or variable:

  • External - Functions that will be called by outside contracts. These functions can not be called internally.
  • Internal - Functions that are only accessed only within the contract in which it is declared or any connected contracts.
  • Public - Functions and variables that can be called both internally and externally by outside contracts.
  • Private - Functions and variables that can only be called in the contract in which it is declared. These functions cannot be called by connected contracts either.

Resources:

You can find detailed further information from Solidity Official documentation (in English):

https://docs.soliditylang.org/en/v0.8.15/contracts.html#function-modifiers


left-disk

Programs to Accelerate Your Progress in a Software Career

Join our 4-8 month intensive Patika+ bootcamps, start with the fundamentals and gain comprehensive knowledge to kickstart your software career!

right-cube

Test

Comments

You need to enroll in the course to be able to comment!