pragma solidity ^0.5.10;
import "./Interfaces/IETHSender.sol";
import "./Utils/Withdrawable.sol";
import "openzeppelin-solidity/contracts/lifecycle/Pausable.sol";
import "openzeppelin-solidity/contracts/access/roles/SignerRole.sol";
/**
* @title ETHSender
* @dev Sends ETH based on the signer of the instruction.
* The deployer is the Owner and the first Signer for convenience.
* The Owner and the Signer can be different.
* Only the owner can withdraw assets or pause.
*/
contract ETHSender is IETHSender, Pausable, SignerRole, Withdrawable {
// the proxy smart contract address
address public proxy;
event LogSendETH(
address indexed signer,
address indexed recipient,
uint256 indexed amount
);
modifier onlyProxy() {
require(msg.sender == proxy, "fn: sendETH(), msg: caller is not the proxy");
_;
}
constructor(address proxyAddress) public payable {
require(proxyAddress != address(0), "fn: constructor(), msg: proxyAddress == address(0)");
proxy = proxyAddress;
}
function() external payable {}
/**
* @dev Send ETH.
* This function can be call only from the owner of the smart contract.
* @param signer The signer of the operation.
* @param recipient The ETH recipient.
* @param amount The amount to be received.
*/
function sendETH(
address signer,
address payable recipient,
uint256 amount
)
external
onlyProxy
whenNotPaused
returns (bool)
{
require(amount > 0, "fn: sendETH(), msg: amount == 0");
require(
amount <= address(this).balance,
"fn: sendETH(), msg: ETH balance not sufficient"
);
require(isSigner(signer), "fn: sendETH(), msg: signer not allowed");
recipient.transfer(amount);
emit LogSendETH(
signer,
recipient,
amount
);
return true;
}
/**
* @dev Destroy the contract.
* Only the owner can destroy the contract.
*/
function kill() public onlyOwner {
selfdestruct(msg.sender);
}
/**
* @dev Set Proxy.
* This function can be call only from the owner and sets the proxy contract address.
* @param proxyAddress The proxy smart contract address.
*/
function setProxy(address proxyAddress) public onlyOwner returns(bool) {
require(proxyAddress != address(0), "fn: setProxy(), msg: proxyAddress == address(0)");
require(proxyAddress != proxy, "fn: setProxy(), msg: proxyAddress == proxy");
proxy = proxyAddress;
return true;
}
}
Created
December 18, 2019 14:36
-
-
Save andreafspeziale/aef346c9cb1c279323141b190c1a1fd6 to your computer and use it in GitHub Desktop.
Contract for ETH transfer
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment