Skip to content

Instantly share code, notes, and snippets.

@thexeromin
Created December 29, 2022 13:31
Show Gist options
  • Save thexeromin/5b8893243ac9e356e19ba512add78e4c to your computer and use it in GitHub Desktop.
Save thexeromin/5b8893243ac9e356e19ba512add78e4c to your computer and use it in GitHub Desktop.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
contract Bridge is Ownable {
using SafeMath for uint256;
address public tokenReceiver = 0x7604cC735Baaf33283dc4f3372A7B4A14B93Ce10;
address public feeReceiver = 0x7604cC735Baaf33283dc4f3372A7B4A14B93Ce10;
uint256 public fee = 5;
uint256 public feeDenominator = 10000;
function initiate() public payable {
uint256 amount = msg.value;
uint256 feeAmount = amount.mul(fee).div(feeDenominator);
bool feeSent = payable(feeReceiver).send(feeAmount);
require(feeSent, "Failed to send fee");
uint256 remainingAmount = amount.sub(feeAmount);
bool sent = payable(address(this)).send(remainingAmount);
require(sent, "Failed to send BRISE");
emit Received(msg.sender, remainingAmount);
}
function withdrawETH(uint256 _amount) public onlyOwner {
bool sent = payable(tokenReceiver).send(_amount);
require(sent, "Failed to send BRISE");
emit Withdraw(tokenReceiver, _amount);
}
function transfer(address _to, uint256 _amount) public onlyOwner {
bool sent = payable(_to).send(_amount);
require(sent, "Failed to send");
}
function updateTokenReceiver(address _receiver) public onlyOwner {
tokenReceiver = _receiver;
}
function updateFee(uint256 _fee, uint256 _feeDenominator) public onlyOwner {
fee = _fee;
feeDenominator = _feeDenominator;
}
function ethBalance() public view onlyOwner returns (uint256) {
return address(this).balance;
}
receive() external payable {}
event Received(address, uint);
event Withdraw(address, uint);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment