Contract Address Details

0xd3906264e1DeC6985F68B9d84D0651948Ab3BdE4

TokenAirdrop Last Balance Update: Block #9390041
Created by 0x4ce2–7390b7 at 0x9400–a3b124

Balance

0 ETC

(@ /ETC)

Fetching tokens...

Contract name:
TokenAirdrop




Optimization enabled
true
Compiler version
v0.4.19+commit.c4cbbb05





Contract source code

/**
* Submitted for verification at blockscout.com on 2019-02-19 19:02:48.149135Z
*/
pragma solidity ^0.4.19;
library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) {
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (_a == 0) {
return 0;
}
c = _a * _b;
assert(c / _a == _b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 _a, uint256 _b) internal pure returns (uint256) {
// assert(_b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = _a / _b;
// assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold
return _a / _b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {
assert(_b <= _a);
return _a - _b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) {
c = _a + _b;
assert(c >= _a);
return c;
}
}
library BytesLib {
function toAddress(bytes _bytes, uint _start) internal pure returns (address) {
require(_bytes.length >= (_start + 20));
address tempAddress;
assembly {
tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000)
}
return tempAddress;
}
function toUint(bytes _bytes, uint _start) internal pure returns (uint256) {
require(_bytes.length >= (_start + 32));
uint256 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0x20), _start))
}
return tempUint;
}
}
contract ERC223 {
uint public totalSupply;
function balanceOf(address who) constant returns (uint);
function name() constant returns (string _name);
function symbol() constant returns (string _symbol);
function decimals() constant returns (uint8 _decimals);
function totalSupply() constant returns (uint256 _supply);
function transfer(address to, uint value) returns (bool ok);
function transfer(address to, uint value, bytes data) returns (bool ok);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event ERC223Transfer(address indexed _from, address indexed _to, uint256 _value, bytes _data);
}
contract ContractReceiver {
function tokenFallback(address _from, uint _value, bytes _data);
}
contract ERC20 {
function totalSupply() public view returns (uint256);
function balanceOf(address _who) public view returns (uint256);
function allowance(address _owner, address _spender)
public view returns (uint256);
function transfer(address _to, uint256 _value) public returns (bool);
function approve(address _spender, uint256 _value)
public returns (bool);
function transferFrom(address _from, address _to, uint256 _value)
public returns (bool);
event Transfer(
address indexed from,
address indexed to,
uint256 value
);
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
}
contract TokenAirdrop is ContractReceiver {
using SafeMath for uint256;
using BytesLib for bytes;
// let users withdraw their tokens
// person => token => balance
mapping(address => mapping(address => uint256)) private balances;
address private etherAddress = 0x0;
event Airdrop(
address from,
address to,
address token,
uint amount,
uint time
);
event Claim(
address claimer,
address token,
uint amount,
uint time
);
// handle incoming ERC223 tokens
function tokenFallback(address from, uint value, bytes data) public {
require(data.length == 20);
address beneficiary = data.toAddress(0);
balances[beneficiary][msg.sender] = balances[beneficiary][msg.sender].add(value);
Airdrop(from, beneficiary, msg.sender, value, now);
}
// handle ether
function giftEther(address to) public payable {
require(msg.value > 0);
balances[to][etherAddress] = balances[to][etherAddress].add(msg.value);
Airdrop(msg.sender, to, etherAddress, msg.value, now);
}
// handle ERC20
function giftERC20(address to, uint amount, address token) public {
ERC20(token).transferFrom(msg.sender, address(this), amount);
balances[to][token] = balances[to][token].add(amount);
Airdrop(msg.sender, to, token, amount, now);
}
function claim(address token) public {
uint amount = balanceOf(msg.sender, token);
require(amount > 0);
balances[msg.sender][token] = 0;
require(sendTokensTo(msg.sender, amount, token));
Claim(msg.sender, token, amount, now);
}
function balanceOf(address person, address token) public view returns(uint) {
return balances[person][token];
}
function sendTokensTo(address destination, uint256 amount, address tkn) private returns(bool) {
if (tkn == etherAddress) {
destination.transfer(amount);
} else {
require(ERC20(tkn).transfer(destination, amount));
}
return true;
}
}

Contract ABI

[{"type":"function","stateMutability":"payable","payable":true,"outputs":[],"name":"giftEther","inputs":[{"type":"address","name":"to"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"claim","inputs":[{"type":"address","name":"token"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"tokenFallback","inputs":[{"type":"address","name":"from"},{"type":"uint256","name":"value"},{"type":"bytes","name":"data"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":""}],"name":"balanceOf","inputs":[{"type":"address","name":"person"},{"type":"address","name":"token"}],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"giftERC20","inputs":[{"type":"address","name":"to"},{"type":"uint256","name":"amount"},{"type":"address","name":"token"}],"constant":false},{"type":"event","name":"Airdrop","inputs":[{"type":"address","name":"from","indexed":false},{"type":"address","name":"to","indexed":false},{"type":"address","name":"token","indexed":false},{"type":"uint256","name":"amount","indexed":false},{"type":"uint256","name":"time","indexed":false}],"anonymous":false},{"type":"event","name":"Claim","inputs":[{"type":"address","name":"claimer","indexed":false},{"type":"address","name":"token","indexed":false},{"type":"uint256","name":"amount","indexed":false},{"type":"uint256","name":"time","indexed":false}],"anonymous":false}]
            

Contract Byte Code

0x6060604052600436106100535763ffffffff60e060020a6000350416631e7343fb81146100585780631e83409a1461006e578063c0ee0b8a1461008d578063f7888aec146100f2578063f822b45714610129575b600080fd5b61006c600160a060020a0360043516610152565b005b341561007957600080fd5b61006c600160a060020a036004351661022d565b341561009857600080fd5b61006c60048035600160a060020a03169060248035919060649060443590810190830135806020601f820181900481020160405190810160405281815292919060208401838380828437509496506102e295505050505050565b34156100fd57600080fd5b610117600160a060020a03600435811690602435166103d0565b60405190815260200160405180910390f35b341561013457600080fd5b61006c600160a060020a0360043581169060243590604435166103f9565b6000341161015f57600080fd5b600160a060020a0380821660009081526020818152604080832060015490941683529290522054610196903463ffffffff61054616565b600160a060020a0380831660009081526020818152604080832060018054861685529252918290209390935591547f8a803bd303fa7c974e446e64445e7b326b8b7463cf20965886eba7545f4d0602923392859216903490429051600160a060020a0395861681529385166020850152919093166040808401919091526060830193909352608082015260a001905180910390a150565b600061023933836103d0565b90506000811161024857600080fd5b33600160a060020a0381811660009081526020818152604080832093871683529290529081205561027a908284610559565b151561028557600080fd5b7f865ca08d59f5cb456e85cd2f7ef63664ea4f73327414e9d8152c4158b0e9464533838342604051600160a060020a0394851681529290931660208301526040808301919091526060820192909252608001905180910390a15050565b600081516014146102f257600080fd5b61030382600063ffffffff61063516565b600160a060020a03808216600090815260208181526040808320339094168352929052205490915061033b908463ffffffff61054616565b600160a060020a0380831660009081526020818152604080832033948516845290915290819020929092557f8a803bd303fa7c974e446e64445e7b326b8b7463cf20965886eba7545f4d060291869184918790429051600160a060020a0395861681529385166020850152919093166040808401919091526060830193909352608082015260a001905180910390a150505050565b600160a060020a0391821660009081526020818152604080832093909416825291909152205490565b80600160a060020a03166323b872dd33308560006040516020015260405160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401602060405180830381600087803b151561046357600080fd5b6102c65a03f1151561047457600080fd5b50505060405180515050600160a060020a03808416600090815260208181526040808320938516835292905220546104b2908363ffffffff61054616565b600160a060020a038085166000908152602081815260408083209386168352929052819020919091557f8a803bd303fa7c974e446e64445e7b326b8b7463cf20965886eba7545f4d0602903390859084908690429051600160a060020a0395861681529385166020850152919093166040808401919091526060830193909352608082015260a001905180910390a1505050565b8181018281101561055357fe5b92915050565b600154600090600160a060020a03838116911614156105a857600160a060020a03841683156108fc0284604051600060405180830381858888f1935050505015156105a357600080fd5b61062b565b81600160a060020a031663a9059cbb858560006040516020015260405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b151561060557600080fd5b6102c65a03f1151561061657600080fd5b50505060405180519050151561062b57600080fd5b5060019392505050565b600080826014018451101561064957600080fd5b6c0100000000000000000000000083602086010151049493505050505600a165627a7a7230582007a31bd1dff998f68bbd8abfe99c428f3289e269a5f83e79ed0dfa09d06229250029