forked from github/haikus-for-codespaces
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwallet-control.sol
37 lines (29 loc) · 1.15 KB
/
wallet-control.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/access/Ownable.sol";
contract FamilyWallet is Ownable {
uint256 public withdrawalLimit;
mapping(address => bool) public approvedWallets;
// Pass the initialOwner argument to the Ownable constructor
constructor(address initialOwner) Ownable(initialOwner) {
// Additional setup if required
}
// Set withdrawal limit
function setWithdrawalLimit(uint256 _limit) external onlyOwner {
withdrawalLimit = _limit;
}
// Approve or revoke a wallet's access
function approveWallet(address wallet, bool status) external onlyOwner {
approvedWallets[wallet] = status;
}
// Withdraw funds
function withdraw(uint256 amount) external {
require(approvedWallets[msg.sender], "Not an approved wallet");
require(amount <= withdrawalLimit, "Exceeds withdrawal limit");
require(address(this).balance >= amount, "Insufficient balance");
// Transfer funds to the sender
payable(msg.sender).transfer(amount);
}
// Fallback function to accept ETH
receive() external payable {}
}