In solidity, you can call the type function to get information about a type.

But what is the return type of the type function?

// SPDX-License-Identifier: MIT
pragma solidity 0.8.7;

contract TypeTest {
    function whatType() public returns(?????){
        return type(uint16);

1 Answer 1


From documentation, in this specific case for integers you can use only this two method:

  • min(): represent the smallest value about data type you passed;
  • max(): represent the largest value about data type you passed.

In your smart contract, you need to change this line type(uint16) adding one of these functions: min or max and at this point you can return the same datatype (in this case uint16). This because max and min function refers only to integer that you would to know the minimum and maximum values.


// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

contract TypeTest {

    function checkMinValue() external view returns(uint16){
        return type(uint16).min;

    function checkMaxValue() public view returns(uint16){
        return type(uint16).max;
  • So basically, type(uint16) doesn't have a return type? Jan 22, 2023 at 17:50
  • 1
    It doesn't a valid instruction. You have to call a function from this statement: 'type(uint16)'. Over min and max functions for integer type, you can use for contract type these functions: name, creationCode and runtimeCode while for interfaces is only available this function: interfaceId. Jan 24, 2023 at 12:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.