我刚开始踏实
我的目标是使这些代码在remix编译器中工作。
该代码是一个" for“函数,它意味着在死者= true (代码用于继承契约)时触发,但它在最后两行代码的”钱包“部分有问题。
我试着在这里和其他地方寻找解决方案(比如Solidity/Remix文档),但仍然在努力解决这个特殊的问题。
我尝试删除"i",添加";“,并在钱包的开头添加下划线(如"_wallets")。
有人告诉我,我已经申报了钱包,但我不知道你是怎么做到的。
这是完整的继承契约代码:
// SPDX-License-Identifier: GPL-3.0
//import solidity
pragma solidity ^0.8.0;
contract Inheritance {
address owner;
bool deceased;
uint money;
constructor () public payable {
owner = msg.sender;
money = msg.value;
deceased = false;
}
modifier oneOwner {
require (msg.sender == owner);
_;
}
modifier isDeceased {
require (deceased == true);
_;
address [0xa1F9019E4F941071cAabCbb3fBc6314c06BeD18f] wallets;
mapping (address => uint) inheritance;
}
function setup(address _wallet, uint _inheritance) public oneOwner {
_wallet.push(_wallet);
Inheritance [_wallet] = _inheritance;
}
function moneyPaid() private isDeceased {
for (uint i=0; i< wallets.length; i++) {
wallets[i].transfer(Inheritance[wallets][i]);
}
}
function died() public oneOwner {
deceased = true;
moneyPaid();
}
}以下是我所犯的错误:
DeclarationError: Undeclared identifier.
--> Inheritance contract 1.1.sol:38:20:
|
38 | for (uint i=0; i< wallets.length; i++) {
| ^^^^^^^
DeclarationError: Undeclared identifier.
--> Inheritance contract 1.1.sol:39:3:
|
39 | wallets;[i].transfer(Inheritance[wallets][i]);
| ^^^^^^^
DeclarationError: Undeclared identifier.
--> Inheritance contract 1.1.sol:39:36:
|
39 | wallets;[i].transfer(Inheritance[wallets][i]);
| ^^^^^^^发布于 2022-08-17 05:51:54
您的存储变量钱包在修饰符中。必须在修饰符之外声明状态变量。
modifier isDeceased {
require (deceased == true);
_;
}
address [0xa1F9019E4F941071cAabCbb3fBc6314c06BeD18f] wallets;
mapping (address => uint) inheritance;
// } --> not herehttps://stackoverflow.com/questions/73382158
复制相似问题