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

left-disk

Yazılım Kariyerinde İlerlemeni Hızlandıracak Programlar

Patika+ programlarımız ile 4-8 aylık yoğun yazılım kamplarına katıl, temel bilgilerden başlayarak kapsamlı bilgiler edin, yazılım kariyerine başla!

right-cube

Yorumlar

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