// SPDX-License-Identifier: MIT
// Import the Solidity compiler library version 0.8.9 or later
pragma solidity ^0.8.9;
/**
* @title ReturnValues
* @dev Demonstrates returning values from functions in Solidity.
* This contract stores the block number at the time of a transaction
* and provides functions to set and retrieve it.
*/
contract ReturnValues {
// State variable to store the block number
uint counter;
/**
* @dev Sets the current block number to the `counter` state variable.
* This function updates the `counter` with the current block number
* when it is called.
*/
function setNumber() public {
counter = block.number;
}
/**
* @dev Returns the stored block number.
* This function returns the value of the `counter` state variable,
* demonstrating a simple way to return a value from a function.
* @return The stored block number.
*/
function getBlockNumber() public view returns (uint) {
return counter;
}
/**
* @dev Another way to return the stored block number.
* This function demonstrates an alternative syntax for returning
* values from a function, using named return variables.
* @return result The stored block number.
*/
function getBlockNumber1() public view returns (uint result) {
result = counter;
}
}
//Deploy: