Changes to contract + estimated gas

This commit is contained in:
Richard Ramos 2018-10-22 15:03:43 -04:00
parent b847f10149
commit 02b3884d02
3 changed files with 25 additions and 11 deletions

View File

@ -64,18 +64,30 @@ contract SNTGiveaway is Controlled {
root = _root; 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 /// @notice Extract balance in ETH + SNT from the contract and destroy the contract
function boom() public onlyController { function boom() public onlyController {
uint sntBalance = SNT.balanceOf(address(this)); uint sntBalance = SNT.balanceOf(address(this));
require(SNT.transfer(controller, sntBalance), "Transfer did not work"); require(SNT.transfer(msg.sender, sntBalance), "Transfer did not work");
selfdestruct(controller); selfdestruct(msg.sender);
} }
function() public payable { function() public payable {
} }
} }

View File

@ -1,22 +1,24 @@
pragma solidity ^0.4.23; pragma solidity ^0.4.23;
contract Controlled { contract Controlled {
mapping(address => bool) controllers;
/// @notice The address of the controller is the only address that can call /// @notice The address of the controller is the only address that can call
/// a function with this modifier /// a function with this modifier
modifier onlyController { modifier onlyController {
require(msg.sender == controller); require(controllers[msg.sender]);
_; _;
} }
address public controller; address public controller;
constructor() internal { constructor() internal {
controller = msg.sender; controllers[msg.sender] = true;
} }
/// @notice Changes the controller of the contract function changeControllerAccess(address _controller, bool _access) public onlyController {
/// @param _newController The new controller of the contract controllers[_controller] = _access;
function changeController(address _newController) public onlyController {
controller = _newController;
} }
} }

View File

@ -124,7 +124,7 @@ const process = async (request) => {
const tx = { const tx = {
gasPrice: parseInt(gasPrice), gasPrice: parseInt(gasPrice),
gas: estimatedGas + 1000, gas: estimatedGas + 50000,
from: account.address, from: account.address,
to: config.contractAddress, to: config.contractAddress,
value: "0x00", value: "0x00",