0
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;

contract will {
    address owner;
    uint fortune;
    bool deceased;


    constructor() payable public {
        owner = msg.sender; //msg sender represent address that is begin calles
        fortune = msg.value;// msg value tell us much ether begin sent
        deceased =false;
          
    }
     
     //create modifier so that only person that can call the contract is the owner
        modifier onlyOwner {
         require (msg.sender == owner);
         _;
     }
    
 
    //create modifier so that only allocate fund if friends gramp deceased
        modifier mustBeDeceased {
         require (deceased ==true );
         _;
     }
    address payable [] familyWallets;


    //map tru inhertance
    mapping(address => uint) inheritance;

    //set inhertance for each address

    function setInheritance(address payable wallet, uint amount) public {
        //to add wallet to the family wallet .push

        familyWallets.push(wallet);
        inheritance[wallet] = amount;
    }

    //pay eeach family member besed on their wallet address
    function payout() private mustBeDeceased {
        //with a for loop you can loop through thing and set conditions
        for( i=0; i<familyWallets.length; i++ ) {
            familyWallets[i].transfer(inheritance[familyWallets[i]])
        }
    }
        
        //orcale switch simulation
    function deceased() public onlyOwner {
        isDeceased = true;
        payout();
    }     

}

1 Answer 1

0

Your contract had multiple issues which made it impossible to compile. Here is a version that doesn't throw any errors. The first issue (; required) was for the familyWallets[i].transfer line.

// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;

contract Will {
    address owner;
    uint fortune;
    bool deceased;


    constructor() payable {
        owner = msg.sender; //msg sender represent address that is begin calles
        fortune = msg.value;// msg value tell us much ether begin sent
        deceased =false;
          
    }
     
     //create modifier so that only person that can call the contract is the owner
        modifier onlyOwner {
         require (msg.sender == owner);
         _;
     }
    
 
    //create modifier so that only allocate fund if friends gramp deceased
        modifier mustBeDeceased {
         require (deceased ==true );
         _;
     }
    address payable [] familyWallets;


    //map tru inhertance
    mapping(address => uint) inheritance;

    //set inhertance for each address

    function setInheritance(address payable wallet, uint amount) public {
        //to add wallet to the family wallet .push

        familyWallets.push(wallet);
        inheritance[wallet] = amount;
    }

    //pay eeach family member besed on their wallet address
    function payout() private mustBeDeceased {
        //with a for loop you can loop through thing and set conditions
        for(uint256 i=0; i<familyWallets.length; i++ ) {
            familyWallets[i].transfer(inheritance[familyWallets[i]]);
        }
    }
        
        //orcale switch simulation
    function declareDeceased() public onlyOwner {
        deceased = true;
        payout();
    }     

}

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.