-
-
Save anoushk1234/37a29f4acbfcb52e26682660acfd267e 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.13; | |
contract Securus { | |
address payable _owner; | |
string private _otp; | |
address private _crank_auth; | |
//create a mapping so other addresses can interact with this wallet. Uint8 is used to determine is the address enabled of disabled | |
// mapping(address => uint8) private _owners; | |
//in order to interact with the wallet you need to be the owner so added a require statement then execute the function _; | |
modifier isOwner() { | |
require(msg.sender == _owner); | |
_; | |
} | |
modifier isCrank() { | |
require(msg.sender == _crank_auth); | |
_; | |
} | |
//Require the msg.sender/the owner OR || Or an owner with a 1 which means enabled owner | |
// modifier validOwner() { | |
// require(msg.sender == _owner || _owners[msg.sender] == 1); | |
// _; | |
// } | |
event DepositFunds(address from, uint amount); | |
event WithdrawFunds(address from, uint amount); | |
event TransferFunds(address from, address to, uint amount); | |
event OTPUpdated(uint256 timestamp); | |
//the creator is the owner of the wallet | |
constructor(address crank_auth) { | |
_owner = payable(msg.sender); | |
_crank_auth= crank_auth; | |
} | |
//this function is used to add owners of the wallet. Only the isOwner can add addresses. 1 means enabled | |
// function addOwner(address owner) | |
// isOwner | |
// public { | |
// _owners[owner] = 1; | |
// } | |
//remove an owner from the wallet. 0 means disabled | |
// function removeOwner(address owner) | |
// isOwner | |
// public { | |
// _owners[owner] = 0; | |
// } | |
//Anyone can deposit funds into the wallet and emit an event called depositfunds | |
// function deposit(uint amount) | |
// external | |
// payable { | |
// bool sent = msg.sender.send(amount); | |
// require(sent, "Failed to send funds"); | |
// emit DepositFunds(msg.sender, msg.value); | |
// } | |
//to withdraw you need to be an owner, the amount needs to be >= balance of acct. then transfer and emit an event | |
function withdraw (uint amount,address payable from) | |
isOwner | |
public payable{ | |
from.transfer(amount); | |
emit WithdrawFunds(msg.sender, amount); | |
} | |
function getOTP() public view returns (string memory){ | |
return _otp; | |
} | |
function transferTo(address payable to, uint amount) | |
isOwner | |
public { | |
require(address(this).balance >= amount); | |
to.transfer(amount); | |
emit TransferFunds(msg.sender, to, amount); | |
} | |
function changeOTP(string memory otp) isCrank public { | |
_otp = otp; | |
emit OTPUpdated(block.timestamp); | |
} | |
function recoverWallet(string memory user_otp) public{ | |
require(keccak256(bytes(_otp)) == keccak256(bytes(user_otp)),"OTP is invalid"); | |
_owner=payable(msg.sender); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment