Would the nonReentrant modifier from the OpenZeppelin ReentrancyGuard library prevent the user from calling stake() when the unstake() function hasn't yet been fully processed (in the example below)?

function stake () nonReentrant {

function unstake () nonReentrant {

Does it manage the _lock state separately for each assignment to the function, or it has the same _lock for all calls?

P.S. Apologies if my question is a bit unclear, I tried my best to explain what I'd like to ask you.

1 Answer 1


It locks all functions in the same contract. In your example, both stake and unstake functions will be under the same lock

  • Thank you so much for your reply!
    – Mila A
    Sep 9, 2023 at 16:15

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.