【问题标题】:Truffle compile松露编译
【发布时间】:2019-01-31 08:28:44
【问题描述】:

我在编译时收到此错误松露。我已尝试将应付帐款添加到地址,但不起作用。这是错误:

TypeError:在地址中进行参数相关查找后,未找到成员“转移”或不可见。买家.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;
    }
}

【问题讨论】:

标签: smartcontracts truffle


【解决方案1】:

检查 Solidiy 0.5.x 中的重大更改。

address 类型分为addressaddress payable,其中只有address payable 提供transfer 函数

https://solidity.readthedocs.io/en/v0.5.3/050-breaking-changes.html?highlight=address%20payable

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-02-07
    • 2019-07-15
    • 1970-01-01
    • 1970-01-01
    • 2020-04-19
    • 1970-01-01
    • 1970-01-01
    • 2018-11-15
    相关资源
    最近更新 更多