1

The code is taken from this smart contract

        /// @notice Only the central admin should be able to store his life memory in bytes32.
function store_me_on_chain(bytes32 _data) public returns (string memory) {
    require(msg.sender == admin, 'Not admin');
    data_store = _data;
    data_set = asmbl();
    ds_to_Str = Strings.toString(data_set);
    return data = string("den_who_is_dan_");
}

/// @notice Generate number
function asmbl() public view returns (uint8 b) {
    assembly {
        let c := add(27, 16)
        mstore(0x80, c)
        { let d := add(sload(c), 255) b := d }
        b := add(b, c) }
    }

asmbl is declared without a return. But asmbl() is to data_set. What is the value of data_set?

1 Answer 1

2

data_set = b

when you define a variable in returns scope like - function asmbl() public view returns (uint8 b), it returns variable b. So you don't need to explicitly write return just set some value to b, and this value will be returned.

when you define function like function store_me_on_chain(bytes32 _data) public returns (string memory) without initializing any variable in returns scope it means that you have to explicitly write return .

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.