Solidity Functions: Declaration

Learn about declaring functions in Solidity.

A function is a block of code that takes an optional input (called its arguments), performs some operations with it, and returns an optional output.

The execution of Solidity code must be initiated by an EOA calling a function in a contract. These interactions are known as external function calls, and they create an actual EVM message call. Functions can, in turn, call other functions, which is known as an internal function call, but the initial function call has to originate from an EOA.

A function is declared with the function keyword and has the following format:

Get hands-on with 1200+ tech skills courses.