首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >与金钱支付功能有关的稳健性申报错误

与金钱支付功能有关的稳健性申报错误
EN

Stack Overflow用户
提问于 2022-08-17 02:10:31
回答 1查看 14关注 0票数 0

我刚开始踏实

我的目标是使这些代码在remix编译器中工作。

该代码是一个" for“函数,它意味着在死者= true (代码用于继承契约)时触发,但它在最后两行代码的”钱包“部分有问题。

我试着在这里和其他地方寻找解决方案(比如Solidity/Remix文档),但仍然在努力解决这个特殊的问题。

我尝试删除"i",添加";“,并在钱包的开头添加下划线(如"_wallets")。

有人告诉我,我已经申报了钱包,但我不知道你是怎么做到的。

这是完整的继承契约代码:

代码语言:javascript
复制
// 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();
}
}

以下是我所犯的错误:

代码语言:javascript
复制
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]);
|                                     ^^^^^^^
EN

回答 1

Stack Overflow用户

发布于 2022-08-17 05:51:54

您的存储变量钱包在修饰符中。必须在修饰符之外声明状态变量。

代码语言:javascript
复制
 modifier isDeceased {
    require (deceased == true);
    _;
}

address [0xa1F9019E4F941071cAabCbb3fBc6314c06BeD18f] wallets;
mapping (address => uint) inheritance;

// }   --> not here
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73382158

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档