Solidity声明错误与钱包中的货币支付功能有关



我是solidity 的新手

我的目标是让这些代码在混音IDE solidity编译器中工作

该代码是一个";对于";函数,该函数旨在在dead=true时触发(该代码用于继承契约(,但它在"true"方面存在问题;钱包";最后两行代码的一部分。

我试着在这里和其他地方(比如Solidity/Remix IDE文档(寻找解决方案,但遇到了这个特殊的问题。

我试着把";[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]);
|                                     ^^^^^^^

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

modifier isDeceased {
require (deceased == true);
_;
}
address [0xa1F9019E4F941071cAabCbb3fBc6314c06BeD18f] wallets;
mapping (address => uint) inheritance;
// }   --> not here

相关内容

  • 没有找到相关文章

最新更新