-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbnbstaking.sol
53 lines (40 loc) · 1.57 KB
/
bnbstaking.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
*Submitted for verification at testnet.bscscan.com on 2024-12-23
*/
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
contract corestaking {
uint256 public constant STAKE_AMOUNT = 0.0002 ether;
address public owner;
// Add the hasStaked mapping
mapping(address => bool) public hasStaked;
event Staked(address indexed user, uint256 amount);
event FundsSent(address indexed recipient, uint256 amount);
constructor() {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner, "Only owner can call this function");
_;
}
function stake() public payable {
require(msg.value == STAKE_AMOUNT, "You must stake exactly 0.0002 BNB");
require(!hasStaked[msg.sender], "You have already staked");
hasStaked[msg.sender] = true;
emit Staked(msg.sender, msg.value);
}
// Add the verifyStake function
function verifyStake(address user) public view returns (bool) {
return hasStaked[user];
}
function withdraw() public onlyOwner {
payable(owner).transfer(address(this).balance);
}
function sendFundsTo(address payable recipient) public onlyOwner {
require(recipient != address(0), "Invalid recipient address");
require(address(this).balance > 0, "Contract has no funds to send");
uint256 amount = address(this).balance;
recipient.transfer(amount);
emit FundsSent(recipient, amount);
}
}