diff --git a/contracts/SNTGiveaway.sol b/contracts/SNTGiveaway.sol index d70b4dd..76c83ca 100644 --- a/contracts/SNTGiveaway.sol +++ b/contracts/SNTGiveaway.sol @@ -64,18 +64,30 @@ contract SNTGiveaway is Controlled { root = _root; } + + function manualSend(address _destAddress, bytes5 code) public onlyController { + require(!sentToAddress[_dest] && !codeUsed[_code], "Funds already sent / Code already used"); + + sentToAddress[_dest] = true; + codeUsed[_code] = true; + + require(SNT.transfer(_dest, sntAmount), "Transfer did not work"); + _dest.transfer(ethAmount); + + emit AddressFunded(_dest, _code, ethAmount, sntAmount); + } /// @notice Extract balance in ETH + SNT from the contract and destroy the contract function boom() public onlyController { uint sntBalance = SNT.balanceOf(address(this)); - require(SNT.transfer(controller, sntBalance), "Transfer did not work"); - selfdestruct(controller); + require(SNT.transfer(msg.sender, sntBalance), "Transfer did not work"); + selfdestruct(msg.sender); } - function() public payable { + function() public payable { - } + } } diff --git a/contracts/common/Controlled.sol b/contracts/common/Controlled.sol index 7b615b6..889270e 100644 --- a/contracts/common/Controlled.sol +++ b/contracts/common/Controlled.sol @@ -1,22 +1,24 @@ pragma solidity ^0.4.23; contract Controlled { + + mapping(address => bool) controllers; + /// @notice The address of the controller is the only address that can call /// a function with this modifier modifier onlyController { - require(msg.sender == controller); + require(controllers[msg.sender]); _; } address public controller; constructor() internal { - controller = msg.sender; + controllers[msg.sender] = true; } - /// @notice Changes the controller of the contract - /// @param _newController The new controller of the contract - function changeController(address _newController) public onlyController { - controller = _newController; + function changeControllerAccess(address _controller, bool _access) public onlyController { + controllers[_controller] = _access; } + } diff --git a/server/main.js b/server/main.js index b0c603f..f6ca478 100644 --- a/server/main.js +++ b/server/main.js @@ -124,7 +124,7 @@ const process = async (request) => { const tx = { gasPrice: parseInt(gasPrice), - gas: estimatedGas + 1000, + gas: estimatedGas + 50000, from: account.address, to: config.contractAddress, value: "0x00",