Solidity Functions: Special Functions

Learn about special functions in Solidity.

Special function types

Solidity allows for the optional definition of special functions, including the following:

  • Payable functions

  • View and pure functions

  • Constructors

Payable functions

Declaring a function of the payable type, specified with the payable keyword, makes it able to receive ETH as part of the transaction calling it. This is similar to the address payable type for variables.

For instance, we have the following payment contract, which can be used to receive fees for a service.

Get hands-on with 1200+ tech skills courses.