Explain solidity>functions

Functions

Functions are blocks of code that run when called. They define what your contract can do.

Basic Function Syntax:

function functionName() public { }

function - Keyword that starts the definition

functionName - The name of your function

() - Parameters go here (empty for now)

public - Visibility (anyone can call it)

{ } - Function body (code goes here)



Let's create a simple function to start a new game.

Write:function startGame() public { }

Create startGame function
0%
Requirements:
Declares function startGame
Function is marked as public
Has opening and closing braces