'Truffle compile
I get this Truffle error when I compile. I have tried adding payable to the addresses but it won't work. This is the error:
TypeError: Member "transfer" not found or not visible after argument-dependent lookup in address. buyer.transfer(Orders[order_no].price*8/10); ^------------^
pragma solidity >0.4.99 <0.6.0;
contract ManageOrder{
address public owner;
uint256 count;
uint256 count_parking;
string order_list;
uint256 order_number;
string public result;
//order table
struct Order {
uint256 orderNo;
address buyer;
address seller;
uint256 parkingNo;
State state;
string new_hour;
uint256 price;
uint date;
}
//parking table
struct Parking {
uint256 parkingNo;
address seller;
string name;
string phone;
string post_code;
string avail_hour;
string park_address;
}
//buyer table
struct Buyer {
string name;
string phone;
}
//map the struct to an index
mapping(uint => Order) private Orders;
mapping(uint => Parking) private Parkings;
mapping(address => uint256) balances;
mapping(address => Buyer) public Buyers;
//for sellers and buyers to abort the order
//order state should be pending
function abortOrder(uint256 order_no) public
inState(State.Pending,order_no)
{
//get the address of both the buyer and the seller
address buyer = Orders[order_no].buyer;
address seller = Orders[order_no].seller;
//if the message sender id the buyer
if(msg.sender==Orders[order_no].buyer)
{
Orders[order_no].state = State.Aborted;
//return 80% of the money to buyer
buyer.transfer(Orders[order_no].price*8/10);
//20% of the money to the seller
seller.transfer(Orders[order_no].price*2/10);
}
else if(msg.sender==Orders[order_no].seller)
{
//if the sender is the seller, he needs to pay 20% of the parking fee to the buyer
Orders[order_no].state = State.Aborted;
//return the money to buyer
buyer.transfer(Orders[order_no].price*12/10);
balances[seller]-=Orders[order_no].price*2/10;
}
}
Solution 1:[1]
Check the breaking changes in Solidiy 0.5.x.
The address
type was split into address
and address payable
, where only address payable
provides the transfer
function
https://solidity.readthedocs.io/en/v0.5.3/050-breaking-changes.html?highlight=address%20payable
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Matt |