Addresses
錯誤:在依賴於參數的查找後未找到成員“發送”或不可見
我正在嘗試編譯以下智能合約:
pragma solidity ^0.5.1; contract Governmental{ uint constant TWELVE_HOURS = 12; function lendGovernmentMoney ( address buddy ) public returns ( bool ) { address owner; uint[] memory creditorAddresses; uint lastTimeOfNewCredit =0; uint amount = msg. value ; uint creditorAmounts = 0; uint profitFromCrash = 0; uint round = 0; uint lastCreditorPayedOut = 0; // check the condition to end the game if ( lastTimeOfNewCredit + TWELVE_HOURS > block . timestamp ) { msg.sender.send ( amount ); // Sends jacpot to the last creditor creditorAddresses[creditorAddresses.length - 1].send ( profitFromCrash ); owner.send (this.balance); // Reset contract state lastCreditorPayedOut = 0; lastTimeOfNewCredit = block . timestamp ; profitFromCrash = 0; creditorAddresses = new address [](0); creditorAmounts = new uint [](0); round += 1; return false ; } } }
我收到錯誤消息:
prg17.sol:20:10:錯誤:在 uint256 中進行與參數相關的查找後,未找到成員“發送”或不可見。債權人地址
$$ creditorAddresses.length - 1 $$.send ( ProfitFromCrash ); ^————————————————- -^
有人請指導我。
祖爾菲。
creditorAddresses
被聲明為一個 uint 數組。uint[] memory creditorAddresses;
可能您打算將其聲明為地址數組
address payable[] memory creditorAddresses;
當數組為空時,此程式碼
creditorAddresses[creditorAddresses.length - 1]
也不起作用。如果記憶體數組沒有像程式碼片段那樣初始化,就是這種情況。