Odak modu

Smart Contract Development with Solidity

View and Pure Functions

Code from video: https://solidity-by-example.org/view-and-pure-functions/ 

View: Indicates that the function will read data from the blockchain but not modify it. 

View functions ensure that state variables are not changed. If the following statements are present in the function, it is considered to be changing state, and the compiler issues a warning.

  • Changing state variables
  • Emitting events
  • Creating other contracts
  • Using selfdestruct
  • Sending Ether via calls
  • Calling any function which is not marked view or pure
  • Using low-level calls
  • Using inline assembly containing certain opcodes

Pure: It states that the function will neither read nor modify data from the blockchain.

Pure functions ensure that data is not read and not modified. If the following statements are present in the function, it is considered to be changing state, and the compiler issues a warning.

  • Reading state variables
  • Accessing address(this).balance or <address>.balance
  • Accessing any of the special variable of block, tx, msg
  • Calling a function which is not pure
  • Etc are present in pure functions

Resources: 

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

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

https://www.tutorialspoint.com/solidity/solidity_view_functions.htm 

https://www.geeksforgeeks.org/solidity-view-and-pure-functions/

https://github.com/itublockchain/web3-bootcamp/tree/master/1x1_Functions

Background Pattern
Birlikte öğrenelim

Sektörde en çok aranan yazılım becerilerini kazan

Yapay zeka desteği, birebir mentörlük saatleri, canlı dersler ve senin için özel hazırlanmış içeriklerle eksiklerini tamamla, düzenli geri bildirimler al ve öğrenme sürecini en verimli hale getir.

Yunus Emre Kabakcı

Patika+ mezunu

Patika+ Fullstack Web Development Bootcamp mezunumuz Yunus Emre,

3 ay içinde Katar’dan aldığı teklif ile, global bir şirket olan Pavo Group’da işe başladı!


“İçerik zenginliği, mentor desteği, ileriye dönük bir network sağlaması ve dünyada en çok tercih edilen frameworkler üzerinden bir eğitim veriyor olması Patika+’ı tercih etmemin temel sebepleri oldu!“

Test

Yorumlar

Yorum yapabilmek için derse kayıt olmalısın!