Whenever someone buys a smart-contract the amount (in Wei) get stored in SC(Smart Contract) address(this) += msg.value.
Now I am trying to create a function to redeem the balance of the SC
function redeemInvTokens(uint256 _amount) public returns(bool){
require(_amount <= amount, "you cannot redeem the more tokens");
balanceOf[msg.sender] -= _amount;
msg.sender.call.value(address(this).balance - (address(this).balance - _amount))("Transferred ether to financier");
return true;
}
but its not transferring any amount to the msg.sender.
How to transfer the specific amount to the msg.sender? so I don't have to use address(this).balance - (address(this).balanace - _amount).
address(this).balance - (address(this).balanace - _amount)"??? This expression is equivalent to_amount, what brought you to the conclusion that you need to use it in order to transfer the specific amount to the sender? You can simply domsg.sender.transfer(_amount). – goodvibration Jan 21 '20 at 08:28amountinrequire(_amount <= amount, ...)? You should post a working example. This symbol (amount) is not defined anywhere in your code. – goodvibration Jan 21 '20 at 08:30msg.sender.call.value(_amount)()it is not transfering any amount tomsg.senderso i usedmsg.sender.call.value(address(this).balance)(). but, again i want to send specific amount tomsg.senderthats why that calculation to determine. – iamsujit Jan 21 '20 at 08:48x - (x - y) == y!!! – goodvibration Jan 21 '20 at 08:50msg.sender.transfer(_amount)? – goodvibration Jan 21 '20 at 08:51