Search code examples
ethereumsoliditytruffle

Getting error while using address.transfer solidity


I am getting an error while using address.transfer function in solidity contract and transaction getting reverted

"Returned error: VM Exception while processing transaction: revert at PromiEvent"

pragma solidity >=0.4.21 <0.7.0;

contract MyContract {
function payEther(address payable _wallet, uint _amount) public {
     _wallet.transfer(_amount);
}
}

Solution

  • I have fixed this issue , contract address must be payable address, also should have enough balance. A Fallback function with external visibility makes contract address payable