Menu
Coddy logo textTech

Unsigned Integers

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

A variable gives a name to a value. uint256 stores whole numbers from zero upward within a fixed 256-bit range. Declare the type, then the name, then assign a value with =. You can replace a variable value later using another assignment.

The statements in this excerpt run inside the provided main function.

uint256 tickets = 12;
tickets = 17;
console.log(tickets);

The second assignment replaces 12 with 17. uint is an alias for uint256. Neither type represents a fraction or a negative number. The task supplies a value; storing it in another named variable lets you practice assignment without fixing the answer in the code.

Assigning a new value replaces the old value of a variable.

challenge icon

Challenge

Easy

Copy the supplied stock into a local available variable and print available.

The tests pass arguments to main in this order: uint256 stock. 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 stock) 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