But i think this code never works because i tried it and it shows warning and when deployed with warning and attacked it returns error (failed to send ethers)
Why in this format of payable the reentrancy fails yet the balance is updated lastly function withdraw() public { uint bal = balances[msg.sender]; require(bal > 0);
The transaction has been reverted to the initial state. Reason provided by the contract: "Failed to send Ether". Debug the transaction to get more information. getting this error while I am hitting attack button
thanks. Explained very well. But one bad thing, which you all "teachers" don't consider is that, you are teaching curious good people, but also you are teaching bad people how to preform an attack, you all provide them, a step by step instrucions. I would prefer to live in the world where noone explains how bad things were made, but only provide solutions how to prevent it.
A programmer needs to understand fully the vulnerability in order to develop a proper solution. Making the vulnerability more known also raises awareness in the community.
Beautiful explanation.
best re-entrancy attack explanation!
But i think this code never works because i tried it and it shows warning and when deployed with warning and attacked it returns error (failed to send ethers)
I was getting an error, and in my case it was because I wasn't sending in 1 eth as mentioned @ 6:27
Why in this format of payable the reentrancy fails yet the balance is updated lastly
function withdraw() public {
uint bal = balances[msg.sender];
require(bal > 0);
require(payable(msg.sender).send(bal), "failed");
balances[msg.sender] = 0;
}
So deposit funds is contract from victim?
Explained well 👍🏻
ma'am from where you learn about crypto
The transaction has been reverted to the initial state.
Reason provided by the contract: "Failed to send Ether".
Debug the transaction to get more information.
getting this error while I am hitting attack button
Hello ma'am can you help me in understanding smart contract vulnerabilities.
thanks. Explained very well.
But one bad thing, which you all "teachers" don't consider is that, you are teaching curious good people, but also you are teaching bad people how to preform an attack, you all provide them, a step by step instrucions. I would prefer to live in the world where noone explains how bad things were made, but only provide solutions how to prevent it.
A programmer needs to understand fully the vulnerability in order to develop a proper solution. Making the vulnerability more known also raises awareness in the community.
you can't prevent it if you don't know how it's done 😂