All about Functions

We’ve already covered the basics of defining functions in Solidity, but in this lesson, we'll spend a bit more time learning the nuances of how we can use and define functions. While functions in Solidity work similarly to other programming languages, there are a few differences, and we'll cover them in this lesson.

Constructors

Similar to object-oriented programming languages, Solidity allows defining a constructor to initialize a smart contract before users can interact with it. Just like a regular function, a constructor accepts a list of parameters, and a user that deploys a smart contract must provide values for all of them.

To define a constructor, we need to use the constructor keyword and specify the list of parameters required for a contract’s initialization.

Get hands-on with 1400+ tech skills courses.