Last active
September 25, 2024 03:14
-
-
Save mingderwang/2220a303f928279aa41d4ff9d933d1c0 to your computer and use it in GitHub Desktop.
refer to https://github.com/mingderwang/me/wiki deploy to sepolia 0xee96d999Ea10b2CCB8Ba20B3FAe0f431e394336f
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.0; | |
import "@openzeppelin/contracts/access/Ownable.sol"; | |
contract AbstractWallet is Ownable { | |
constructor() Ownable(msg.sender) { | |
} | |
mapping(address => bool) public authorizedAddresses; | |
event TransactionExecuted(address indexed to, uint256 value, bytes data); | |
event AddressAuthorized(address indexed addr); | |
event AddressRevoked(address indexed addr); | |
// Modifier to check if the caller is authorized | |
modifier onlyAuthorized() { | |
require(authorizedAddresses[msg.sender] || msg.sender == owner(), "Not authorized"); | |
_; | |
} | |
// Function to authorize an address | |
function authorizeAddress(address addr) external onlyOwner { | |
authorizedAddresses[addr] = true; | |
emit AddressAuthorized(addr); | |
} | |
// Function to revoke an address | |
function revokeAddress(address addr) external onlyOwner { | |
authorizedAddresses[addr] = false; | |
emit AddressRevoked(addr); | |
} | |
// Function to execute a transaction | |
function executeTransaction(address to, uint256 value, bytes calldata data) external onlyAuthorized { | |
(bool success, ) = to.call{value: value}(data); | |
require(success, "Transaction failed"); | |
emit TransactionExecuted(to, value, data); | |
} | |
// Allow the contract to receive ETH | |
receive() external payable {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment