Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

krishnasantosh
Copy link

Homework submission

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;
Copy link
Collaborator

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

Copy link
Author

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
Copy link
Collaborator

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants