Hi folks! I have this code and while calling addNewUser, it fails every time. The task is to add a user to an array. Any ideas?

contract A {

address[] public users;
bool lock;

function addNewUser(address user) public{
lock = false;

msg.sender.call("");

require(lock);
users.push(user);
}
}

Oct 12, 2022, 8:40 AM
it looks like a reen-cy attack
Oct 12, 2022, 8:41 AM
where is winner defined?
Oct 12, 2022, 9:21 AM
it should be user
Oct 12, 2022, 9:22 AM
please just send a screenshot
never paste code here, it is hard to read
also if you have a failed tx just share it
Oct 12, 2022, 9:23 AM
See the require(lock) , you just set that to false, ofc it fails
Oct 12, 2022, 10:26 AM
this code is already deployed and the task is to add a new user into an array
Oct 12, 2022, 10:54 AM
Send the address of the contract
Oct 12, 2022, 11:37 AM

© 2024 Draquery.com All rights reserved.