Reputation: 315
function finalizeRequest(uint index) public restricted {
Request storage request = requests[index];
require(request.approvalCount > (approversCount / 2));
require(!request.complete);
request.recipient.transfer(request.value);
request.complete = true;
}
error line ---> request.recipient.transfer(request.value);
can someone help me with this? Thank you.
solidity version I'm using:
pragma solidity >0.4.17 <0.8.0;
Upvotes: 27
Views: 24172
Reputation: 43481
You need to mark the request.recipient
as payable
payable(request.recipient).transfer(request.value);
From the docs page Solidity v0.8.0 Breaking Changes:
The global variables
tx.origin
andmsg.sender
have the typeaddress
instead ofaddress payable
. One can convert them intoaddress payable
by using an explicit conversion, i.e.,payable(tx.origin)
orpayable(msg.sender)
.
Upvotes: 72
Reputation: 11
There is no error in code its fine but upon execution i passed address then i get Error as given below in Remix ide
:status false Transaction mined but execution failed" transact to transferEther.payBill errored: VM error: revert.
revert The transaction has been reverted to the initial state. Note: The called function should be payable if you send value and the value you send should be less than your current balance. Debug the transaction to get more information.
Upvotes: 1
Reputation: 764
If you are using a complier older than 0.6, you can declare recipient
as address payable
instead of address
.
If you are using a compiler more or equal to 0.6, you can use the solution provided by @Petr Hejda.
Upvotes: 8