contract Application is ERC721Tradable {
    uint256 public hardcap;
    address payable wallet;
    bool public locked;
    string constant public ipfshash = 'QmVX2DQxWNMUiTA5MXTCHUFS6mm55VqiJC1sUvaACs5HLW';

    constructor(address payable _wallet, address _proxyRegistryAddress)
        public
        ERC721Tradable("THEM Applications", "MAPPLY", _proxyRegistryAddress)
    {
        wallet = _wallet;
        locked = true;
        hardcap = 69;
    }

    /**
     * Buy a token and mint it in the process. (Only 1 - 69).
     * @param _to address of the future owner of the token
     */
    function buy(address _to) external payable {
        uint256 payed = msg.value;
        uint256 price = currentPrice();
        
        require(!locked, 'Buying is not unlocked yet.');
        require(balanceOf(_to) == 0, 'Only one application per address.');
        require(totalSupply() < hardcap, 'Sold out!');
        require(price <= payed, 'Price must be equal or larger to the sales price.');

        _mintToInternal(_to);
        wallet.transfer(msg.value);
    }

    /**
     * First one costs 0.01 ETH, last one costs ~0.1 ETH.
     */
    function currentPrice() public view returns (uint256 price) {
        return (0.01 ether) + (totalSupply() * (0.00131 ether)); 
    }

    function changeWallet(address payable _newWallet) public onlyOwner {
        wallet = _newWallet;
    }

    /**
     * Irreversably unlock buying.
     */
    function unlock() public onlyOwner {
        locked = false;
    }

    function baseTokenURI() public pure returns (string memory) {
        return "https://api.them.af/api/application/";
    }

    function contractURI() public pure returns (string memory) {
        return "https://api.them.af/api/contracts/application";
    }
}
/**
 * @title Application
 * Application - a contract for non-fungible Applications.
 */
function currentPrice() public view returns (uint256 price) {
    return (0.01 ether) + (totalSupply() * (0.00131 ether)); 
}

/**
 * First one costs 0.01 ETH, last one costs ~0.1 ETH.
 */