-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSmartContract.sol
37 lines (30 loc) · 908 Bytes
/
SmartContract.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.7;
contract smartContract{
uint256 private balance;
address public owner;
constructor(address _owner) payable {
owner=_owner;
balance+=msg.value;
}
//i receive payouts that come with function
fallback() external payable {
balance+=msg.value;
}
receive() external payable {
balance+=msg.value;
}
function getBalance() external view returns (uint256){
return balance;
}
function deposit() external payable{
balance +=msg.value;
}
function withdraw(uint256 _amount) external {
//constraint!!
require(msg.sender==owner,"You re not authorized.");
require(balance>=_amount,"Insufficient balance.");
balance -=_amount;
payable (owner).transfer(_amount);
}
}