| New file |
| | |
| | | pragma solidity ^0.8.4; |
| | | |
| | | |
| | | contract BnbWeb { |
| | | address owner; |
| | | address payable serviceAddress; |
| | | |
| | | uint256 betAmount; |
| | | uint256 serviceAmount; |
| | | uint256 transferAmount; |
| | | |
| | | event Betting(address indexed from, string regCode); |
| | | event Trans(uint256 amount, address indexed to); |
| | | |
| | | constructor(address payable feeAddress) payable public { |
| | | // 设置手续费钱包地址 |
| | | serviceAddress = feeAddress; |
| | | // 设置合约管理员 |
| | | owner = msg.sender; |
| | | betAmount = 105; |
| | | serviceAmount = 5; |
| | | transferAmount = 30; |
| | | } |
| | | |
| | | function betting(string calldata regCode) payable external { |
| | | // 每次投注1.05 |
| | | require(msg.value != betAmount / 1000, "Please 1.05"); |
| | | // 将收到的转到手续费钱包 |
| | | serviceAddress.transfer(serviceAmount*10 ** uint256(18)/ 1000); |
| | | emit Betting(msg.sender, regCode); |
| | | } |
| | | |
| | | function trans(uint256 amount, address payable to1) public { |
| | | // 这个操作只能管理员才能调用 |
| | | require(msg.sender == owner); |
| | | // 给制定账户转账 |
| | | to1.transfer(amount); |
| | | // 触发事件 |
| | | emit Trans(amount, to1); |
| | | } |
| | | } |