Skip to main content
deleted 20 characters in body
Source Link
goodvibration
  • 26.2k
  • 5
  • 49
  • 89

If you want to transfer the entire balance of the contract to the owner of the contract, then you should replace msg.value with address(this).balance.

If the balance of the contract prior to calling function send is 0, then it will indeed transfer the entire balance of the contract to the owner of the contract.

Otherwise, you are transferring to the owner of the contract the exact amount of ether that the caller of function send has just transferred to the contract using this function.

If you want to transfer the entire balance of the contract to the owner of the contract, then you should replace msg.value with address(this).balance.

If the balance of the contract prior to calling function send is 0, then it will indeed transfer the entire balance of the contract to the owner of the contract.

Otherwise, you are transferring to the owner of the contract the exact amount of ether that the caller of function send has just transferred to the contract using this function.

If you want to transfer the entire balance of the contract to the owner of the contract, then you should replace msg.value with address(this).balance.

If the balance of the contract prior to calling function send is 0, then it will indeed transfer the entire balance of the contract to the owner of the contract.

Otherwise, you are transferring to the owner of the contract the exact amount of ether that the caller of function send has just transferred to the contract.

Source Link
goodvibration
  • 26.2k
  • 5
  • 49
  • 89

If you want to transfer the entire balance of the contract to the owner of the contract, then you should replace msg.value with address(this).balance.

If the balance of the contract prior to calling function send is 0, then it will indeed transfer the entire balance of the contract to the owner of the contract.

Otherwise, you are transferring to the owner of the contract the exact amount of ether that the caller of function send has just transferred to the contract using this function.