Question 1) Let's imagine I have this code
require(userVotes[msg.sender] == 0);
presidents[_id-1].voteCount++;
userVotes[msg.sender] = _id;
so If I make a call to this function, and it doesn't pass the require, what really happens is in metamask it says : contract threw exception. then It still lets me to click on submit button. I'm curious is it still gonna take gas from my account?
Question 2) If the answer from the previous question is yes, then how much? the gas that it took require(userVotes[msg.sender] == 0);
doing this command? I am still curious even though there was an exception in require , it still got included in a block and status was fail. What exactly got in block? nothing has changed.
Question 3) I tried to write something like require(userVotes[msg.sender] == 0,"error go away");
I want to catch this in front-end. What i did is after sending the transaction, I used event
.on('error', function(error){
console.log(error);
}
but it was not those words That I wrote in a solidity like a "error go away".
Thank you so much