Contract 0xA6e72eFC07e99957497156D1E40B9eeA7a06c0C6

 

Contract Overview

Balance:
0.0208 Ether

EtherValue:
$2.89 (@ $138.92/ETH)
TxHash Block Age From To Value [TxFee]
0x9e3dfbb88c86cb6d564d537e0cb745926331119bfa9b3d41028547eb942bc782716894014 days 12 hrs ago0xc69e4946457eb0f88fb1888a6bbba13abfe2239d  IN   0xa6e72efc07e99957497156d1e40b9eea7a06c0c60.01 Ether0.000442896
0xcab35ae7c88e3ff8c4c8dd9a0a696ec99d4388fb8befc970c69158d9a7a2837a683552273 days 19 hrs ago0x5ab7c4a0a69426827f4de5fc7c00dc2e0482034d  IN   0xa6e72efc07e99957497156d1e40b9eea7a06c0c60.001 Ether0.000494289
0xa21bd4fc149ea38f40cb9bd98631546515e36c7ed1d762751592d6d62524dba3683118374 days 12 hrs ago0x5ab7c4a0a69426827f4de5fc7c00dc2e0482034d  IN   0xa6e72efc07e99957497156d1e40b9eea7a06c0c60.001 Ether0.000495342
0x8d524186234aaa2d278dcd618b27cf5cab6b6497802fa5521302045fe73e73c3683007774 days 17 hrs ago0x5ab7c4a0a69426827f4de5fc7c00dc2e0482034d  IN   0xa6e72efc07e99957497156d1e40b9eea7a06c0c60.001 Ether0.000385266
0x46aef8c3390a2dedfafbbffdc5347b7bb7cc00173b3faa7b5705dd773c67ca1e682943274 days 19 hrs ago0x5ab7c4a0a69426827f4de5fc7c00dc2e0482034d  IN   0xa6e72efc07e99957497156d1e40b9eea7a06c0c60.001 Ether0.00055038
0x1cabe70f102c06f65379edc080f2739a004e15aae61efb112a3baf492259735d682937874 days 20 hrs ago0x5ab7c4a0a69426827f4de5fc7c00dc2e0482034d  IN   0xa6e72efc07e99957497156d1e40b9eea7a06c0c60.001 Ether0.000495342
0x6a4653b09356fedadbad557019d0cdde916393543e84e4ecbc103088e9bf1a45682918174 days 20 hrs ago0x5ab7c4a0a69426827f4de5fc7c00dc2e0482034d  IN   0xa6e72efc07e99957497156d1e40b9eea7a06c0c60.001 Ether0.00070038
0x492b5824992cccb01b91bbe491656b16c89f87dd4622aeec30dd7f6f8a19b844682900074 days 21 hrs ago0x5ab7c4a0a69426827f4de5fc7c00dc2e0482034d  IN   0xa6e72efc07e99957497156d1e40b9eea7a06c0c60.01 Ether0.00147632
0x8130a5049af0659a3f1bb102466e3bf4a5a4a461bfb8ce2a0610a19122415f53682897374 days 21 hrs ago0xd58af86238e0c00cfd7115bc84c963e92fa25621  IN   Contract Creation0 Ether0.009032089
[ Download CSV Export 

Latest 8 Internal Transactions Internal Transactions as a result of Contract Execution

Parent TxHash Block Age From To Value
0x9e3dfbb88c86cb6d564d537e0cb745926331119bfa9b3d41028547eb942bc782716894014 days 12 hrs ago0xa6e72efc07e99957497156d1e40b9eea7a06c0c60xd58af86238e0c00cfd7115bc84c963e92fa256210.002 Ether
0xcab35ae7c88e3ff8c4c8dd9a0a696ec99d4388fb8befc970c69158d9a7a2837a683552273 days 19 hrs ago0xa6e72efc07e99957497156d1e40b9eea7a06c0c60xd58af86238e0c00cfd7115bc84c963e92fa256210.0002 Ether
0xa21bd4fc149ea38f40cb9bd98631546515e36c7ed1d762751592d6d62524dba3683118374 days 12 hrs ago0xa6e72efc07e99957497156d1e40b9eea7a06c0c60xd58af86238e0c00cfd7115bc84c963e92fa256210.0002 Ether
0x8d524186234aaa2d278dcd618b27cf5cab6b6497802fa5521302045fe73e73c3683007774 days 17 hrs ago0xa6e72efc07e99957497156d1e40b9eea7a06c0c60xd58af86238e0c00cfd7115bc84c963e92fa256210.0002 Ether
0x46aef8c3390a2dedfafbbffdc5347b7bb7cc00173b3faa7b5705dd773c67ca1e682943274 days 19 hrs ago0xa6e72efc07e99957497156d1e40b9eea7a06c0c60xd58af86238e0c00cfd7115bc84c963e92fa256210.0002 Ether
0x1cabe70f102c06f65379edc080f2739a004e15aae61efb112a3baf492259735d682937874 days 20 hrs ago0xa6e72efc07e99957497156d1e40b9eea7a06c0c60xd58af86238e0c00cfd7115bc84c963e92fa256210.0002 Ether
0x6a4653b09356fedadbad557019d0cdde916393543e84e4ecbc103088e9bf1a45682918174 days 20 hrs ago0xa6e72efc07e99957497156d1e40b9eea7a06c0c60xd58af86238e0c00cfd7115bc84c963e92fa256210.0002 Ether
0x492b5824992cccb01b91bbe491656b16c89f87dd4622aeec30dd7f6f8a19b844682900074 days 21 hrs ago0xa6e72efc07e99957497156d1e40b9eea7a06c0c60xd58af86238e0c00cfd7115bc84c963e92fa256210.002 Ether
[ Download CSV Export 
Contract Source Code Verified (Exact Match)
Contract Name: Town
Compiler Version: v0.4.25+commit.59dbf8f1
Optimization Enabled: Yes
Runs (Optimizer):  200


Contract Source Code
pragma solidity ^0.4.25;

contract Town {
    struct Position {
        int x;
        int y;
    }
    
    uint movePrice = 0.001 ether;
    uint attackPrice = 0.005 ether;
    uint spawnPrice = 0.01 ether;
    uint fee = 20;
    uint refFee = 10;
    
    mapping (address => bool) internal users;
    mapping (address => bool) internal ingame;
    mapping (address => address) public referrers;
    mapping (int => mapping (int => address)) public field;
    mapping (address => Position) public positions;
    address support = msg.sender;
    
    uint private seed;
    
    event UserPlaced(address user, int x, int y);
    event UserAttacked(address user, address by);
    event UserRemoved(address user);
    
    /* Converts uint256 to bytes32 */
    function toBytes(uint256 x) internal pure returns (bytes b) {
        b = new bytes(32);
        assembly {
            mstore(add(b, 32), x)
        }
    }
    
    function random(uint lessThan) internal returns (uint) {
        seed += block.timestamp + uint(msg.sender);
        return uint(sha256(toBytes(uint(blockhash(block.number - 1)) + seed))) % lessThan;
    }
    
    function bytesToAddress(bytes source) internal pure returns (address parsedAddress) {
        assembly {
            parsedAddress := mload(add(source,0x14))
        }
        return parsedAddress;
    }
    
    function requireEmptyCell(int x, int y) internal view {
        require(field[x][y] == 0x0);
    }
    
    function moveTo(int diffX, int diffY) internal {
        Position storage p = positions[msg.sender];
        int _x = p.x + diffX;
        int _y = p.y + diffY;
        requireEmptyCell(_x, _y);
        delete field[p.x][p.y];
        field[_x][_y] = msg.sender;
        positions[msg.sender] = Position(_x, _y);
    }
    
    function removeUserFrom(address user, int x, int y) internal {
        delete ingame[user];
        delete field[x][y];
        delete positions[user];
    }
    
    function tryAttack(int diffX, int diffY) internal returns (address) {
        Position storage p = positions[msg.sender];
        int _x = p.x + diffX;
        int _y = p.y + diffY;
        address enemy = field[_x][_y];
        if (enemy != 0x0) {
            removeUserFrom(enemy, _x, _y);
            msg.sender.transfer(address(this).balance / 2);
            return enemy;
        } else {
            return 0x0;
        }
    }
    
    function fees() internal {
        support.transfer(msg.value * fee / 100);
        if (referrers[msg.sender] != 0x0) {
            referrers[msg.sender].transfer(msg.value * refFee / 100);
        }
    }

    function move(uint8 dir) external payable {
        require(ingame[msg.sender]);
        require(msg.value == movePrice);
        require(dir < 4);
        fees();
        if (dir == 0) {
            moveTo(0, -1);
        } else if (dir == 1) {
            moveTo(1, 0);
        } else if (dir == 2) {
            moveTo(0, 1);
        } else {
            moveTo(-1, 0);
        }
        emit UserPlaced(msg.sender, positions[msg.sender].x, positions[msg.sender].y);
    }
    
    function attack(uint8 dir) external payable {
        require(ingame[msg.sender]);
        require(msg.value == attackPrice);
        require(dir < 4);
        fees();
        address enemy;
        if (dir == 0) {
            enemy = tryAttack(0, -1);
        } else if (dir == 1) {
            enemy = tryAttack(1, 0);
        } else if (dir == 2) {
            enemy = tryAttack(0, 1);
        } else {
            enemy = tryAttack(-1, 0);
        }
        emit UserAttacked(enemy, msg.sender);
        emit UserRemoved(enemy);
    }
    
    function () external payable {
        require(!ingame[msg.sender]);
        require(msg.value == spawnPrice);
        ingame[msg.sender] = true;
        if (!users[msg.sender]) {
            users[msg.sender] = true;
            address referrerAddress = bytesToAddress(bytes(msg.data));
            require(referrerAddress != msg.sender);     
            if (users[referrerAddress]) {
                referrers[msg.sender] = referrerAddress;
            }
        }
        
        fees();
        
        int x = int(random(20)) - 10;
        int y = int(random(20)) - 10;
        
        while (field[x][y] != 0x0) {
            x += int(random(2)) * 2 - 1;
            y += int(random(2)) * 2 - 1;
        }
        
        field[x][y] = msg.sender;
        positions[msg.sender] = Position(x, y);
        
        emit UserPlaced(msg.sender, x, y);
    }
}

Contract ABI
[{"constant":false,"inputs":[{"name":"dir","type":"uint8"}],"name":"attack","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"referrers","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"positions","outputs":[{"name":"x","type":"int256"},{"name":"y","type":"int256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"dir","type":"uint8"}],"name":"move","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"int256"},{"name":"","type":"int256"}],"name":"field","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":false,"name":"user","type":"address"},{"indexed":false,"name":"x","type":"int256"},{"indexed":false,"name":"y","type":"int256"}],"name":"UserPlaced","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"user","type":"address"},{"indexed":false,"name":"by","type":"address"}],"name":"UserAttacked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"user","type":"address"}],"name":"UserRemoved","type":"event"}]

Contract Creation Code
608060405266038d7ea4c680006000556611c37937e08000600155662386f26fc100006002556014600355600a60048190558054600160a060020a0319163317905534801561004d57600080fd5b506109738061005d6000396000f30060806040526004361061006c5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416631999eca881146102a95780634a3b68cc146102b957806355f57510146102f657806370e87aaf14610330578063da04570b1461033e575b336000908152600660205260408120548190819060ff161561008d57600080fd5b600254341461009b57600080fd5b336000908152600660209081526040808320805460ff19166001179055600590915290205460ff16151561018b57336000908152600560209081526040808320805460ff191660011790558051601f3690810184900484028201840190925281815261011c9390929091908190840183828082843750610359945050505050565b9250600160a060020a03831633141561013457600080fd5b600160a060020a03831660009081526005602052604090205460ff161561018b57336000908152600760205260409020805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0385161790555b610193610360565b600a61019f601461041c565b039150600a6101ae601461041c565b0390505b6000828152600860209081526040808320848452909152902054600160a060020a0316156102045760016101e6600261041c565b600202038201915060016101fa600261041c565b60020203016101b2565b60008281526008602090815260408083208484528252808320805473ffffffffffffffffffffffffffffffffffffffff191633908117909155815180830183528681528084018681528286526009855294839020905181559351600194909401939093558051928352908201849052818101839052517feece30da3471446f0af796f3e1e97e125f203980da3ae1fe122622e36cf507c69181900360600190a1505050005b6102b760ff600435166104d7565b005b3480156102c557600080fd5b506102da600160a060020a03600435166105fc565b60408051600160a060020a039092168252519081900360200190f35b34801561030257600080fd5b50610317600160a060020a0360043516610617565b6040805192835260208301919091528051918290030190f35b6102b760ff60043516610630565b34801561034a57600080fd5b506102da600435602435610723565b6014015190565b600a54600354604051600160a060020a03909216916064349092029190910480156108fc02916000818181858888f193505050501580156103a5573d6000803e3d6000fd5b5033600090815260076020526040902054600160a060020a03161561041a5733600090815260076020526040902054600454600160a060020a03909116906108fc906064903402049081150290604051600060405180830381858888f19350505050158015610418573d6000803e3d6000fd5b505b565b600b8054423301019081905560009082906002906104409060001943014001610749565b6040518082805190602001908083835b6020831061046f5780518252601f199092019160209182019101610450565b51815160209384036101000a600019018019909216911617905260405191909301945091925050808303816000865af11580156104b0573d6000803e3d6000fd5b5050506040513d60208110156104c557600080fd5b50518115156104d057fe5b0692915050565b3360009081526006602052604081205460ff1615156104f557600080fd5b600154341461050357600080fd5b600460ff83161061051357600080fd5b61051b610360565b60ff82161515610539576105326000600019610774565b9050610579565b8160ff16600114156105515761053260016000610774565b8160ff16600214156105695761053260006001610774565b6105766000196000610774565b90505b60408051600160a060020a038316815233602082015281517f1e2b30dfd20c0333e61eb2d623d50b9e59108c31821d0900918943b00cd641cd929181900390910190a160408051600160a060020a038316815290517fe9dce8c992623ce791725b21e857e33248d1f190a25b5168313420eebdaae99d9181900360200190a15050565b600760205260009081526040902054600160a060020a031681565b6009602052600090815260409020805460019091015482565b3360009081526006602052604090205460ff16151561064e57600080fd5b600054341461065c57600080fd5b600460ff82161061066c57600080fd5b610674610360565b60ff811615156106905761068b600060001961080e565b6106cd565b8060ff16600114156106a85761068b6001600061080e565b8060ff16600214156106c05761068b6000600161080e565b6106cd600019600061080e565b33600081815260096020908152604091829020805460019091015483519485529184015282820152517feece30da3471446f0af796f3e1e97e125f203980da3ae1fe122622e36cf507c69181900360600190a150565b6008602090815260009283526040808420909152908252902054600160a060020a031681565b6040805160208082528183019092526060918082016104008038833950505060208101929092525090565b3360009081526009602090815260408083208054600182015490870180865260088552838620918701808752919094529184205490929190600160a060020a031680156107ff576107c68184846108b1565b6040513390600230310480156108fc02916000818181858888f193505050501580156107f6573d6000803e3d6000fd5b50809450610804565b600094505b5050505092915050565b336000908152600960205260409020805460018201549084019083016108348282610916565b8254600090815260086020818152604080842060019788015485528252808420805473ffffffffffffffffffffffffffffffffffffffff1990811690915586855292825280842085855282528084208054339416841790558051808201825295865285820194855291835260099052902091518255519101555050565b600160a060020a039092166000818152600660209081526040808320805460ff1916905593825260088152838220948252938452828120805473ffffffffffffffffffffffffffffffffffffffff191690559081526009909252812081815560010155565b6000828152600860209081526040808320848452909152902054600160a060020a03161561094357600080fd5b50505600a165627a7a72305820648048cd80af6e0bf5007f811202df029ef9dc39ee47d09000d429d5ee768cdd0029


   Swarm Source:
bzzr://648048cd80af6e0bf5007f811202df029ef9dc39ee47d09000d429d5ee768cdd
Block Age transaction Difficulty GasUsed Reward
Block Age Uncle Number Difficulty GasUsed Reward
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.