Solidity

Solidity:“發送”和“轉移”僅適用於“應付地址”類型的對象,而不適用於“地址”

  • June 6, 2019

我正在嘗試使用solidity 0.5.0 版本編譯我的智能合約。使用以下程式碼:

function unbond(address wallet, bytes32 specifier, uint quantity) internal {

   bondage = BondageInterface(coord.getContract("BONDAGE")); 
   uint issued = bondage.getDotsIssued(address(this), specifier);

   currentCost = CurrentCostInterface(coord.getContract("CURRENT_COST")); 
   uint reserveCost = currentCost._costOfNDots(address(this), specifier, issued + 1 - quantity, quantity - 1);
   FactoryTokenInterface tok = FactoryTokenInterface(curves[specifier]);

   //unbond dots
   bondage.unbond(address(this), specifier, quantity);
   //burn dot backed token
   tok.burnFrom(wallet, quantity);
   //send wallet eth
   wallet.transfer(reserveCost * adapterRate);
} 

傳遞函式是這樣的:function transfer(address _to, uint256 _value) public returns (bool);

我得到的錯誤是這個

TypeError:“發送”和“轉移”僅適用於“應付地址”類型的對象,而不適用於“地址”。wallet.transfer(reserveCost * adapterRate);

您需要將函式定義為:

function unbond(address payable wallet, bytes32 specifier, uint quantity) internal

你可以試試這個,函式 transfer(address _to, uint256 _value) public應付回報(bool);

請讓我知道它是否有效。

引用自:https://ethereum.stackexchange.com/questions/71504