I want to understand when (and why) it's necessary to use this statement : require(sent, "failed to send ether")
i could just do somethink like this instead:
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.
Sign up to join this communityYou could, but it would not be safe because call()
won't revert if the external contract execution does. It's highly discouraged and generally unsafe.
With call() if the function reverts your function calling it will not revert unless you have the require(success) line. I've encountered situations where you do not want to revert if the contract you are calling reverts, but most of the time you will want to revert.