pragma solidity 0.5.9;
contract Testing{
function participate()public payable{
uint winner = 9;
require(msg.value == 0.1 ether);
if ( winner==9)
{
require(msg.sender.call.value(this.balance)());
}
}
}
I am getting the following error message:
solc testing8_2.sol testing8_2.sol:13:42: Error: Member "balance" not found or not visible after argument-dependent lookup in contract Testing. Use "address(this).balance" to access this address member. require(msg.sender.call.value(this.balance)());
But if I try:
if ( winner==9)
{
require(msg.sender.call.value(address(this).balance)());
}
I get the following error message:
solc testing8_2.sol testing8_2.sol:13:20: Error: Wrong argument count for function call: 0 arguments given but expected 1. This function requires a single bytes argument. Use "" as argument to provide empty calldata. require(msg.sender.call.value(address(this).balance)()); ^--------------------------------------------^ testing8_2.sol:13:12: Error: No matching declaration found after argument-dependent lookup. require(msg.sender.call.value(address(this).balance)()); ^-----^
Somebody please guide me how to solve this problem:
Zulfi.
bytes private constant payload = abi.encode(bytes4(keccak256("deposit()")));. – goodvibration Apr 18 '20 at 06:22bankAddress.deposit.valueis a supported way of writing it. The comment from @goodvibration simply states the correct fact you could save some gas by doing the computation outside the function as a one-time constant variable. That is because it never changes, actually even ifdepositwould have input arguments, you could still do it outside. If would then simply bekeccak256("deposit(address,uint256)").It would be nice to have Solidity features on top to make this more readable.
– Markus - soliditydeveloper.com Apr 19 '20 at 06:26abi.encodeWithSelector(this.deposit.selector), but I haven't tested it. – Markus - soliditydeveloper.com Apr 20 '20 at 03:31