编译时出现此错误松露。我曾尝试将应付账款添加到地址中,但无法正常工作。这是错误:
TypeError:在地址中依赖于参数进行查找之后,找不到或不可见成员“传输”。 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;
}
}
答案 0 :(得分:0)
检查Solidiy 0.5.x中的重大更改。
address
类型分为address
和address payable
,其中只有address payable
提供了transfer
功能
https://solidity.readthedocs.io/en/v0.5.3/050-breaking-changes.html?highlight=address%20payable