-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Krishna s #25
base: master
Are you sure you want to change the base?
Krishna s #25
Conversation
function withdraw(uint _amount) external nonReentrant { | ||
require(balances[msg.sender] >= _amount, "Insufficient balance"); | ||
// first substract and then transfer to avoid reentry or other issues | ||
balances[msg.sender] -= _amount; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you are subtracting the amount before calling transfer, this reentrancy check might not be required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know :-) but wanted to be careful anyways.
function mint(uint _amount) payable external nonReentrant { | ||
require(_amount == msg.value, "Amount of VAULT requested != Ether passed"); | ||
|
||
// Question says "user" but not does not explicitly say if a contract |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both EOA and contracts should be able to call this function (they both can be users). Just calling _mint
meets this purpose
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool.
Homework submission