Created
August 9, 2022 04:47
-
-
Save Ultra-Tech-code/d26bf24307e3b85f358a40d783a79e7a to your computer and use it in GitHub Desktop.
This file contains 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.8; | |
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/security/Pausable.sol"; | |
contract wallet is Pausable{ | |
//STate Variables// | |
address owner; | |
mapping(address => uint) public balance; | |
event _transfer(address indexed from, address indexed to, uint amount); | |
event _withdraw(address indexed _owmer, uint indexed amount); | |
constructor (){ | |
owner = msg.sender; | |
} | |
modifier onlyOwner(){ | |
require(msg.sender == owner, "You can't perform this transaction"); | |
_; | |
} | |
function deposit() external payable returns(bool){ | |
require(msg.value > 0, "Money too small to be deposited"); | |
balance[msg.sender] += msg.value; | |
emit _withdraw(msg.sender, msg.value); | |
return true; | |
} | |
function withdraw(uint _amount) external payable whenNotPaused{ | |
require(msg.sender != address(0), "You can't withdraw here!!"); | |
require(balance[msg.sender] >= _amount, "Insufficeint balance"); | |
uint amount = balance[msg.sender] - msg.value; | |
payable(msg.sender).transfer(amount); | |
emit _withdraw(msg.sender, amount); | |
} | |
function transfer (address _to, uint _amount) external payable whenNotPaused{ | |
require(_to != address(0), "This address cannot be found"); | |
require(balance[msg.sender] >= _amount, "Insufficeint balance"); | |
uint amount = balance[msg.sender] - msg.value; | |
// balance[_to] += msg.value; | |
payable(_to).transfer(amount); | |
emit _transfer(msg.sender, _to, amount); | |
} | |
function getBalance(address _user) external view returns(uint){ | |
return balance[_user]; | |
} | |
function getWalletBalance() external view returns(uint){ | |
return address(this).balance; | |
} | |
function stopTransaction() external onlyOwner{ | |
_pause(); | |
} | |
function continueTransaction() external onlyOwner{ | |
_unpause(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment