I have a function in my smart contract as follows:
function transferToaddress(address payable addressToSend) public payable{
addressToSend.transfer(0.5 ether);
}
From my front-end, I'm calling the above function as follows:
var response = await this.contract.transferToaddress(vm.userAccountAddress,{
from: vm.userAccountAddress,
gas: vm.gas
})
The transaction fails. My contract has some balance. On a click of a button I want some ether (0.5 in this case) to get transferred from my smart contract to the address passed to the function. Any idea what am I doing wrong?