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

@ -65,11 +65,23 @@ contract SNTGiveaway is Controlled {
}
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);
}

View File

@ -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;
}
}

View File

@ -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",