Contract 0x7d1aa4fc1a668ccd5aaeb639a5786de322612afe

 

Contract Overview

Balance:
0 BNB

BNB Value:
$0.00

Token:
Txn Hash
Block
From
To
Value [Txn Fee]
0x2a1eebb630b51c439c740e1bbf9c9d3bde6178e333ab8bb2cfad9b6ee08665bd72009182021-05-07 1:27:0348 days 9 hrs ago0xba387b00b00ee6811bc226757eb242ccdfa12d7e IN  0x7d1aa4fc1a668ccd5aaeb639a5786de322612afe0 BNB0.00139506
0xd9da9a8b474477c00d44a37dd918705b4d57703d4e272eb01ccb84ab7a79a93a71980672021-05-06 23:01:5348 days 12 hrs ago0x089840a0d8dbdf89c4f94d4847bfad3e23dcc0ee IN  0x7d1aa4fc1a668ccd5aaeb639a5786de322612afe0 BNB0.00117006
0x16e245236ebe88afddf75fa0db27138dae867190345f2abf6a219124456c18f471906872021-05-06 16:48:5448 days 18 hrs ago0xb3afa07e16583e21a20d1478c70ab808ba30ff29 IN  0x7d1aa4fc1a668ccd5aaeb639a5786de322612afe0 BNB0.001012055
0x5bc2d460976c68e22f01a65a941d52458c7800da175b938af1d83e9726d9edd871904562021-05-06 16:37:0248 days 18 hrs ago0xe8ebdc6f996bd6dd249b0a63ec2ef73c65b118e0 IN  0x7d1aa4fc1a668ccd5aaeb639a5786de322612afe0 BNB0.00117006
0x7bb6f29a9cd53bed8f35b7c5dd9a846c50910aef661f12ffd35718a7ba28164071900342021-05-06 16:15:2848 days 18 hrs ago0xe87c14d0e590e064b80bcb634d303e3f5a96715f IN  0x7d1aa4fc1a668ccd5aaeb639a5786de322612afe0 BNB0.00139506
0xf9ecca593048a4fc51e895c0fd0f337078d49940d43dd39bd3ab08ff4bf7fa8c71897122021-05-06 15:58:5248 days 19 hrs ago0x0f1e073b23b4b2d0e3f537ab536ef7f00a3c56ee IN  0x7d1aa4fc1a668ccd5aaeb639a5786de322612afe0 BNB0.00117006
0x2b4a9cce2a15cc99accf9fa62e500506aa2523936ccffcb9f94a6c5b74e7c97571896872021-05-06 15:57:3448 days 19 hrs ago0x40fff87e8c99b1b1d58bd4a6d7cf8ff060548660 IN  0x7d1aa4fc1a668ccd5aaeb639a5786de322612afe0 BNB0.00117006
0x48fd60c79d3942b85422e8dac46751539b50dca0d4fa7bee6011cad1735cc24471896572021-05-06 15:56:0448 days 19 hrs ago0x6556204617568e9b37dbf074a36dc9abd5ae544b IN  0x7d1aa4fc1a668ccd5aaeb639a5786de322612afe0 BNB0.00139506
0x90917f482e3fc9cad3e246b6562b28a5e2fd133b3c86d05dc1bb16acd55ce0e671896522021-05-06 15:55:4948 days 19 hrs ago0x6556204617568e9b37dbf074a36dc9abd5ae544b IN  0x7d1aa4fc1a668ccd5aaeb639a5786de322612afe0 BNB0.000636445
0x12b5f83a99b5791793754e6f1872ce909cfd331f7a210f49c62d950c52399c6e71896342021-05-06 15:54:5548 days 19 hrs ago0xde380b4b52b231bc504e2a688fca1065c47f3253 IN  0x7d1aa4fc1a668ccd5aaeb639a5786de322612afe0 BNB0.00124506
0x96a9d3b4d7bd3229dab492c3c40ac5a5bf958ae5b84f837296d50cb749a4400671896312021-05-06 15:54:4648 days 19 hrs ago0x367e71facac09373dc507dbdfa5142682598b736 IN  0x7d1aa4fc1a668ccd5aaeb639a5786de322612afe0 BNB0.00139506
0x32c0df302d724c291d98a7bb1827d8741c1a0dffd4bcaa44bcb9b2ddc538054371896222021-05-06 15:54:1948 days 19 hrs ago0x8a9b7145bc7f7b2a530f188a4fc933f66f5cfe12 IN  0x7d1aa4fc1a668ccd5aaeb639a5786de322612afe0 BNB0.00132006
0xa42dfcbffc9324940332a88e267725a0929854a3f088f68d6028f138b6a9f54071896212021-05-06 15:54:1648 days 19 hrs ago0xc36c80e794a371fd95d740f732385ea53454e0cd IN  0x7d1aa4fc1a668ccd5aaeb639a5786de322612afe0 BNB0.00124506
0x350d6ffa8f60cdba2c927563e817199bbecfc5ab921b0e6b3e2b795e79b649fd71896142021-05-06 15:53:5548 days 19 hrs ago0xd320f96410baddcd0fe158dc25b4c364a161f23a IN  0x7d1aa4fc1a668ccd5aaeb639a5786de322612afe0 BNB0.00117006
0x2e28c857e6673ab441816250598574a768cc3ea931ae936d2a7a56e879da506771896122021-05-06 15:53:4948 days 19 hrs ago0x8583c5bd9256ad3a0cfa421719916b0139137fe3 IN  0x7d1aa4fc1a668ccd5aaeb639a5786de322612afe0 BNB0.00117006
0x5fd42b400be1322becaa0a61851f479783b2eb538f1b2213344f4da703bae92571896082021-05-06 15:53:3748 days 19 hrs ago0xf48558dd77ed1541b2331d5ef92aa50d7c95ca78 IN  0x7d1aa4fc1a668ccd5aaeb639a5786de322612afe0 BNB0.00124506
0xd0656ffe115484f9117cd8d4a6e9c9fb6caed31c64b9390e4d48446028b0be0371896062021-05-06 15:53:3148 days 19 hrs ago0x0852a5556e12301feae507e149c9bc575ea9d626 IN  0x7d1aa4fc1a668ccd5aaeb639a5786de322612afe0 BNB0.00124506
0xccd84898acbe4881d7e16698b5e65f50870da82273c1729a44d0e839d19530d171896052021-05-06 15:53:2848 days 19 hrs ago0x14edc2ce4e34d610539543e19dbeac3ea8ac7d11 IN  0x7d1aa4fc1a668ccd5aaeb639a5786de322612afe0 BNB0.00139506
0xd7379bdd43b44196da00a0e4ddc1f490560b47f960e89eb45fa5cbbe1fbda20371896032021-05-06 15:53:2248 days 19 hrs ago0x9eeb7d64cfc9b2505cc149ffa8a1ec5d157ab5cf IN  0x7d1aa4fc1a668ccd5aaeb639a5786de322612afe0 BNB0.00124506
0xda4ca7fe9f13787e8b99ad35b1500b4c374332ebb3f253ca5c7ca1d44109fa8b71895992021-05-06 15:53:1048 days 19 hrs ago0xde380b4b52b231bc504e2a688fca1065c47f3253 IN  0x7d1aa4fc1a668ccd5aaeb639a5786de322612afe0 BNB0.00107389
0xee9ee8538d3b712df9476891dcaf30c7e1b05c594b82d92e2325154620a5ace071895992021-05-06 15:53:1048 days 19 hrs ago0x8a9b7145bc7f7b2a530f188a4fc933f66f5cfe12 IN  0x7d1aa4fc1a668ccd5aaeb639a5786de322612afe0 BNB0.002762256
0x2cafa7988ff91ede907e8940bd201acda7657fb67758ec358e76e37a6e99d28771895982021-05-06 15:53:0748 days 19 hrs ago0x367e71facac09373dc507dbdfa5142682598b736 IN  0x7d1aa4fc1a668ccd5aaeb639a5786de322612afe0 BNB0.00114815
0xb6b84b2a04e1420319943fb6738cdb61c8149cd8318f424aac48a5771ae0bb6b71895952021-05-06 15:52:5848 days 19 hrs ago0x0852a5556e12301feae507e149c9bc575ea9d626 IN  0x7d1aa4fc1a668ccd5aaeb639a5786de322612afe0 BNB0.00171185
0xa106eb1f6655f3f107e56aec46c40cf06b7f42f65ee13c9ee2c63ee05f9a92a171895942021-05-06 15:52:5548 days 19 hrs ago0x8a9b7145bc7f7b2a530f188a4fc933f66f5cfe12 IN  0x7d1aa4fc1a668ccd5aaeb639a5786de322612afe0 BNB0.002763174
0xe0a11883913069a8fc17169bc6adb14caa9de01941e48f892e630d89e2eec51471895932021-05-06 15:52:5248 days 19 hrs ago0xde380b4b52b231bc504e2a688fca1065c47f3253 IN  0x7d1aa4fc1a668ccd5aaeb639a5786de322612afe0 BNB0.00171882
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Similar Match)
Note: This contract matches the deployed ByteCode of the Source Code for Contract 0xb2e33c84Cc25Ddfcf89279E748395d5337C64fea

Contract Name:
Arena

Compiler Version
v0.8.0+commit.c7dfd78e

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 21 : Arena.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.0;
pragma experimental ABIEncoderV2;

import "../oz/utils/structs/EnumerableSet.sol";
import "../oz/access/Ownable.sol";
import "../oz/token/ERC20/ERC20.sol";
import "../oz/token/ERC20/IERC20.sol";
import "../oz/token/ERC20/utils/SafeERC20.sol";
import "../oz/token/ERC721/utils/ERC721Holder.sol";
import '../oz/token/ERC721/IERC721.sol';
import "../oz/utils/math/SafeMath.sol";
import "./BeastNFT.sol";
import "./Random.sol";

contract Arena is Ownable, ERC721Holder {
    using SafeERC20 for IERC20;
    using SafeMath for uint;
    using Random for Random.Seed;
    
    
    struct FighterInfo {
        address user;
        uint seed1;
        uint8 health1;
        uint seed2;
        uint8 health2;
        uint seed3;
        uint8 health3;
        uint coins;
        uint name;
        uint8 fights;
    }
    
    struct Log {
        address attacker;
        uint8 healthA1;
        uint8 healthA2;
        uint8 healthA3;
        address defender;
        uint8 healthD1;
        uint8 healthD2;
        uint8 healthD3;
        uint16[] kicks; // array 6 numbers ([damage] [enemyIndex] [myIndex])
        uint money;
        bool win;
    }
    
    enum State { IDLE, PREPARING, STARTED, FINISHED }
    uint public startPreparingBlock;
    uint public startFightBlock;
    uint public endFightBlock;
    
    BeastNFT public nft;
    IERC20 public gen;
    uint8 public maxTeam = 3;
    uint public pool;
    uint16 public usersCount = 0;
    uint16 public usersLimit = 30;    
    uint public minLevel = 1;
    uint public maxLevel = 3;
    event Fight(Log log);
    
    constructor(BeastNFT n, IERC20 g) {
        nft = n;
        gen = g;
    }
    
    mapping (address => uint[]) public teams;
    mapping (uint => uint8) public health;
    mapping (address => uint8) public fightNumber; 
    mapping (address => uint) public money; 
    mapping (address => uint16) public fightersIndexer;
    mapping (uint16 => address) public allFighters;
     
     
    function fight(address enemy) public {
        require(getState() == State.STARTED,"Battle didn't start");
        require(fightNumber[msg.sender] < 7,"too much attacks");
        require(totalHealth(teams[msg.sender]) > 0,"You have 0 health");
        require(totalHealth(teams[enemy]) > 0,"You have 0 health");
        
        
        // uint userSeed = uint(sha256((abi.encodePacked(msg.sender)))); 
        
        uint mySeed = uint(blockhash(block.number - 1)) / 100000;// >> 4 + userSeed >> 4 + ;
        uint enemySeed = mySeed / 10000000000;
        
        
        uint8 myDamage = 0;
        uint8 enemyDamage = 0;
        
        uint16[] memory kicks = new uint16[](6);
        
        for (uint8 i=0;i<3;i++) {
            if (health[teams[msg.sender][i]] > 0) {
                uint16 damage = attack(i,msg.sender,enemy, mySeed) * 10 + uint16(i);
                
                // uint16 damage = attack(i,msg.sender,enemy, mySeed,
                // [ health[teams[enemy][0]], health[teams[enemy][1]], health[teams[enemy][2]] ],
                // [ defenceFor(teams[enemy][0]), defenceFor(teams[enemy][1]), defenceFor(teams[enemy][2])]
                // ) * 10 + uint16(i);
                
                
                kicks[i * 2] = 10000 + damage;
                myDamage += uint8(damage / 100);
            } else {
                kicks[i * 2] = 0;
            }
            
            mySeed /= 1000;
                
            if (health[teams[enemy][i]] > 0) {
                uint16 damage = attack(i,enemy,msg.sender, enemySeed) * 10 + uint16(i);
                
                // uint16 damage = attack(i,enemy,msg.sender, enemySeed,
                // [ health[teams[msg.sender][0]], health[teams[msg.sender][1]], health[teams[msg.sender][2]] ],
                // [ defenceFor(teams[msg.sender][0]), defenceFor(teams[msg.sender][1]), defenceFor(teams[msg.sender][2])]
                // ) * 10 + uint16(i);
                
                kicks[i * 2 + 1] = 10000 + damage;
                enemyDamage += uint8(damage / 100);
            } else {
                kicks[i * 2 + 1] = 0;
            }
            
            enemySeed /= 1000;
        }
        
        fightNumber[msg.sender]++;
        
        uint myMoney = moneyFor(msg.sender);
        uint enemyMoney = moneyFor(enemy);
        bool meAlive = totalHealth(teams[msg.sender]) > 0;
        bool enemyAlive = totalHealth(teams[enemy]) > 0;
        uint moneyChange = 0;
        bool isWin = false;
        if (meAlive) {
            if ((myDamage >= enemyDamage) || (enemyAlive == false)) {
                moneyChange = enemyMoney * 30 / 100;
                money[msg.sender] = myMoney + enemyMoney * 30 / 100;
                money[enemy] = enemyMoney - enemyMoney * 30 / 100;
                isWin = true;
            }
        }
        
        if (enemyAlive) {
            if ((myDamage < enemyDamage) || (meAlive == false)) {
                moneyChange = myMoney * 30 / 100;
                money[msg.sender] = myMoney - myMoney * 30 / 100;
                money[enemy] = enemyMoney + myMoney * 30 / 100;
            }
        }
        uint[] memory enemyTeam = teams[enemy];
        
        emit Fight(Log(msg.sender,
        health[teams[msg.sender][0]],
        health[teams[msg.sender][1]],
        health[teams[msg.sender][2]],
        enemy,
        health[enemyTeam[0]],
        health[enemyTeam[1]],
        health[enemyTeam[2]],
        kicks, moneyChange, isWin));
    }
    
    function attack(uint8 index, address me, address enemy, uint mySeed) private returns (uint16) {//([damage] [enemyIndex])
        uint myId = teams[me][index];
        
        uint8 damage = 0;
      
            uint8 enemyIndex = index;
            
            if (health[teams[enemy][enemyIndex]] == 0) {
                for (uint8 i = 0; i<3; i++) {
                    if (health[teams[enemy][i]] > 0) {
                        enemyIndex = i;
                        break;
                    }
                }
            }
                
            uint enemyId = teams[enemy][enemyIndex];
                
            uint8 enemyHealth = health[enemyId];
            if (enemyHealth > 0) {
                if (mySeed % 10 >= defenceFor(teams[enemy][enemyIndex])) { //try block
                    damage = uint8(mySeed % 1000 % strengthFor(myId) + 1);
                    
                    if (enemyHealth > damage) {
                        health[enemyId] = enemyHealth - damage;
                    } else {
                        health[enemyId] = 0;
                        nft.kill(enemyId);
                    }
                }
            }
        
  
        return damage * 10 + enemyIndex;
    }
    
    function attackk(uint8 index, address me, address enemy, uint mySeed, uint8[] memory healthEnemies, uint8[] memory defences) private returns (uint16) {//([damage] [index])
        uint myId = teams[me][index];
        
        uint8 damage = 0;
      
            
        if (healthEnemies[index] == 0) {
            for (uint8 i = 0; i<3; i++) {
                if (healthEnemies[i] > 0) {
                    index = i;
                    break;
                }
            }
        }
                
        uint enemyId = teams[enemy][index];
        uint8 enemyHealth = healthEnemies[index];
            
        if (enemyHealth > 0) {
            if (mySeed % 10 >= defences[index]) {
                damage = uint8(mySeed % 1000 % strengthFor(myId) + 1);
                    
                if (enemyHealth > damage) {
                    health[enemyId] = enemyHealth - damage;
                } else {
                    health[enemyId] = 0;
                    nft.kill(enemyId);
                }
            }
        }
  
        return damage * 10 + index;
    }
    
    function strengthFor(uint tokenId) view public returns (uint8) {
        BeastNFT.Ability[] memory abilities = nft.abilitiesFor(tokenId);
        uint strength = 5;
        for (uint i = 0; i< abilities.length; i++) {
            if (abilities[i].value.param == 2) {
                strength += abilities[i].value.amount;
            }
            
        }
        
        return uint8(strength);
    }
    
    function defenceFor(uint tokenId) view public returns (uint8) {
        BeastNFT.Ability[] memory abilities = nft.abilitiesFor(tokenId);
        uint defence = 0;
        for (uint i = 0; i< abilities.length; i++) {
            if (abilities[i].value.param == 3) {
                defence += abilities[i].value.amount;
            }
        }
        
        return uint8(defence);
    }
    
    function moneyFor(address user) view public returns (uint){
        if (money[user] == 0) {
            return pool / usersCount;
        }
        return money[user];
    }
    
    function totalHealth(uint[] memory team) view public returns (uint8) {
        return health[team[0]] +  health[team[1]] + health[team[2]];
    }
    
    function addMonsters(uint nftId1, uint nftId2, uint nftId3) public {
        require(getState() == State.PREPARING,"Battle already started");
        require(nft.ownerOf(nftId1) == msg.sender, "you are not owner");
        require(nft.ownerOf(nftId2) == msg.sender, "you are not owner");
        require(nft.ownerOf(nftId3) == msg.sender, "you are not owner");
        
        uint abAmount1 = nft.abilitiesAmount(nftId1);
        uint abAmount2 = nft.abilitiesAmount(nftId2);
        uint abAmount3 = nft.abilitiesAmount(nftId3);
        
        require(abAmount1 >= minLevel, "don't fit");
        require(abAmount2 >= minLevel, "don't fit");
        require(abAmount3 >= minLevel, "don't fit");
        require(abAmount1 <= maxLevel, "don't fit");
        require(abAmount2 <= maxLevel, "don't fit");
        require(abAmount3 <= maxLevel, "don't fit");
        
        require(teams[msg.sender].length == 0, "you are not owner");
        require(usersCount < usersLimit, "users Limit");
        
        teams[msg.sender].push(nftId1);
        teams[msg.sender].push(nftId2);
        teams[msg.sender].push(nftId3);
        
        health[nftId1] = uint8(nft.statsFor(nftId1).health);
        health[nftId2] = uint8(nft.statsFor(nftId2).health);
        health[nftId3] = uint8(nft.statsFor(nftId3).health);
        
        allFighters[usersCount] = msg.sender; 
        fightersIndexer[msg.sender] = usersCount;
        usersCount++;
        
        nft.safeTransferFrom(address(msg.sender), address(this), nftId1);
        nft.safeTransferFrom(address(msg.sender), address(this), nftId2);
        nft.safeTransferFrom(address(msg.sender), address(this), nftId3);
    }
    
    function leave() public {
        require(getState() == State.FINISHED,"Battle already started");
        uint id0 = teams[msg.sender][0];
        uint id1 = teams[msg.sender][1];
        uint id2 = teams[msg.sender][2];
        
        bool alive = false;
        if (id0 > 0) {
            if (nft.isAlive(id0)) {
                nft.addEvolvePoint(id0,fightNumber[msg.sender]);
                nft.safeTransferFrom(address(this), address(msg.sender), id0);
                alive = true;
            }
            teams[msg.sender][0] = 0;
        }
        
        if (id1 > 0) {
            if (nft.isAlive(id1)) {
                nft.addEvolvePoint(id1,fightNumber[msg.sender]);
                nft.safeTransferFrom(address(this), address(msg.sender), id1);
                alive = true;
            } 
            teams[msg.sender][1] = 0;
        }
        
        if (id2 > 0) {
            if (nft.isAlive(id2)) {
                nft.addEvolvePoint(id2,fightNumber[msg.sender]);
                nft.safeTransferFrom(address(this), address(msg.sender), id2);
                alive = true;
            }
            teams[msg.sender][2] = 0;
        }
        
        require(alive,"You are dead");
        
        if (fightNumber[msg.sender] > 0) { 
            gen.transfer(msg.sender, moneyFor(msg.sender));
        }
    }
    
    function revive() public {
        uint id0 = teams[msg.sender][0];
        uint id1 = teams[msg.sender][1];
        uint id2 = teams[msg.sender][2];
        
        uint8 revived = 0;
        uint lvlSum = 0;
        if (id0 > 0) {
            if (nft.isAlive(id0) == false) {
                lvlSum += nft.abilitiesAmount(id0);
                nft.revive(id0);
                health[id0] = 1;
                revived++;
            }
        }
        
        if (id1 > 0) {
            if (nft.isAlive(id1) == false) {
                lvlSum += nft.abilitiesAmount(id1);
                nft.revive(id1);
                health[id1] = 1;
                revived++;
            } 
        }
        
        if (id2 > 0) {
            if (nft.isAlive(id2) == false) {
                lvlSum += nft.abilitiesAmount(id2);
                nft.revive(id2);
                health[id2] = 1;
                revived++;
            }
        }
        
        require(revived > 0,"You are dead");
        
        if (revived == 3) {
            money[msg.sender] = 1;
        }
        
        gen.transferFrom(msg.sender, address(this), lvlSum * 3 * 1e18);
    }
    
    function getState() public view returns (State) {
        if (block.number < startFightBlock) return State.PREPARING;
        if (block.number > endFightBlock) return State.FINISHED;
        return State.STARTED;
    }
    
    //start
    function start(uint blocks, uint amount) external onlyOwner {
        startPreparingBlock = block.number + blocks;
        startFightBlock = startPreparingBlock + 60 * 20;
        endFightBlock = startFightBlock + 30 * 20;
        pool = amount * 1e18;
    }
    
    function withdrawAll() external onlyOwner {
        gen.safeTransfer(msg.sender, gen.balanceOf(address(this)));
    }
    
    
    function getFightersInfo() view external returns (FighterInfo[] memory) {
        FighterInfo[] memory info = new FighterInfo[](usersCount);
        
        for (uint16 i=0;i<usersCount; i++) {
            info[i] = getFighterInfo(allFighters[i]);
        }
        
        return info;
    }
    
    function getFighterInfo(address user) view public returns (FighterInfo memory) {
        
        return FighterInfo(user,
            nft.valuesSeedFor(teams[user][0]),
            health[teams[user][0]],
            nft.valuesSeedFor(teams[user][1]),
            health[teams[user][1]],
            nft.valuesSeedFor(teams[user][2]),
            health[teams[user][2]],
            moneyFor(user),
            fightersIndexer[user],
            fightNumber[user]);
    }
    
    function updateMinMax(uint min, uint max) public onlyOwner {
        minLevel = min;
        maxLevel = max;
    }
    
    //Trusted
    mapping(address=>bool) private _isTrusted;
    modifier onlyTrusted {
        require(_isTrusted[msg.sender] || msg.sender == owner(), "not trusted");
        _;
    }
    
    function addTrusted(address user) public onlyOwner {
        _isTrusted[user] = true;
    }
    
    function removeTrusted(address user) public onlyOwner {
        _isTrusted[user] = false;
    }
    
    // function revive(uint nftId, address owner) public onlyTrusted {
    //     nft.revive(nftId);
    //     nft.safeTransferFrom(address(this), owner, nftId);
    // }
}

File 2 of 21 : BeastNFT.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.12;
pragma experimental ABIEncoderV2;

import "../oz/utils/structs/EnumerableSet.sol";
import "../oz/access/Ownable.sol";
import "../oz/token/ERC721/extensions/ERC721Enumerable.sol";

contract BeastNFT is ERC721Enumerable, Ownable  {
    
    //// different types of features
    struct Value { 
        uint id;
        uint amount;   // how much boost
        uint param;  // what boost
    }
    
    struct Ability {
        uint feature; //body, horns, wings
        Value value;
    }
    
    struct Info {
        uint valuesSeed;
        uint abilitiesAmount;
        uint breedLeft;
        uint evolvePoints;
        bool dead;
    }
    
    struct Stats { 
        uint health;  //1
        uint strength;//2
        uint defence;//3
    }
    
    constructor() ERC721("Beast NFT","BeastNFT") {
        
    } 
    
    function addValueToFeature(uint featureId, uint id, uint value, uint param) public onlyOwner {
        if (featureId + 1 > featuresAmount) {
            featuresAmount = featureId + 1;
        }
        featureToValues[featureId].push(Value(id, value, param));
    }
    
        
    function updateBreedTimes(uint _maxBreedTimes) public onlyOwner {
        maxBreedTimes = _maxBreedTimes;
    }
    
    function updateEvolvePointsMultiplier(uint _evolvePointsMultiplier) public onlyOwner {
        evolvePointsMultiplier = _evolvePointsMultiplier;
    }
    
    uint public featuresAmount;
    uint public maxBreedTimes = 3;
    uint public evolvePointsMultiplier = 10;
    
    mapping (uint=>Value[]) public featureToValues;
    
    mapping (uint=>uint) public valuesSeedByTokenId;
    mapping (uint=>uint) public abilitiesAmountByTokenId;
    
    mapping (uint=>uint) public breedAmount;
    
    mapping (uint=>uint) public evolvePoints;
    mapping (uint=>bool) public dead;
    
    using EnumerableSet for EnumerableSet.UintSet;
    using Strings for uint256;
    
       //Trusted
    mapping(address=>bool) public _isTrusted;
    modifier onlyTrusted {
        require(_isTrusted[msg.sender] || msg.sender == owner(), "not trusted");
        _;
    }
    
    function addTrusted(address user) public onlyOwner {
        _isTrusted[user] = true;
    }
    
    function removeTrusted(address user) public onlyOwner {
        _isTrusted[user] = false;
    }
       
    uint nextTokenId = 0;
    
    function createToken(address holder) public onlyTrusted returns (uint tokenId) {
        tokenId = ++nextTokenId;
        _mint(holder, tokenId);
    }
    
    function updateAbilities(uint tokenId, uint amount, uint valuesSeed) public onlyTrusted {
        abilitiesAmountByTokenId[tokenId] = amount;
        valuesSeedByTokenId[tokenId] = valuesSeed;
    }
    
    function addEvolvePoint(uint tokenId, uint points) public onlyTrusted {
        evolvePoints[tokenId] += points;
    }
    
    function evolve(uint tokenId) public onlyTrusted {
        require(evolvePoints[tokenId] >= abilitiesAmountByTokenId[tokenId] * evolvePointsMultiplier / 10, "can't evolve");
        require(abilitiesAmountByTokenId[tokenId] < featuresAmount, "can't evolve");
        evolvePoints[tokenId] -= abilitiesAmountByTokenId[tokenId] * evolvePointsMultiplier / 10;
    }
    
    function kill(uint tokenId) public onlyTrusted {
        dead[tokenId] = true;
    }
    
    function revive(uint tokenId) public onlyTrusted {
        dead[tokenId] = false;
    }
    
    function breed(uint tokenId) public onlyTrusted {
        breedAmount[tokenId] = breedAmount[tokenId] + 1;
        if (breedAmount[tokenId] >= maxBreedTimes) {
            dead[tokenId] = true;
        }
    }
    
    function isAlive(uint tokenId) view public returns (bool) {
        return dead[tokenId] == false;
    }
    
     function canEvolve(uint tokenId) view public returns (bool) {
        return (dead[tokenId] == false) &&
        (abilitiesAmountByTokenId[tokenId] < featuresAmount) && 
        (abilitiesAmountByTokenId[tokenId] * evolvePointsMultiplier / 10 <= evolvePoints[tokenId]);
    }
    
    function valuesSeedFor(uint tokenId) view public returns (uint) {
        return valuesSeedByTokenId[tokenId];
    }
    
    function abilitiesAmount(uint tokenId) view public returns (uint) {
        return abilitiesAmountByTokenId[tokenId];
    }
    
    function valuesAmountFor(uint feature) view public returns (uint) {
        return featureToValues[feature].length;
    }
    
    function info(uint tokenId) view public returns (Info memory) {
        return Info(valuesSeedByTokenId[tokenId],
        abilitiesAmountByTokenId[tokenId],
        maxBreedTimes - breedAmount[tokenId],
        evolvePoints[tokenId],
        dead[tokenId]);
    }
    
    function statsFor(uint tokenId) view public returns (Stats memory) {//health,strength,defence
        Ability[] memory abilities = abilitiesFor(tokenId);
        uint[] memory stats = new uint[](4);
        for (uint i = 0; i< abilities.length; i++) {
            stats[abilities[i].value.param] += abilities[i].value.amount;
        }
        if (dead[tokenId] == true) {
            stats[1] = 0;
        }
        return Stats(stats[1],stats[2] + 5,stats[3]);
    }
    
    function abilitiesFor(uint tokenId) view public returns (Ability[] memory) {
        
        uint abilAmount = abilitiesAmountByTokenId[tokenId];
        uint valuesSeed = valuesSeedByTokenId[tokenId];
        
        Ability[] memory abilities = new Ability[](abilAmount);
        
        for (uint featureIndex = 0; featureIndex < abilAmount; featureIndex++) {
            
            uint valueNumber = valuesSeed % 1000;
            
            abilities[featureIndex] = Ability(featureIndex, featureToValues[featureIndex][valueNumber - 1]);
            
            valuesSeed /= 1000;
        }
        
        return abilities;
    }
    
    function allfeatureToValues() view public returns (Value[][] memory) {
        Value[][] memory all = new Value[][](featuresAmount);
        
        for (uint i = 0; i< featuresAmount; i++) {
            all[i] = featureToValues[i];
        }
        
        return all;
    }
    
    
    function _baseURI() internal view virtual override returns (string memory) {
        return "https://nft.evodefi.com/";
    }
    
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        string memory baseURI = ERC721.tokenURI(tokenId);
        return string(abi.encodePacked(
            baseURI, "/", valuesSeedByTokenId[tokenId].toString()));
    }
}

File 3 of 21 : Random.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;
pragma experimental ABIEncoderV2;
library Random {

  struct Seed {
    uint blockNumber;
  }

  function isInitialized(Seed memory seed) internal pure returns (bool) {
    return seed.blockNumber > 0;
  }
  
  function isReady(Seed memory seed) internal view returns (bool) {
    return (block.number > seed.blockNumber + 1) && (seed.blockNumber > 0);
  }
    
  function init(Seed storage seed) internal {
    require(!isInitialized(seed), "Seed already initialized");
    seed.blockNumber = block.number;
  }
  
  function get(Seed storage seed) internal view returns (bytes32) {
    require(isInitialized(seed), "Seed is not initialized");
    require(block.number > seed.blockNumber, "Wait one more block to open this Seed");
    return blockhash(seed.blockNumber + 1);
  }

  function reset(Seed storage seed) internal {
    seed.blockNumber = 0;
  }

}

File 4 of 21 : Ownable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../utils/Context.sol";
/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor () {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
}

File 5 of 21 : ERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IERC20.sol";
import "../../utils/Context.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin guidelines: functions revert instead
 * of returning `false` on failure. This behavior is nonetheless conventional
 * and does not conflict with the expectations of ERC20 applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is Context, IERC20 {
    mapping (address => uint256) private _balances;

    mapping (address => mapping (address => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * The defaut value of {decimals} is 18. To select a different value for
     * {decimals} you should overload it.
     *
     * All three of these values are immutable: they can only be set once during
     * construction.
     */
    constructor (string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5,05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the value {ERC20} uses, unless this function is
     * overloaded;
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual returns (uint8) {
        return 18;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual override returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `recipient` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(_msgSender(), recipient, amount);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual override returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * Requirements:
     *
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     * - the caller must have allowance for ``sender``'s tokens of at least
     * `amount`.
     */
    function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(sender, recipient, amount);

        uint256 currentAllowance = _allowances[sender][_msgSender()];
        require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
        _approve(sender, _msgSender(), currentAllowance - amount);

        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        uint256 currentAllowance = _allowances[_msgSender()][spender];
        require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
        _approve(_msgSender(), spender, currentAllowance - subtractedValue);

        return true;
    }

    /**
     * @dev Moves tokens `amount` from `sender` to `recipient`.
     *
     * This is internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `sender` cannot be the zero address.
     * - `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     */
    function _transfer(address sender, address recipient, uint256 amount) internal virtual {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(sender, recipient, amount);

        uint256 senderBalance = _balances[sender];
        require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
        _balances[sender] = senderBalance - amount;
        _balances[recipient] += amount;

        emit Transfer(sender, recipient, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply += amount;
        _balances[account] += amount;
        emit Transfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        uint256 accountBalance = _balances[account];
        require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
        _balances[account] = accountBalance - amount;
        _totalSupply -= amount;

        emit Transfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(address owner, address spender, uint256 amount) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    /**
     * @dev Hook that is called before any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * will be to transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
}

File 6 of 21 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

File 7 of 21 : SafeERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(IERC20 token, address spender, uint256 value) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        // solhint-disable-next-line max-line-length
        require((value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        // unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        // }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) { // Return data is optional
            // solhint-disable-next-line max-line-length
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 8 of 21 : ERC721.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "./extensions/IERC721Enumerable.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/ERC165.sol";

/**
 * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
 * the Metadata extension, but not including the Enumerable extension, which is available separately as
 * {ERC721Enumerable}.
 */
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
    using Address for address;
    using Strings for uint256;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    // Mapping from token ID to owner address
    mapping (uint256 => address) private _owners;

    // Mapping owner address to token count
    mapping (address => uint256) private _balances;

    // Mapping from token ID to approved address
    mapping (uint256 => address) private _tokenApprovals;

    // Mapping from owner to operator approvals
    mapping (address => mapping (address => bool)) private _operatorApprovals;

    /**
     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
     */
    constructor (string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
        return interfaceId == type(IERC721).interfaceId
            || interfaceId == type(IERC721Metadata).interfaceId
            || super.supportsInterface(interfaceId);
    }

    /**
     * @dev See {IERC721-balanceOf}.
     */
    function balanceOf(address owner) public view virtual override returns (uint256) {
        require(owner != address(0), "ERC721: balance query for the zero address");
        return _balances[owner];
    }

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId) public view virtual override returns (address) {
        address owner = _owners[tokenId];
        require(owner != address(0), "ERC721: owner query for nonexistent token");
        return owner;
    }

    /**
     * @dev See {IERC721Metadata-name}.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev See {IERC721Metadata-symbol}.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");

        string memory baseURI = _baseURI();
        return bytes(baseURI).length > 0
            ? string(abi.encodePacked(baseURI, tokenId.toString()))
            : '';
    }

    /**
     * @dev Base URI for computing {tokenURI}. Empty by default, can be overriden
     * in child contracts.
     */
    function _baseURI() internal view virtual returns (string memory) {
        return "";
    }

    /**
     * @dev See {IERC721-approve}.
     */
    function approve(address to, uint256 tokenId) public virtual override {
        address owner = ERC721.ownerOf(tokenId);
        require(to != owner, "ERC721: approval to current owner");

        require(_msgSender() == owner || ERC721.isApprovedForAll(owner, _msgSender()),
            "ERC721: approve caller is not owner nor approved for all"
        );

        _approve(to, tokenId);
    }

    /**
     * @dev See {IERC721-getApproved}.
     */
    function getApproved(uint256 tokenId) public view virtual override returns (address) {
        require(_exists(tokenId), "ERC721: approved query for nonexistent token");

        return _tokenApprovals[tokenId];
    }

    /**
     * @dev See {IERC721-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        require(operator != _msgSender(), "ERC721: approve to caller");

        _operatorApprovals[_msgSender()][operator] = approved;
        emit ApprovalForAll(_msgSender(), operator, approved);
    }

    /**
     * @dev See {IERC721-isApprovedForAll}.
     */
    function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
        return _operatorApprovals[owner][operator];
    }

    /**
     * @dev See {IERC721-transferFrom}.
     */
    function transferFrom(address from, address to, uint256 tokenId) public virtual override {
        //solhint-disable-next-line max-line-length
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");

        _transfer(from, to, tokenId);
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override {
        safeTransferFrom(from, to, tokenId, "");
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override {
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
        _safeTransfer(from, to, tokenId, _data);
    }

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * `_data` is additional data, it has no specified format and it is sent in call to `to`.
     *
     * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
     * implement alternative mechanisms to perform token transfer, such as signature-based.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual {
        _transfer(from, to, tokenId);
        require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
    }

    /**
     * @dev Returns whether `tokenId` exists.
     *
     * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
     *
     * Tokens start existing when they are minted (`_mint`),
     * and stop existing when they are burned (`_burn`).
     */
    function _exists(uint256 tokenId) internal view virtual returns (bool) {
        return _owners[tokenId] != address(0);
    }

    /**
     * @dev Returns whether `spender` is allowed to manage `tokenId`.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
        require(_exists(tokenId), "ERC721: operator query for nonexistent token");
        address owner = ERC721.ownerOf(tokenId);
        return (spender == owner || getApproved(tokenId) == spender || ERC721.isApprovedForAll(owner, spender));
    }

    /**
     * @dev Safely mints `tokenId` and transfers it to `to`.
     *
     * Requirements:
     d*
     * - `tokenId` must not exist.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeMint(address to, uint256 tokenId) internal virtual {
        _safeMint(to, tokenId, "");
    }

    /**
     * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
     */
    function _safeMint(address to, uint256 tokenId, bytes memory _data) internal virtual {
        _mint(to, tokenId);
        require(_checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
    }

    /**
     * @dev Mints `tokenId` and transfers it to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - `to` cannot be the zero address.
     *
     * Emits a {Transfer} event.
     */
    function _mint(address to, uint256 tokenId) internal virtual {
        require(to != address(0), "ERC721: mint to the zero address");
        require(!_exists(tokenId), "ERC721: token already minted");

        _beforeTokenTransfer(address(0), to, tokenId);

        _balances[to] += 1;
        _owners[tokenId] = to;

        emit Transfer(address(0), to, tokenId);
    }

    /**
     * @dev Destroys `tokenId`.
     * The approval is cleared when the token is burned.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     *
     * Emits a {Transfer} event.
     */
    function _burn(uint256 tokenId) internal virtual {
        address owner = ERC721.ownerOf(tokenId);

        _beforeTokenTransfer(owner, address(0), tokenId);

        // Clear approvals
        _approve(address(0), tokenId);

        _balances[owner] -= 1;
        delete _owners[tokenId];

        emit Transfer(owner, address(0), tokenId);
    }

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     *
     * Emits a {Transfer} event.
     */
    function _transfer(address from, address to, uint256 tokenId) internal virtual {
        require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
        require(to != address(0), "ERC721: transfer to the zero address");

        _beforeTokenTransfer(from, to, tokenId);

        // Clear approvals from the previous owner
        _approve(address(0), tokenId);

        _balances[from] -= 1;
        _balances[to] += 1;
        _owners[tokenId] = to;

        emit Transfer(from, to, tokenId);
    }

    /**
     * @dev Approve `to` to operate on `tokenId`
     *
     * Emits a {Approval} event.
     */
    function _approve(address to, uint256 tokenId) internal virtual {
        _tokenApprovals[tokenId] = to;
        emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
    }

    /**
     * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
     * The call is not executed if the target address is not a contract.
     *
     * @param from address representing the previous owner of the given token ID
     * @param to target address that will receive the tokens
     * @param tokenId uint256 ID of the token to be transferred
     * @param _data bytes optional data to send along with the call
     * @return bool whether the call correctly returned the expected magic value
     */
    function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data)
        private returns (bool)
    {
        if (to.isContract()) {
            try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
                return retval == IERC721Receiver(to).onERC721Received.selector;
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    revert("ERC721: transfer to non ERC721Receiver implementer");
                } else {
                    // solhint-disable-next-line no-inline-assembly
                    assembly {
                        revert(add(32, reason), mload(reason))
                    }
                }
            }
        } else {
            return true;
        }
    }

    /**
     * @dev Hook that is called before any token transfer. This includes minting
     * and burning.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
     * transferred to `to`.
     * - When `from` is zero, `tokenId` will be minted for `to`.
     * - When `to` is zero, ``from``'s `tokenId` will be burned.
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { }
}

File 9 of 21 : IERC721.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool _approved) external;

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);

    /**
      * @dev Safely transfers `tokenId` token from `from` to `to`.
      *
      * Requirements:
      *
      * - `from` cannot be the zero address.
      * - `to` cannot be the zero address.
      * - `tokenId` token must exist and be owned by `from`.
      * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
      * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
      *
      * Emits a {Transfer} event.
      */
    function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
}

File 10 of 21 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @title ERC721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC721 asset contracts.
 */
interface IERC721Receiver {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
     *
     * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
     */
    function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4);
}

File 11 of 21 : ERC721Enumerable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../ERC721.sol";
import "./IERC721Enumerable.sol";

/**
 * @dev This implements an optional extension of {ERC721} defined in the EIP that adds
 * enumerability of all the token ids in the contract as well as all token ids owned by each
 * account.
 */
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
    // Mapping from owner to list of owned token IDs
    mapping(address => mapping(uint256 => uint256)) private _ownedTokens;

    // Mapping from token ID to index of the owner tokens list
    mapping(uint256 => uint256) private _ownedTokensIndex;

    // Array with all token ids, used for enumeration
    uint256[] private _allTokens;

    // Mapping from token id to position in the allTokens array
    mapping(uint256 => uint256) private _allTokensIndex;

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {
        return interfaceId == type(IERC721Enumerable).interfaceId
            || super.supportsInterface(interfaceId);
    }

    /**
     * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
        require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
        return _ownedTokens[owner][index];
    }

    /**
     * @dev See {IERC721Enumerable-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _allTokens.length;
    }

    /**
     * @dev See {IERC721Enumerable-tokenByIndex}.
     */
    function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
        require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds");
        return _allTokens[index];
    }

    /**
     * @dev Hook that is called before any token transfer. This includes minting
     * and burning.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
     * transferred to `to`.
     * - When `from` is zero, `tokenId` will be minted for `to`.
     * - When `to` is zero, ``from``'s `tokenId` will be burned.
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override {
        super._beforeTokenTransfer(from, to, tokenId);

        if (from == address(0)) {
            _addTokenToAllTokensEnumeration(tokenId);
        } else if (from != to) {
            _removeTokenFromOwnerEnumeration(from, tokenId);
        }
        if (to == address(0)) {
            _removeTokenFromAllTokensEnumeration(tokenId);
        } else if (to != from) {
            _addTokenToOwnerEnumeration(to, tokenId);
        }
    }

    /**
     * @dev Private function to add a token to this extension's ownership-tracking data structures.
     * @param to address representing the new owner of the given token ID
     * @param tokenId uint256 ID of the token to be added to the tokens list of the given address
     */
    function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
        uint256 length = ERC721.balanceOf(to);
        _ownedTokens[to][length] = tokenId;
        _ownedTokensIndex[tokenId] = length;
    }

    /**
     * @dev Private function to add a token to this extension's token tracking data structures.
     * @param tokenId uint256 ID of the token to be added to the tokens list
     */
    function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
        _allTokensIndex[tokenId] = _allTokens.length;
        _allTokens.push(tokenId);
    }

    /**
     * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
     * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
     * gas optimizations e.g. when performing a transfer operation (avoiding double writes).
     * This has O(1) time complexity, but alters the order of the _ownedTokens array.
     * @param from address representing the previous owner of the given token ID
     * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
     */
    function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
        // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;
        uint256 tokenIndex = _ownedTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary
        if (tokenIndex != lastTokenIndex) {
            uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];

            _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
            _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
        }

        // This also deletes the contents at the last position of the array
        delete _ownedTokensIndex[tokenId];
        delete _ownedTokens[from][lastTokenIndex];
    }

    /**
     * @dev Private function to remove a token from this extension's token tracking data structures.
     * This has O(1) time complexity, but alters the order of the _allTokens array.
     * @param tokenId uint256 ID of the token to be removed from the tokens list
     */
    function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
        // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = _allTokens.length - 1;
        uint256 tokenIndex = _allTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
        // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
        // an 'if' statement (like in _removeTokenFromOwnerEnumeration)
        uint256 lastTokenId = _allTokens[lastTokenIndex];

        _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
        _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index

        // This also deletes the contents at the last position of the array
        delete _allTokensIndex[tokenId];
        _allTokens.pop();
    }
}

File 12 of 21 : IERC721Enumerable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Enumerable is IERC721 {

    /**
     * @dev Returns the total amount of tokens stored by the contract.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.
     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);

    /**
     * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
     * Use along with {totalSupply} to enumerate all tokens.
     */
    function tokenByIndex(uint256 index) external view returns (uint256);
}

File 13 of 21 : IERC721Metadata.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Metadata is IERC721 {

    /**
     * @dev Returns the token collection name.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the token collection symbol.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
     */
    function tokenURI(uint256 tokenId) external view returns (string memory);
}

File 14 of 21 : ERC721Holder.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC721Receiver.sol";

  /**
   * @dev Implementation of the {IERC721Receiver} interface.
   *
   * Accepts all token transfers.
   * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}.
   */
contract ERC721Holder is IERC721Receiver {

    /**
     * @dev See {IERC721Receiver-onERC721Received}.
     *
     * Always returns `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(address, address, uint256, bytes memory) public virtual override returns (bytes4) {
        return this.onERC721Received.selector;
    }
}

File 15 of 21 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly { size := extcodesize(account) }
        return size > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (bool success, ) = recipient.call{ value: amount }("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain`call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
      return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: value }(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.staticcall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 16 of 21 : Context.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/*
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}

File 17 of 21 : Strings.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant alphabet = "0123456789abcdef";

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = alphabet[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

}

File 18 of 21 : ERC165.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

File 19 of 21 : IERC165.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 20 of 21 : SafeMath.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler
 * now has built in overflow checking.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        return a + b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        return a * b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        unchecked {
            require(b <= a, errorMessage);
            return a - b;
        }
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a / b;
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a % b;
        }
    }
}

File 21 of 21 : EnumerableSet.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;

        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping (bytes32 => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) { // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
            // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.

            bytes32 lastvalue = set._values[lastIndex];

            // Move the last value to the index where the value to delete is
            set._values[toDeleteIndex] = lastvalue;
            // Update the index for the moved value
            set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        require(set._values.length > index, "EnumerableSet: index out of bounds");
        return set._values[index];
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }


    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }
}

Settings
{
  "remappings": [],
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "evmVersion": "istanbul",
  "libraries": {},
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "abi"
      ]
    }
  }
}

Contract ABI

[{"inputs":[{"internalType":"contract BeastNFT","name":"n","type":"address"},{"internalType":"contract IERC20","name":"g","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"components":[{"internalType":"address","name":"attacker","type":"address"},{"internalType":"uint8","name":"healthA1","type":"uint8"},{"internalType":"uint8","name":"healthA2","type":"uint8"},{"internalType":"uint8","name":"healthA3","type":"uint8"},{"internalType":"address","name":"defender","type":"address"},{"internalType":"uint8","name":"healthD1","type":"uint8"},{"internalType":"uint8","name":"healthD2","type":"uint8"},{"internalType":"uint8","name":"healthD3","type":"uint8"},{"internalType":"uint16[]","name":"kicks","type":"uint16[]"},{"internalType":"uint256","name":"money","type":"uint256"},{"internalType":"bool","name":"win","type":"bool"}],"indexed":false,"internalType":"struct Arena.Log","name":"log","type":"tuple"}],"name":"Fight","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[{"internalType":"uint256","name":"nftId1","type":"uint256"},{"internalType":"uint256","name":"nftId2","type":"uint256"},{"internalType":"uint256","name":"nftId3","type":"uint256"}],"name":"addMonsters","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"addTrusted","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"}],"name":"allFighters","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"defenceFor","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"endFightBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"enemy","type":"address"}],"name":"fight","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"fightNumber","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"fightersIndexer","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gen","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getFighterInfo","outputs":[{"components":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"seed1","type":"uint256"},{"internalType":"uint8","name":"health1","type":"uint8"},{"internalType":"uint256","name":"seed2","type":"uint256"},{"internalType":"uint8","name":"health2","type":"uint8"},{"internalType":"uint256","name":"seed3","type":"uint256"},{"internalType":"uint8","name":"health3","type":"uint8"},{"internalType":"uint256","name":"coins","type":"uint256"},{"internalType":"uint256","name":"name","type":"uint256"},{"internalType":"uint8","name":"fights","type":"uint8"}],"internalType":"struct Arena.FighterInfo","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getFightersInfo","outputs":[{"components":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"seed1","type":"uint256"},{"internalType":"uint8","name":"health1","type":"uint8"},{"internalType":"uint256","name":"seed2","type":"uint256"},{"internalType":"uint8","name":"health2","type":"uint8"},{"internalType":"uint256","name":"seed3","type":"uint256"},{"internalType":"uint8","name":"health3","type":"uint8"},{"internalType":"uint256","name":"coins","type":"uint256"},{"internalType":"uint256","name":"name","type":"uint256"},{"internalType":"uint8","name":"fights","type":"uint8"}],"internalType":"struct Arena.FighterInfo[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getState","outputs":[{"internalType":"enum Arena.State","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"health","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"leave","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"maxLevel","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxTeam","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minLevel","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"money","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"moneyFor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nft","outputs":[{"internalType":"contract BeastNFT","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pool","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"removeTrusted","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"revive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"blocks","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"start","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"startFightBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"startPreparingBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"strengthFor","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"teams","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"team","type":"uint256[]"}],"name":"totalHealth","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"min","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"name":"updateMinMax","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"usersCount","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"usersLimit","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdrawAll","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60806040526005805460ff60a01b1916600360a01b1790556007805463ffffffff1916621e0000179055600160085560036009553480156200004057600080fd5b5060405162004560380380620045608339810160408190526200006391620000ef565b60006200006f620000eb565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a350600480546001600160a01b039384166001600160a01b0319918216179091556005805492909316911617905562000146565b3390565b6000806040838503121562000102578182fd5b82516200010f816200012d565b602084015190925062000122816200012d565b809150509250929050565b6001600160a01b03811681146200014357600080fd5b50565b61440a80620001566000396000f3fe608060405234801561001057600080fd5b50600436106102275760003560e01c80638fb4b57311610130578063c7672e4f116100b8578063d55e62a01161007c578063d55e62a014610444578063d66d9e1914610457578063dc48384c1461045f578063f0ee1cc414610472578063f2fde38b1461048557610227565b8063c7672e4f146103fb578063cc06c35914610403578063d0d05c9c1461040b578063d1f3e67f1461041e578063d4d0d6e61461043157610227565b806396fe4288116100ff57806396fe4288146103bb578063af156f0e146103c3578063b42dfa0d146103cb578063bdf0983d146103d3578063bf03a575146103f357610227565b80638fb4b5731461038557806395851a651461039857806395c71157146103a05780639604e42e146103a857610227565b80635b6887c7116101b3578063715018a611610182578063715018a6146103475780637621724e1461034f578063783b6d6014610362578063853828b6146103755780638da5cb5b1461037d57610227565b80635b6887c7146102f7578063644b375e1461030a578063678774741461031d5780636ba13a821461033257610227565b8063188a1353116101fa578063188a1353146102925780633bbd391e146102b257806347ccca02146102c75780634ae3b576146102dc5780634d4ca7d4146102e457610227565b8063150b7a021461022c57806315e1f7cd1461025557806316f0115b146102755780631865c57d1461027d575b600080fd5b61023f61023a36600461385b565b610498565b60405161024c9190613d24565b60405180910390f35b610268610263366004613823565b6104a8565b60405161024c9190614123565b6102686104ba565b6102856104c0565b60405161024c9190613d39565b6102a56102a0366004613823565b6104ed565b60405161024c919061413d565b6102c56102c0366004613b3d565b610502565b005b6102cf610555565b60405161024c9190613c84565b610268610564565b6102a56102f2366004613b0d565b61056a565b6102c5610305366004613b5e565b610692565b6102c5610318366004613823565b610f50565b61032561198b565b60405161024c9190613cd5565b61033a611a7d565b60405161024c9190614114565b6102c5611a87565b6102a561035d366004613b0d565b611b10565b6102a5610370366004613b0d565b611c2d565b6102c5611c42565b6102cf611d1c565b6102c5610393366004613b3d565b611d2b565b6102c5611db2565b6102a5612427565b6102a56103b6366004613a20565b612437565b610268612528565b61026861252e565b6102cf612534565b6103e66103e1366004613823565b612543565b60405161024c9190614021565b61033a612935565b610268612945565b61026861294b565b61033a610419366004613823565b612951565b6102cf61042c366004613aeb565b612967565b6102c561043f366004613823565b612982565b6102c5610452366004613823565b6129e5565b6102c5612a45565b61026861046d366004613823565b613102565b610268610480366004613917565b613156565b6102c5610493366004613823565b613187565b630a85bd0160e11b949350505050565b600d6020526000908152604090205481565b60065481565b60006002544310156104d4575060016104ea565b6003544311156104e6575060036104ea565b5060025b90565b600c6020526000908152604090205460ff1681565b61050a613247565b6001600160a01b031661051b611d1c565b6001600160a01b03161461054a5760405162461bcd60e51b815260040161054190613ef5565b60405180910390fd5b600891909155600955565b6004546001600160a01b031681565b60025481565b6004805460405163154edcb960e01b815260009283926001600160a01b03169163154edcb99161059c91879101614123565b60006040518083038186803b1580156105b457600080fd5b505afa1580156105c8573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526105f09190810190613942565b9050600560005b82518110156106885782818151811061062057634e487b7160e01b600052603260045260246000fd5b60200260200101516020015160400151600214156106765782818151811061065857634e487b7160e01b600052603260045260246000fd5b602002602001015160200151602001518261067391906141bf565b91505b806106808161432b565b9150506105f7565b509150505b919050565b600161069c6104c0565b60038111156106bb57634e487b7160e01b600052602160045260246000fd5b146106d85760405162461bcd60e51b815260040161054190613e9a565b600480546040516331a9108f60e11b815233926001600160a01b0390921691636352211e9161070991889101614123565b60206040518083038186803b15801561072157600080fd5b505afa158015610735573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610759919061383f565b6001600160a01b03161461077f5760405162461bcd60e51b815260040161054190613eca565b600480546040516331a9108f60e11b815233926001600160a01b0390921691636352211e916107b091879101614123565b60206040518083038186803b1580156107c857600080fd5b505afa1580156107dc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610800919061383f565b6001600160a01b0316146108265760405162461bcd60e51b815260040161054190613eca565b600480546040516331a9108f60e11b815233926001600160a01b0390921691636352211e9161085791869101614123565b60206040518083038186803b15801561086f57600080fd5b505afa158015610883573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108a7919061383f565b6001600160a01b0316146108cd5760405162461bcd60e51b815260040161054190613eca565b60048054604051632518058d60e01b81526000926001600160a01b0390921691632518058d916108ff91889101614123565b60206040518083038186803b15801561091757600080fd5b505afa15801561092b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061094f9190613b25565b60048054604051632518058d60e01b81529293506000926001600160a01b0390911691632518058d9161098491889101614123565b60206040518083038186803b15801561099c57600080fd5b505afa1580156109b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109d49190613b25565b60048054604051632518058d60e01b81529293506000926001600160a01b0390911691632518058d91610a0991889101614123565b60206040518083038186803b158015610a2157600080fd5b505afa158015610a35573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a599190613b25565b9050600854831015610a7d5760405162461bcd60e51b815260040161054190613f2a565b600854821015610a9f5760405162461bcd60e51b815260040161054190613f2a565b600854811015610ac15760405162461bcd60e51b815260040161054190613f2a565b600954831115610ae35760405162461bcd60e51b815260040161054190613f2a565b600954821115610b055760405162461bcd60e51b815260040161054190613f2a565b600954811115610b275760405162461bcd60e51b815260040161054190613f2a565b336000908152600a602052604090205415610b545760405162461bcd60e51b815260040161054190613eca565b60075461ffff6201000082048116911610610b815760405162461bcd60e51b815260040161054190613e4a565b336000908152600a60209081526040808320805460018082018355828652939094209384018a905580548084018255840189905580549283019055910185905560048054915163d6fafde560e01b81526001600160a01b039092169163d6fafde591610bef918a9101614123565b60606040518083038186803b158015610c0757600080fd5b505afa158015610c1b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c3f9190613ad0565b516000878152600b602052604090819020805460ff191660ff9093169290921790915560048054915163d6fafde560e01b81526001600160a01b039092169163d6fafde591610c9091899101614123565b60606040518083038186803b158015610ca857600080fd5b505afa158015610cbc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ce09190613ad0565b516000868152600b602052604090819020805460ff191660ff9093169290921790915560048054915163d6fafde560e01b81526001600160a01b039092169163d6fafde591610d3191889101614123565b60606040518083038186803b158015610d4957600080fd5b505afa158015610d5d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d819190613ad0565b516000858152600b60209081526040808320805460ff90951660ff19909516949094179093556007805461ffff9081168452600f835284842080546001600160a01b031916339081179091558254908552600e909352938320805461ffff19169285169290921790915580549092169190610dfb83614309565b825461ffff9182166101009390930a92830291909202199091161790555060048054604051632142170760e11b81526001600160a01b03909116916342842e0e91610e4c91339130918c9101613c98565b600060405180830381600087803b158015610e6657600080fd5b505af1158015610e7a573d6000803e3d6000fd5b505060048054604051632142170760e11b81526001600160a01b0390911693506342842e0e9250610eb191339130918b9101613c98565b600060405180830381600087803b158015610ecb57600080fd5b505af1158015610edf573d6000803e3d6000fd5b505060048054604051632142170760e11b81526001600160a01b0390911693506342842e0e9250610f1691339130918a9101613c98565b600060405180830381600087803b158015610f3057600080fd5b505af1158015610f44573d6000803e3d6000fd5b50505050505050505050565b6002610f5a6104c0565b6003811115610f7957634e487b7160e01b600052602160045260246000fd5b14610f965760405162461bcd60e51b815260040161054190613f4d565b336000908152600c6020526040902054600760ff90911610610fca5760405162461bcd60e51b815260040161054190613e20565b336000908152600a60209081526040808320805482518185028101850190935280835261102a9383018282801561102057602002820191906000526020600020905b81548152602001906001019080831161100c575b5050505050612437565b60ff161161104a5760405162461bcd60e51b815260040161054190613e6f565b6001600160a01b0381166000908152600a6020908152604080832080548251818502810185019093528083526110b193830182828015611020576020028201919060005260206000209081548152602001906001019080831161100c575050505050612437565b60ff16116110d15760405162461bcd60e51b815260040161054190613e6f565b6000620186a06110e26001436142a3565b6110ed91904061421d565b905060006111006402540be4008361421d565b60408051600680825260e0820190925291925060009182918291906020820160c08036833701905050905060005b60038160ff1610156113fc57336000908152600a602052604081208054600b91839160ff861690811061117157634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910154835282019290925260400190205460ff1611156112285760008160ff166111a883338b8b61324b565b6111b390600a614231565b6111bd9190614199565b90506111cb81612710614199565b836111d784600261427a565b60ff16815181106111f857634e487b7160e01b600052603260045260246000fd5b61ffff909216602092830291909101909101526112166064826141fc565b61122090866141d7565b94505061126e565b60008261123683600261427a565b60ff168151811061125757634e487b7160e01b600052603260045260246000fd5b602002602001019061ffff16908161ffff16815250505b61127a6103e88761421d565b95506000600b6000600a60008b6001600160a01b03166001600160a01b031681526020019081526020016000208460ff16815481106112c957634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910154835282019290925260400190205460ff16111561138b5760008160ff16611300838a338a61324b565b61130b90600a614231565b6113159190614199565b905061132381612710614199565b8361132f84600261427a565b61133a9060016141d7565b60ff168151811061135b57634e487b7160e01b600052603260045260246000fd5b61ffff909216602092830291909101909101526113796064826141fc565b61138390856141d7565b9350506113dc565b60008261139983600261427a565b6113a49060016141d7565b60ff16815181106113c557634e487b7160e01b600052603260045260246000fd5b602002602001019061ffff16908161ffff16815250505b6113e86103e88661421d565b9450806113f481614346565b91505061112e565b50336000908152600c60205260408120805460ff169161141b83614346565b91906101000a81548160ff021916908360ff16021790555050600061143f33613102565b9050600061144c88613102565b336000908152600a602090815260408083208054825181850281018501909352808352949550929384936114b493909190830182828015611020576020028201919060005260206000209081548152602001906001019080831161100c575050505050612437565b60ff16119050600080611537600a60008d6001600160a01b03166001600160a01b03168152602001908152602001600020805480602002602001604051908101604052809291908181526020018280548015611020576020028201919060005260206000209081548152602001906001019080831161100c575050505050612437565b60ff1611905060008083156115e6578760ff168960ff16101580611559575082155b156115e657606461156b86601e61425b565b611575919061421d565b9150606461158486601e61425b565b61158e919061421d565b61159890876141bf565b336000908152600d602052604090205560646115b586601e61425b565b6115bf919061421d565b6115c990866142a3565b6001600160a01b038d166000908152600d60205260409020555060015b8215611688578760ff168960ff1610806115fe575083155b1561168857606461161087601e61425b565b61161a919061421d565b9150606461162987601e61425b565b611633919061421d565b61163d90876142a3565b336000908152600d6020526040902055606461165a87601e61425b565b611664919061421d565b61166e90866141bf565b6001600160a01b038d166000908152600d60205260409020555b6001600160a01b038c166000908152600a60209081526040808320805482518185028101850190935280835291929091908301828280156116e857602002820191906000526020600020905b8154815260200190600101908083116116d4575b505050505090507fd482f73a7a77263cb58176e057e49f963f99b6bd36be0d0b3c9e7fe05d89c5e4604051806101600160405280336001600160a01b03168152602001600b6000600a6000336001600160a01b03166001600160a01b0316815260200190815260200160002060008154811061177457634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910154835282810193909352604091820181205460ff168452338152600a835290812080549390920192600b929060019081106117cc57634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910154835282810193909352604091820181205460ff168452338152600a835290812080549390920192600b9290600290811061182457634e487b7160e01b600052603260045260246000fd5b9060005260206000200154815260200190815260200160002060009054906101000a900460ff1660ff1681526020018f6001600160a01b03168152602001600b60008560008151811061188757634e487b7160e01b600052603260045260246000fd5b6020026020010151815260200190815260200160002060009054906101000a900460ff1660ff168152602001600b6000856001815181106118d857634e487b7160e01b600052603260045260246000fd5b6020026020010151815260200190815260200160002060009054906101000a900460ff1660ff168152602001600b60008560028151811061192957634e487b7160e01b600052603260045260246000fd5b6020026020010151815260200190815260200160002060009054906101000a900460ff1660ff1681526020018a81526020018581526020018415158152506040516119749190614030565b60405180910390a150505050505050505050505050565b60075460609060009061ffff1667ffffffffffffffff8111156119be57634e487b7160e01b600052604160045260246000fd5b6040519080825280602002602001820160405280156119f757816020015b6119e4613760565b8152602001906001900390816119dc5790505b50905060005b60075461ffff9081169082161015611a775761ffff81166000908152600f6020526040902054611a35906001600160a01b0316612543565b828261ffff1681518110611a5957634e487b7160e01b600052603260045260246000fd5b60200260200101819052508080611a6f90614309565b9150506119fd565b50905090565b60075461ffff1681565b611a8f613247565b6001600160a01b0316611aa0611d1c565b6001600160a01b031614611ac65760405162461bcd60e51b815260040161054190613ef5565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6004805460405163154edcb960e01b815260009283926001600160a01b03169163154edcb991611b4291879101614123565b60006040518083038186803b158015611b5a57600080fd5b505afa158015611b6e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611b969190810190613942565b90506000805b825181101561068857828181518110611bc557634e487b7160e01b600052603260045260246000fd5b6020026020010151602001516040015160031415611c1b57828181518110611bfd57634e487b7160e01b600052603260045260246000fd5b6020026020010151602001516020015182611c1891906141bf565b91505b80611c258161432b565b915050611b9c565b600b6020526000908152604090205460ff1681565b611c4a613247565b6001600160a01b0316611c5b611d1c565b6001600160a01b031614611c815760405162461bcd60e51b815260040161054190613ef5565b6005546040516370a0823160e01b8152611d1a9133916001600160a01b03909116906370a0823190611cb7903090600401613c84565b60206040518083038186803b158015611ccf57600080fd5b505afa158015611ce3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d079190613b25565b6005546001600160a01b0316919061355e565b565b6000546001600160a01b031690565b611d33613247565b6001600160a01b0316611d44611d1c565b6001600160a01b031614611d6a5760405162461bcd60e51b815260040161054190613ef5565b611d7482436141bf565b6001819055611d85906104b06141bf565b6002819055611d96906102586141bf565b600355611dab81670de0b6b3a764000061425b565b6006555050565b336000908152600a6020526040812080548290611ddf57634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910154338352600a909152604082208054919350906001908110611e1e57634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910154338352600a909152604082208054919350906002908110611e5d57634e487b7160e01b600052603260045260246000fd5b60009182526020822001549150808415612006576004805460405163d84b236160e01b81526001600160a01b039091169163d84b236191611ea091899101614123565b60206040518083038186803b158015611eb857600080fd5b505afa158015611ecc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ef09190613ab0565b6120065760048054604051632518058d60e01b81526001600160a01b0390911691632518058d91611f2391899101614123565b60206040518083038186803b158015611f3b57600080fd5b505afa158015611f4f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f739190613b25565b611f7d90826141bf565b60048054604051638baecc2160e01b81529293506001600160a01b031691638baecc2191611fad91899101614123565b600060405180830381600087803b158015611fc757600080fd5b505af1158015611fdb573d6000803e3d6000fd5b5050506000868152600b60205260409020805460ff19166001179055508161200281614346565b9250505b83156121a1576004805460405163d84b236160e01b81526001600160a01b039091169163d84b23619161203b91889101614123565b60206040518083038186803b15801561205357600080fd5b505afa158015612067573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061208b9190613ab0565b6121a15760048054604051632518058d60e01b81526001600160a01b0390911691632518058d916120be91889101614123565b60206040518083038186803b1580156120d657600080fd5b505afa1580156120ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061210e9190613b25565b61211890826141bf565b60048054604051638baecc2160e01b81529293506001600160a01b031691638baecc219161214891889101614123565b600060405180830381600087803b15801561216257600080fd5b505af1158015612176573d6000803e3d6000fd5b5050506000858152600b60205260409020805460ff19166001179055508161219d81614346565b9250505b821561233c576004805460405163d84b236160e01b81526001600160a01b039091169163d84b2361916121d691879101614123565b60206040518083038186803b1580156121ee57600080fd5b505afa158015612202573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122269190613ab0565b61233c5760048054604051632518058d60e01b81526001600160a01b0390911691632518058d9161225991879101614123565b60206040518083038186803b15801561227157600080fd5b505afa158015612285573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122a99190613b25565b6122b390826141bf565b60048054604051638baecc2160e01b81529293506001600160a01b031691638baecc21916122e391879101614123565b600060405180830381600087803b1580156122fd57600080fd5b505af1158015612311573d6000803e3d6000fd5b5050506000848152600b60205260409020805460ff19166001179055508161233881614346565b9250505b60008260ff161161235f5760405162461bcd60e51b815260040161054190613ffb565b8160ff166003141561237f57336000908152600d60205260409020600190555b6005546001600160a01b03166323b872dd333061239d85600361425b565b6123af90670de0b6b3a764000061425b565b6040518463ffffffff1660e01b81526004016123cd93929190613c98565b602060405180830381600087803b1580156123e757600080fd5b505af11580156123fb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061241f9190613ab0565b505050505050565b600554600160a01b900460ff1681565b6000600b60008360028151811061245e57634e487b7160e01b600052603260045260246000fd5b6020026020010151815260200190815260200160002060009054906101000a900460ff16600b6000846001815181106124a757634e487b7160e01b600052603260045260246000fd5b6020026020010151815260200190815260200160002060009054906101000a900460ff16600b6000856000815181106124f057634e487b7160e01b600052603260045260246000fd5b602090810291909101810151825281019190915260400160002054612518919060ff166141d7565b61252291906141d7565b92915050565b60085481565b60035481565b6005546001600160a01b031681565b61254b613760565b60408051610140810182526001600160a01b038085168083526004546000918252600a6020908152948220805494958601949190931692630c4e4ae59290916125a457634e487b7160e01b600052603260045260246000fd5b90600052602060002001546040518263ffffffff1660e01b81526004016125cb9190614123565b60206040518083038186803b1580156125e357600080fd5b505afa1580156125f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061261b9190613b25565b8152602001600b6000600a6000876001600160a01b03166001600160a01b0316815260200190815260200160002060008154811061266957634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910154835282810193909352604091820181205460ff1684526004546001600160a01b038881168352600a85529290912080549490930193911691630c4e4ae59160019081106126d457634e487b7160e01b600052603260045260246000fd5b90600052602060002001546040518263ffffffff1660e01b81526004016126fb9190614123565b60206040518083038186803b15801561271357600080fd5b505afa158015612727573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061274b9190613b25565b8152602001600b6000600a6000876001600160a01b03166001600160a01b0316815260200190815260200160002060018154811061279957634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910154835282810193909352604091820181205460ff1684526004546001600160a01b038881168352600a85529290912080549490930193911691630c4e4ae591600290811061280457634e487b7160e01b600052603260045260246000fd5b90600052602060002001546040518263ffffffff1660e01b815260040161282b9190614123565b60206040518083038186803b15801561284357600080fd5b505afa158015612857573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061287b9190613b25565b8152602001600b6000600a6000876001600160a01b03166001600160a01b031681526020019081526020016000206002815481106128c957634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910154835282810193909352604090910190205460ff168252016128f784613102565b81526001600160a01b0384166000818152600e602090815260408083205461ffff1682860152928252600c90528190205460ff169101529050919050565b60075462010000900461ffff1681565b60015481565b60095481565b600e6020526000908152604090205461ffff1681565b600f602052600090815260409020546001600160a01b031681565b61298a613247565b6001600160a01b031661299b611d1c565b6001600160a01b0316146129c15760405162461bcd60e51b815260040161054190613ef5565b6001600160a01b03166000908152601060205260409020805460ff19166001179055565b6129ed613247565b6001600160a01b03166129fe611d1c565b6001600160a01b031614612a245760405162461bcd60e51b815260040161054190613ef5565b6001600160a01b03166000908152601060205260409020805460ff19169055565b6003612a4f6104c0565b6003811115612a6e57634e487b7160e01b600052602160045260246000fd5b14612a8b5760405162461bcd60e51b815260040161054190613e9a565b336000908152600a6020526040812080548290612ab857634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910154338352600a909152604082208054919350906001908110612af757634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910154338352600a909152604082208054919350906002908110612b3657634e487b7160e01b600052603260045260246000fd5b600091825260208220015491508315612ce9576004805460405163d84b236160e01b81526001600160a01b039091169163d84b236191612b7891889101614123565b60206040518083038186803b158015612b9057600080fd5b505afa158015612ba4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bc89190613ab0565b15612caf5760048054336000908152600c60205260409081902054905163adcbf32960e01b81526001600160a01b039092169263adcbf32992612c1392899260ff909116910161412c565b600060405180830381600087803b158015612c2d57600080fd5b505af1158015612c41573d6000803e3d6000fd5b505060048054604051632142170760e11b81526001600160a01b0390911693506342842e0e9250612c7891309133918a9101613c98565b600060405180830381600087803b158015612c9257600080fd5b505af1158015612ca6573d6000803e3d6000fd5b50505050600190505b336000908152600a6020526040812080548290612cdc57634e487b7160e01b600052603260045260246000fd5b6000918252602090912001555b8215612e92576004805460405163d84b236160e01b81526001600160a01b039091169163d84b236191612d1e91879101614123565b60206040518083038186803b158015612d3657600080fd5b505afa158015612d4a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d6e9190613ab0565b15612e555760048054336000908152600c60205260409081902054905163adcbf32960e01b81526001600160a01b039092169263adcbf32992612db992889260ff909116910161412c565b600060405180830381600087803b158015612dd357600080fd5b505af1158015612de7573d6000803e3d6000fd5b505060048054604051632142170760e11b81526001600160a01b0390911693506342842e0e9250612e1e9130913391899101613c98565b600060405180830381600087803b158015612e3857600080fd5b505af1158015612e4c573d6000803e3d6000fd5b50505050600190505b336000908152600a6020526040812080546001908110612e8557634e487b7160e01b600052603260045260246000fd5b6000918252602090912001555b811561303b576004805460405163d84b236160e01b81526001600160a01b039091169163d84b236191612ec791869101614123565b60206040518083038186803b158015612edf57600080fd5b505afa158015612ef3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f179190613ab0565b15612ffe5760048054336000908152600c60205260409081902054905163adcbf32960e01b81526001600160a01b039092169263adcbf32992612f6292879260ff909116910161412c565b600060405180830381600087803b158015612f7c57600080fd5b505af1158015612f90573d6000803e3d6000fd5b505060048054604051632142170760e11b81526001600160a01b0390911693506342842e0e9250612fc79130913391889101613c98565b600060405180830381600087803b158015612fe157600080fd5b505af1158015612ff5573d6000803e3d6000fd5b50505050600190505b336000908152600a602052604081208054600290811061302e57634e487b7160e01b600052603260045260246000fd5b6000918252602090912001555b806130585760405162461bcd60e51b815260040161054190613ffb565b336000908152600c602052604090205460ff16156130fc576005546001600160a01b031663a9059cbb3361308b81613102565b6040518363ffffffff1660e01b81526004016130a8929190613cbc565b602060405180830381600087803b1580156130c257600080fd5b505af11580156130d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130fa9190613ab0565b505b50505050565b6001600160a01b0381166000908152600d602052604081205461313a576007546006546131339161ffff169061421d565b905061068d565b506001600160a01b03166000908152600d602052604090205490565b600a602052816000526040600020818154811061317257600080fd5b90600052602060002001600091509150505481565b61318f613247565b6001600160a01b03166131a0611d1c565b6001600160a01b0316146131c65760405162461bcd60e51b815260040161054190613ef5565b6001600160a01b0381166131ec5760405162461bcd60e51b815260040161054190613d94565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b3390565b6001600160a01b0383166000908152600a60205260408120805482919060ff881690811061328957634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101546001600160a01b0387168352600a9091526040822080549193508891600b91849160ff85169081106132d957634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910154835282019290925260400190205460ff1661338c5760005b60038160ff16101561338a576001600160a01b0387166000908152600a602052604081208054600b91839160ff861690811061334b57634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910154835282019290925260400190205460ff1611156133785780915061338a565b8061338281614346565b9150506132ff565b505b6001600160a01b0386166000908152600a60205260408120805460ff84169081106133c757634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910154808352600b90915260409091205490915060ff168015613537576001600160a01b0388166000908152600a60205260409020805461343f919060ff861690811061342f57634e487b7160e01b600052603260045260246000fd5b9060005260206000200154611b10565b60ff1661344d600a89614366565b106135375761345b8561056a565b60ff1661346a6103e889614366565b6134749190614366565b61347f9060016141bf565b93508360ff168160ff1611156134be5761349984826142ba565b6000838152600b60205260409020805460ff191660ff92909216919091179055613537565b6000828152600b602052604090819020805460ff1916905560048054915163d29a002560e01b81526001600160a01b039092169163d29a00259161350491869101614123565b600060405180830381600087803b15801561351e57600080fd5b505af1158015613532573d6000803e3d6000fd5b505050505b8261354385600a61427a565b61354d91906141d7565b60ff169a9950505050505050505050565b6135b48363a9059cbb60e01b848460405160240161357d929190613cbc565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526135b9565b505050565b600061360e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166136489092919063ffffffff16565b8051909150156135b4578080602001905181019061362c9190613ab0565b6135b45760405162461bcd60e51b815260040161054190613fb1565b60606136578484600085613661565b90505b9392505050565b6060824710156136835760405162461bcd60e51b815260040161054190613dda565b61368c85613721565b6136a85760405162461bcd60e51b815260040161054190613f7a565b600080866001600160a01b031685876040516136c49190613c68565b60006040518083038185875af1925050503d8060008114613701576040519150601f19603f3d011682016040523d82523d6000602084013e613706565b606091505b5091509150613716828286613727565b979650505050505050565b3b151590565b6060831561373657508161365a565b8251156137465782518084602001fd5b8160405162461bcd60e51b81526004016105419190613d61565b60405180610140016040528060006001600160a01b0316815260200160008152602001600060ff16815260200160008152602001600060ff16815260200160008152602001600060ff1681526020016000815260200160008152602001600060ff1681525090565b6000606082840312156137d9578081fd5b6040516060810181811067ffffffffffffffff821117156137fc576137fc6143a6565b80604052508091508251815260208301516020820152604083015160408201525092915050565b600060208284031215613834578081fd5b813561365a816143bc565b600060208284031215613850578081fd5b815161365a816143bc565b60008060008060808587031215613870578283fd5b843561387b816143bc565b935060208581013561388c816143bc565b935060408601359250606086013567ffffffffffffffff808211156138af578384fd5b818801915088601f8301126138c2578384fd5b8135818111156138d4576138d46143a6565b6138e6601f8201601f1916850161414b565b915080825289848285010111156138fb578485fd5b8084840185840137810190920192909252939692955090935050565b60008060408385031215613929578182fd5b8235613934816143bc565b946020939093013593505050565b60006020808385031215613954578182fd5b825167ffffffffffffffff8082111561396b578384fd5b818501915085601f83011261397e578384fd5b815161399161398c82614175565b61414b565b818152848101908486016080808502870188018b10156139af578889fd5b8896505b84871015613a115780828c0312156139c9578889fd5b6040805181810181811089821117156139e4576139e46143a6565b8252835181526139f68d8b86016137c8565b818b01528552506001969096019592870192908101906139b3565b50909998505050505050505050565b60006020808385031215613a32578182fd5b823567ffffffffffffffff811115613a48578283fd5b8301601f81018513613a58578283fd5b8035613a6661398c82614175565b8181528381019083850185840285018601891015613a82578687fd5b8694505b83851015613aa4578035835260019490940193918501918501613a86565b50979650505050505050565b600060208284031215613ac1578081fd5b8151801515811461365a578182fd5b600060608284031215613ae1578081fd5b61365a83836137c8565b600060208284031215613afc578081fd5b813561ffff8116811461365a578182fd5b600060208284031215613b1e578081fd5b5035919050565b600060208284031215613b36578081fd5b5051919050565b60008060408385031215613b4f578182fd5b50508035926020909101359150565b600080600060608486031215613b72578081fd5b505081359360208301359350604090920135919050565b6001600160a01b03169052565b6000815180845260208085019450808401835b83811015613bc957815161ffff1687529582019590820190600101613ba9565b509495945050505050565b15159052565b613be5828251613b89565b602081015160208301526040810151613c016040840182613c61565b50606081015160608301526080810151613c1e6080840182613c61565b5060a081015160a083015260c0810151613c3b60c0840182613c61565b5060e081015160e0830152610100808201518184015250610120808201516130fc828501825b60ff169052565b60008251613c7a8184602087016142dd565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b6020808252825182820181905260009190848201906040850190845b81811015613d1857613d04838551613bda565b928401926101409290920191600101613cf1565b50909695505050505050565b6001600160e01b031991909116815260200190565b6020810160048310613d5b57634e487b7160e01b600052602160045260246000fd5b91905290565b6000602082528251806020840152613d808160408501602087016142dd565b601f01601f19169190910160400192915050565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b60208082526026908201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6040820152651c8818d85b1b60d21b606082015260800190565b60208082526010908201526f746f6f206d7563682061747461636b7360801b604082015260600190565b6020808252600b908201526a1d5cd95c9cc8131a5b5a5d60aa1b604082015260600190565b6020808252601190820152700b2deea40d0c2ecca406040d0cac2d8e8d607b1b604082015260600190565b60208082526016908201527510985d1d1b1948185b1c9958591e481cdd185c9d195960521b604082015260600190565b6020808252601190820152703cb7ba9030b932903737ba1037bbb732b960791b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b602080825260099082015268191bdb89dd08199a5d60ba1b604082015260600190565b60208082526013908201527210985d1d1b1948191a591b89dd081cdd185c9d606a1b604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b6020808252600c908201526b165bdd48185c99481919585960a21b604082015260600190565b61014081016125228284613bda565b600060208252614044602083018451613b89565b60208301516140566040840182613c61565b5060408301516140696060840182613c61565b50606083015161407c6080840182613c61565b50608083015161408f60a0840182613b89565b5060a08301516140a260c0840182613c61565b5060c08301516140b560e0840182613c61565b5060e08301516101006140ca81850183613c61565b8085015191505061016061012081818601526140ea610180860184613b96565b908601516101408681019190915286015190925061410a82860182613bd4565b5090949350505050565b61ffff91909116815260200190565b90815260200190565b91825260ff16602082015260400190565b60ff91909116815260200190565b60405181810167ffffffffffffffff8111828210171561416d5761416d6143a6565b604052919050565b600067ffffffffffffffff82111561418f5761418f6143a6565b5060209081020190565b600061ffff8083168185168083038211156141b6576141b661437a565b01949350505050565b600082198211156141d2576141d261437a565b500190565b600060ff821660ff84168060ff038211156141f4576141f461437a565b019392505050565b600061ffff8084168061421157614211614390565b92169190910492915050565b60008261422c5761422c614390565b500490565b600061ffff808316818516818304811182151516156142525761425261437a565b02949350505050565b60008160001904831182151516156142755761427561437a565b500290565b600060ff821660ff84168160ff048111821515161561429b5761429b61437a565b029392505050565b6000828210156142b5576142b561437a565b500390565b600060ff821660ff8416808210156142d4576142d461437a565b90039392505050565b60005b838110156142f85781810151838201526020016142e0565b838111156130fc5750506000910152565b600061ffff808316818114156143215761432161437a565b6001019392505050565b600060001982141561433f5761433f61437a565b5060010190565b600060ff821660ff81141561435d5761435d61437a565b60010192915050565b60008261437557614375614390565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146143d157600080fd5b5056fea2646970667358221220036c7681ed1b11d19fa850a082324d8b29c36b3e9effdfaa2c591ba42717ecbe64736f6c634300080000330000000000000000000000007df6ffa9f379788b5283ea8917af4e90890e50b1000000000000000000000000b0f2939a1c0e43683e5954c9fe142f7df9f8d967

Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.