Odak modu

Smart Contract Development with Solidity

Errors

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

You can access the video content in Turkish prepared by İTÜ Blockchain here: https://www.youtube.com/playlist?list=PLby2HXktGwN4Cof_6a8YwlMrboX8-hs73 

Errors in Solidity provide a convenient and gas-efficient way to explain to the user why an operation failed. They can be defined inside and outside of contracts (including interfaces and libraries). An error will undo all changes made to the state during a transaction.

You can throw an error by calling require, revert or assert.

  • require is used to validate inputs and conditions before execution.
  • revert is similar to require.
  • assert is used to check for code that should never be false. Failing assertion probably means that there is a bug.

Using the above three error types help us save gas.

Resources:

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

https://docs.soliditylang.org/en/v0.8.15/structure-of-a-contract.html#errors 

https://docs.soliditylang.org/en/v0.8.15/contracts.html#errors-and-the-revert-statement

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!“

Yorumlar

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