-
I've seen "bytes memory" used as argument at different places in Lesson-9. function checkUpkeep(bytes memory)
public
view
override
returns (bool upkeepNeeded, bytes memory)
{
bool isOpen = RaffleState.OPEN == s_raffleState;
bool timePassed = ((block.timestamp - s_lastTimeStamp) > i_interval);
bool hasBalance = address(this).balance > 0;
bool hasPlayers = s_players.length > 0;
upkeepNeeded = (timePassed && isOpen && hasBalance && hasPlayers);
return (upkeepNeeded, '0x0');
} Can anyone explain? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Here, the function The word "memory" likely threw you off. It is just a name. You can do Now, as to the how: The function above has the keyword |
Beta Was this translation helpful? Give feedback.
Here, the function
checkUpkeep()
is a parameterized function (a function which requires parameters). In addition,(bytes memory)
basically is a variable (any arbitrary name can be used, in this casememory
) of the data-typebytes
.The word "memory" likely threw you off. It is just a name. You can do
bytes yangyueche
as well; it is the data-type which is compulsory.Now, as to the how:
The function above has the keyword
override
; therefore, this implies that the function in the inherited contract has a parameter of thebytes
type. This is why we have thebytes
variable in the first place. Of course, in our case, we did not really use that variable, whic…