// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
// Error
error Connect__NotOwner();
error Connect__NotEnoughEth();
contract Connect {
//state variables
uint256 public constant MINIMUM_ETH = 5_000_000_000_000_00;
address private immutable i_owner;
// Modifiers
modifier onlyOwner() {
if (msg.sender != i_owner) revert Connect__NotOwner();
_;
}
// Events
event Funded(address indexed from, uint256 indexed amount);
event Withdrawn(uint256 indexed amount);
constructor() {
i_owner = msg.sender;
}
function fund() public payable {
if (msg.value < MINIMUM_ETH) revert Connect__NotEnoughEth();
emit Funded(msg.sender, msg.value);
}
function withdraw() public payable onlyOwner {
payable(msg.sender).transfer(address(this).balance);
emit Withdrawn(address(this).balance);
}
function getOwner() public view returns (address) {
return i_owner;
}
fallback() external payable {
fund();
}
receive() external payable {
fund();
}
}
{
"compilationTarget": {
"Connect.sol": "Connect"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"Connect__NotEnoughEth","type":"error"},{"inputs":[],"name":"Connect__NotOwner","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Funded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"MINIMUM_ETH","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"fund","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"getOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"payable","type":"function"},{"stateMutability":"payable","type":"receive"}]