I'm confusing the rule of paying gas fee when caller makes a transaction.
The gas fee is needed when the transaction is made and I know that the require() is the guard function that returns all the gas fee to the caller.
Is the gas fee paid after all operations in the function in the smart contract?
Then, if the require() function is placed at the start of the function and the codes aren't operated at all, does that mean no gas fee is needed?
And what if the value in that require() statement is false condition and the transaction therefore fails?
Is the gas fee 100% refunded to the caller or does the caller have to pay a remaining gas fee after some operations in the function worked?
Can the caller be refunded all gas?
function burn(uint256 _value) public returns (bool success) {
require(balances[msg.sender] >= _value);
balances[msg.sender] = balances[msg.sender].sub(_value);
totalSupply = totalSupply.sub(_value);
Burn(msg.sender, _value);
return true;
}
If the gas fee has to be paid after the code has been executed, what happens if caller(msg.sender) can not pay the gas fee because caller's account has no balance after the require () conditional pass?
I doubt that I know right.