Menu
Coddy logo textTech

Function Parameters

Part of the Fundamentals section of Coddy's Solidity journey. Lesson 21 of 53.

A function groups a reusable operation under a name. Its parameters are named inputs with declared types. The caller supplies arguments in the same order. In this example a small internal helper adds two supplied quantities, and main prints the result.

Define this helper inside the contract:

function combine(uint256 left, uint256 right) internal pure returns (uint256) {
    return left + right;
}

Use it inside the provided main function:

console.log(combine(7, 9));

Calling combine copies 7 into left and 9 into right. returns (uint256) describes the result type and return sends the computed value back. The internal helper is callable from this contract; it is not an external entry point.

Argument order determines which value each function parameter receives.

challenge icon

Challenge

Easy

Create an internal pure function named difference that receives two uint256 values and returns the first minus the second. In main, print difference(high, low). high is at least low.

The tests pass arguments to main in this order: uint256 high, uint256 low. Each test starts with fresh contract state.

Use console.log for the requested output. Print only the requested values, one per line, with no extra labels unless the task specifies them.

Try it yourself

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
import "forge-std/console.sol";
contract Main {
    function main(uint256 high, uint256 low) external view {
        // Write your solution here.
    }
}
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals

Practice on your own: Solidity playground