mirror of
https://github.com/status-im/hackathon-registration-dapp.git
synced 2025-02-28 12:00:41 +00:00
Changes to contract + estimated gas
This commit is contained in:
parent
b847f10149
commit
02b3884d02
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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",
|
||||
|
Loading…
x
Reference in New Issue
Block a user