-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathethereumwallet.sol
More file actions
59 lines (47 loc) · 1.32 KB
/
ethereumwallet.sol
File metadata and controls
59 lines (47 loc) · 1.32 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract tech4dev {
address payable public owner;
constructor(){
owner = payable(msg.sender);
}
receive() external payable{}
//create get function
function getBalance() public view returns (uint) {
return address(this).balance;
}
//create a withdraw function
function withdraw(uint _amount) public {
require(msg.sender == owner, "Thief you are not the owner");
payable(msg.sender).transfer(_amount);
}
//Anyone can withdraw
function Anybodycanwithdraw(uint _amount, address payable _to) public {
_to.transfer(_amount);
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract tech4dev {
/*
Class Work
Create a contract that can receive ether.
The contract will have the following functions:
Get function
Withdraw Function
|*/
address payable public owner;
constructor(){
owner = payable(msg.sender);
}
receive() external payable{}
//getBalance function
function getBalance() public view returns (uint) {
return address(this).balance;
}
//Withdraw function
function withdraw(uint _amount) public {
require(msg.sender == owner, "Error you are not the owner");
payable(msg.sender).transfer(_amount);
}
}