Smart contract code:
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract AddressWallets {
// variables
address owner;
uint funds;
bool transferFund;
constructor() payable {
owner == msg.sender;
funds == msg.value;
transferFund = false;
}
modifier onlyOwner{
require(msg.sender == owner);
_;
}
modifier fundTransfered{
require(transferFund == true);
_;
}
// list of wallet address
address payable[] investorWallets;
// map through all the wallet addresses
mapping(address => uint) investors;
//Write a payable function called payInvestors which takes the parameters address and amount.
function payInvestors(address payable wallet, uint amount) public {
//Write logic in the function so that it can add new wallets to investorWallets and fill them with amounts of your choosing.
investorWallets.push(wallet);
investors[wallet] = amount;
}
function sendEthers() private fundTransfered {
for( uint i = 0; i < investorWallets.length; i++) {
investorWallets[i].transfer(investors[investorWallets[i]]);
}
}
// fund transfer trigger....
function hasTransfered() public onlyOwner {
transferFund = true;
sendEthers();
}
function checkInvestors() public view returns (uint) {
return investorWallets.length;
}
}