Contract 0x63174FA9680C674a5580f7d747832B2a2133Ad8f 1

 
Txn Hash Method
Block
From
To
Value
0x4e03dc19e8e4e6f874c7111e7d5e3e70ea8a9f3a4788e81c594e463896b6bd35Set Approval For...132535152021-09-19 2:35:592 days 4 hrs ago0x21543a89d39730bc239623fd9a41bf379dc3f6f1 IN  0x63174fa9680c674a5580f7d747832b2a2133ad8f0 Ether0.00289705969 58.806830359
0xc564d800276b57bae8a766ff0f83e795791ef72b52c46ff539c982809d0bb844Set Sale Price132521972021-09-18 21:39:312 days 9 hrs agoENS Name james.lexdao.eth IN  0x63174fa9680c674a5580f7d747832b2a2133ad8f0 Ether0.002568416091 51.631643203
0x898224070c4eb57ac5ec620b9e7d82ac4e80729820ea6e0b4920bcb3ce2b1affSet Approval For...132383592021-09-16 18:19:434 days 13 hrs agoENS Name businessneeds.eth IN  0x63174fa9680c674a5580f7d747832b2a2133ad8f0 Ether0.004140635852 84.049932049
0x04136febe25d5d3f3cd7db4dbf3b6bb3daa967374a76729de9f89b56e2afcea5Set Approval For...132138812021-09-12 23:15:398 days 8 hrs ago0xe1c49beca9cf0489426f53e914f1d98987866ee1 IN  0x63174fa9680c674a5580f7d747832b2a2133ad8f0 Ether0.00334995268
0x3e8058d8c0351491fcb9ae73341b5ca52299245c61d1075dd52876bedd00cd6dSet Approval For...132078422021-09-12 1:06:149 days 6 hrs ago0x2b7cf1f0bb033bd970b7f77af937136ad5716206 IN  0x63174fa9680c674a5580f7d747832b2a2133ad8f0 Ether0.00306347043962.184768578
0x816a6ac39ef4cce8662969258cd59f76c71b8dbee299014fe4c2e1a51f22f8a5Create Proton Fo...132075922021-09-12 0:12:319 days 7 hrs ago0x2b7cf1f0bb033bd970b7f77af937136ad5716206 IN  0x63174fa9680c674a5580f7d747832b2a2133ad8f0 Ether0.01710292292649.909602971
0xb3d6356150d6dbdb4d79f35d22d1dbef32b316f57f810360f51c038fb910abb9Create Proton Fo...132050492021-09-11 14:42:409 days 16 hrs agoGitcoin Grants: Interaxis IN  0x63174fa9680c674a5580f7d747832b2a2133ad8f0 Ether0.017064355895 63.647083447
0xc9ce5c80b11562054ac6e43d8f9e33afe1cdfe93139792d1c7676307b71d1d59Create Proton Fo...131921002021-09-09 14:40:4611 days 16 hrs ago0x6c0b585429fa0cd9dbf6d87bb3e51dac85f42635 IN  0x63174fa9680c674a5580f7d747832b2a2133ad8f0 Ether0.03760903887 131.864839014
0x169a92500b191b4fb29467adc910525eb25dfb6b67b3e712b14fcd47a3f165d2Set Approval For...131874662021-09-08 21:13:1112 days 10 hrs ago0x13abc2a0fdb6b0155b2ef70b7ceb8425154d9f8b IN  0x63174fa9680c674a5580f7d747832b2a2133ad8f0 Ether0.008795515615 178.53839752
0x02b1cb19c47b37dcef8d7181c169c814f5b789a43fd33c3fe647a9ef4053a407Set Sale Price131873962021-09-08 20:56:3012 days 10 hrs ago0x13abc2a0fdb6b0155b2ef70b7ceb8425154d9f8b IN  0x63174fa9680c674a5580f7d747832b2a2133ad8f0 Ether0.014409516786 152.706274697
0xd218adb906441180998dc71bab3af29b7187b069a4b5f8aebf9b04d8b3f30856Create Proton Fo...131873752021-09-08 20:51:4212 days 10 hrs ago0x13abc2a0fdb6b0155b2ef70b7ceb8425154d9f8b IN  0x63174fa9680c674a5580f7d747832b2a2133ad8f0 Ether0.048759715692 142.280219236
0x021a6c8cfc6cf8dcac2c46504962f7b5e4cbed39cabd9287ec7c5c5185038405Create Proton Fo...131873592021-09-08 20:47:3612 days 10 hrs ago0x13abc2a0fdb6b0155b2ef70b7ceb8425154d9f8b IN  0x63174fa9680c674a5580f7d747832b2a2133ad8f0 Ether0.007663901925 163.061743087
0x4afb686671dd79431e33545da89d6a162654a6a44ba130c06306033d24c357e6Create Proton Fo...131851552021-09-08 12:40:4112 days 18 hrs ago0xcb24e0487cc832c11d292944eff1e4928360322f IN  0x63174fa9680c674a5580f7d747832b2a2133ad8f0 Ether0.032667435613 100.333043439
0x592153439100c794eb5eb0df6c8cb54a9cd48483431618826153a5d70299d2cfCreate Proton Fo...131808772021-09-07 20:42:1613 days 10 hrs agoENS Name itsmango.eth IN  0x63174fa9680c674a5580f7d747832b2a2133ad8f0 Ether0.034743199698 106.704503347
0x20cc175912c8c78b7eb7262a6bac201764973d858f395bcb1f37aaf4326d15daTransfer From131771452021-09-07 6:53:5914 days 27 mins ago0xcae8cd58f1df6163f0c3f04c55dd3b3391e1e2ce IN  0x63174fa9680c674a5580f7d747832b2a2133ad8f0 Ether0.0132747351106.9
0x46dc04ad8d6d0822fbe34282c12ef0ec49296d2dcbf7ecd6ea33bf3419b5bcb7Transfer From131605262021-09-04 17:20:3516 days 14 hrs ago0xdf4f2bf9461b623dfde4e888da2bf3caee50e22e IN  0x63174fa9680c674a5580f7d747832b2a2133ad8f0 Ether0.024766560564 231.292415553
0xc6e2c0faec976a2fb5f296ddcaa7f633a18624df211ea70b91fe17e9ea102a23Create Proton Fo...131591062021-09-04 12:10:2216 days 19 hrs ago0xd0a067af1111e8499a2635b5ce445f239c9aba29 IN  0x63174fa9680c674a5580f7d747832b2a2133ad8f0 Ether0.027964059114 81.598762525
0x9430a2323be6a9982348e8a6ece46f947ed4635662846a8240099facec448a4cCreate Proton Fo...131568712021-09-04 3:44:4417 days 3 hrs ago0xb4f111f55b99829d921ef31f31186b72942447fc IN  0x63174fa9680c674a5580f7d747832b2a2133ad8f0 Ether0.043932242512 128.193714985
0xca2d5b81a6b0512b8cb1b1e96913ef677a3377a0e8c0459e748d92b6fa299d67Create Proton Fo...131510092021-09-03 6:06:4818 days 1 hr agoMirror: Ellie Explains The World IN  0x63174fa9680c674a5580f7d747832b2a2133ad8f0 Ether0.024447520018 85.717912194
0x7f1018bf5213c84c00f7b5dcb0c78d552ff20054ca76c6d8b15f434f78d77162Safe Transfer Fr...131425742021-09-01 22:53:5019 days 8 hrs ago0xe83addbe930e1c242536717ff5d72df6e9264af1 IN  0x63174fa9680c674a5580f7d747832b2a2133ad8f0 Ether0.01310905288 99.387052827
0xd5ec2563e28fafc84689eacc890a9a94620e7cc3134f0304363a38c6e51ee4f7Create Proton Fo...131424742021-09-01 22:34:2919 days 8 hrs ago0xe83addbe930e1c242536717ff5d72df6e9264af1 IN  0x63174fa9680c674a5580f7d747832b2a2133ad8f0 Ether0.037104449079 138.393150099
0x2836ca7c92ebd2fd3d546ade9b08a22b79eedf4f54ff135914ff596075f21f35Safe Transfer Fr...131424532021-09-01 22:29:0019 days 8 hrs ago0x49ed1afe35b048c51e74f88985192d12693d2c10 IN  0x63174fa9680c674a5580f7d747832b2a2133ad8f0 Ether0.016098687338 133.497141923
0x43bf522f40050f7a05125dc4b8f3e8047af5b9e6f4c10dd831a529da0c8d3a10Create Proton Fo...131375842021-09-01 4:12:4620 days 3 hrs ago0xf0933b6251135eeb0042264323e4260d4e722f04 IN  0x63174fa9680c674a5580f7d747832b2a2133ad8f0 Ether0.021319764974 74.757665986
0xd618b293cb0673c6e47331c0679be78d527352c217bdf518e1525101e73cae90Set Sale Price131368292021-09-01 1:30:4920 days 5 hrs agoENS Name treyratcliff.eth IN  0x63174fa9680c674a5580f7d747832b2a2133ad8f0 Ether0.010540048444 111.684999357
0xec17fb1478055fd8c12f00a5cbd5c902787749c63409875f57bbeb7b72870151Transfer From131366962021-09-01 1:02:1620 days 6 hrs agoENS Name duckingwhimsical.eth IN  0x63174fa9680c674a5580f7d747832b2a2133ad8f0 Ether0.013784157762 114.937901914
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x1b893fb479bd4000ac9459d5188447835d9b20a958fa71305a2b097e4e40b4e9125565972021-06-02 18:07:44110 days 13 hrs ago 0x63174fa9680c674a5580f7d747832b2a2133ad8f0xf91ba1faf962b672a7ae12815afd2f432bc741860.5 Ether
0x4a75fab382dae4c15641b94aa0636c2950e78b4379c1d8594bc06c5a31c6d383125120202021-05-26 20:13:10117 days 11 hrs ago 0x63174fa9680c674a5580f7d747832b2a2133ad8f0x27b09d167d8ed88563d81ed766cbd280c8b434c51 Ether
0x46ffce738f13f6055eb6dd0bfbf886ed55395b771a52d5ccc57d7500c47b70d7124775352021-05-21 11:54:37122 days 19 hrs ago 0x63174fa9680c674a5580f7d747832b2a2133ad8f0xdf8eef2a68775db7fb3179e243231e06d7d751131 Ether
0x3c0677faa7928390e446ebbc6e06ef5b28536d4fd3d06c734d03fbb36e12531b123628872021-05-03 18:32:45140 days 12 hrs ago 0x63174fa9680c674a5580f7d747832b2a2133ad8fENS Name squigs.eth0.59 Ether
0x18b22aa96d6d2538b3cb531f3c04ecedc0b664fc7ea569ff19f9ce0a5baf4db1123600262021-05-03 8:07:50140 days 23 hrs ago 0x63174fa9680c674a5580f7d747832b2a2133ad8f0x03828b7129d49313b2cdc966e50369b75ec79a480.75 Ether
0x57ea2a2e0492f9a9dcdfba88e6b8cf190f768549f49e9832f7b5b867118231f6123511792021-05-01 22:59:15142 days 8 hrs ago 0x63174fa9680c674a5580f7d747832b2a2133ad8f0x520d9567cd51a1ff7babb9139ecc63d8923c32520.5 Ether
0x4c63ea823609d7ce18202afb6152f4b067a6a2766fb05396a3bc564b711e778c123511782021-05-01 22:59:14142 days 8 hrs ago 0x63174fa9680c674a5580f7d747832b2a2133ad8f0x520d9567cd51a1ff7babb9139ecc63d8923c32520.5 Ether
0x7a9c9ba399ffef6fcef9954aee9ae61110f8f0a14f1173aeb80afd11fc1291fe123511372021-05-01 22:51:08142 days 8 hrs ago 0x63174fa9680c674a5580f7d747832b2a2133ad8f0x520d9567cd51a1ff7babb9139ecc63d8923c32520.5 Ether
0x1273c5908d89a6788f7ea6328747a8911ff9ba056ddee999e864b6503fb7ece6123374112021-04-29 20:00:33144 days 11 hrs ago 0x63174fa9680c674a5580f7d747832b2a2133ad8f0xcb24e0487cc832c11d292944eff1e4928360322f42 Ether
0x1c80d63d78ec5b3ffaefb3bcb61237770dcce1981c11d746c68b927e93405d86122151472021-04-10 23:20:55163 days 8 hrs ago 0x63174fa9680c674a5580f7d747832b2a2133ad8f0x7d2498a05f2c6d6d53db8dfb5826e279012996eb5 Ether
0x2239e140ba8b9464a8825e94769353cc8771c453e1df7b535b96cb35f49f4b8a122123752021-04-10 13:16:44163 days 18 hrs ago 0x63174fa9680c674a5580f7d747832b2a2133ad8f0xdf8eef2a68775db7fb3179e243231e06d7d751131.3 Ether
0xb0d035ffd9609f35922ed3383d19ce123bf2ad72a208e75fd91732c913174ee4122090982021-04-10 1:07:25164 days 6 hrs ago 0x63174fa9680c674a5580f7d747832b2a2133ad8f0xdf8eef2a68775db7fb3179e243231e06d7d751131.3 Ether
0xa6d6e11c7ee5e4caf6fc7151cf30619dad5f0c4d6b77e7cc03c4bb06e1793565121998802021-04-08 15:07:40165 days 16 hrs ago 0x63174fa9680c674a5580f7d747832b2a2133ad8f0xbeae36aefd7ae78ac1d59981bd2969d84eb5430c0.75 Ether
0x99bc43377621a8abfa992fe7cdd198695e1f6ea12b9950778bbf267454708b25121997872021-04-08 14:48:58165 days 16 hrs ago 0x63174fa9680c674a5580f7d747832b2a2133ad8f0xcb24e0487cc832c11d292944eff1e4928360322f5 Ether
0xfd070c240ed9f48ed06d375f2bdd1af4bf0710c750dba03db501d2230c921864121929152021-04-07 13:19:23166 days 18 hrs ago 0x63174fa9680c674a5580f7d747832b2a2133ad8f0xdf8eef2a68775db7fb3179e243231e06d7d751130.3 Ether
0x0c4c4cad675214833e23ce863f78d9db62cc0b60c4e5aa6483f45a3804c96bd9121928502021-04-07 13:05:03166 days 18 hrs ago 0x63174fa9680c674a5580f7d747832b2a2133ad8f0xdf8eef2a68775db7fb3179e243231e06d7d751130.3 Ether
0x0a77bce97cb56b4425cd7427194e5fd11e8ffa31d986ff94906bd7c1d805fe18121928442021-04-07 13:03:35166 days 18 hrs ago 0x63174fa9680c674a5580f7d747832b2a2133ad8f0xdf8eef2a68775db7fb3179e243231e06d7d751130.3 Ether
0x5975a3c810510dd7abda896fe75d410ed8696aaa98b71f563ae0172e5d8434ec121928432021-04-07 13:03:29166 days 18 hrs ago 0x63174fa9680c674a5580f7d747832b2a2133ad8f0xdf8eef2a68775db7fb3179e243231e06d7d751130.3 Ether
0x054bb9d60dd6f15b8ed0a684476dae0cd9bf414f6da819f3c342d406b251e0bf121927962021-04-07 12:54:03166 days 18 hrs ago 0x63174fa9680c674a5580f7d747832b2a2133ad8f0xdf8eef2a68775db7fb3179e243231e06d7d751130.3 Ether
0x30a442e96a3242357bc35039771e0a41332f95af2eb1cd232a7410686b45ad6b121926072021-04-07 12:15:46166 days 19 hrs ago 0x63174fa9680c674a5580f7d747832b2a2133ad8f0xdf8eef2a68775db7fb3179e243231e06d7d751130.3 Ether
0x77746ccd46616ad2a5a007de9db6d3f420c346a99670bfa16f9de6ad4402b70c121925362021-04-07 12:01:24166 days 19 hrs ago 0x63174fa9680c674a5580f7d747832b2a2133ad8f0xdf8eef2a68775db7fb3179e243231e06d7d751130.3 Ether
0xe6840f885d24e313781a83888ff7a4cad2b27206cdeb94b81f19278593833cdf121863052021-04-06 12:59:13167 days 18 hrs ago 0x63174fa9680c674a5580f7d747832b2a2133ad8f0x37655d125c02f7ea23124ff8b30a6a4e2a63aa643 Ether
0x26e11f1999d2ce069c859f43b4d4949c207e53d5053f10c2d2cb707346b1890a121862982021-04-06 12:57:02167 days 18 hrs ago 0x63174fa9680c674a5580f7d747832b2a2133ad8f0xcfb539b7b1974fd1dc3cec1f639c6affe649e1e75 Ether
0xaeb994362859d94a9045bbfecbaae5e77fcd9aee74927e5449a7ed4a791bab05121644022021-04-03 4:11:25171 days 3 hrs ago 0x63174fa9680c674a5580f7d747832b2a2133ad8f0xac6be0f5dec557f243d3f0ca3a6d6452e24a172c0.5 Ether
0xeef74dc752f6dd9590e478f5fe3d1f9b9f2a946eb880d573f5b862ed4c63df45121631572021-04-02 23:46:13171 days 7 hrs ago 0x63174fa9680c674a5580f7d747832b2a2133ad8f0xac6be0f5dec557f243d3f0ca3a6d6452e24a172c0.75 Ether
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Proton

Compiler Version
v0.6.12+commit.27d51765

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 30 : Proton.sol
// SPDX-License-Identifier: MIT

// Proton.sol -- Part of the Charged Particles Protocol
// Copyright (c) 2021 Firma Lux, Inc. <https://charged.fi>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;

import "../lib/ERC721.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";

import "../interfaces/IProton.sol";
import "../interfaces/IUniverse.sol";
import "../interfaces/IChargedState.sol";
import "../interfaces/IChargedSettings.sol";
import "../interfaces/IChargedParticles.sol";

import "../lib/BlackholePrevention.sol";
import "../lib/RelayRecipient.sol";


contract Proton is IProton, ERC721, Ownable, RelayRecipient, ReentrancyGuard, BlackholePrevention {
  using SafeMath for uint256;
  using Address for address payable;
  using Counters for Counters.Counter;

  uint256 constant internal PERCENTAGE_SCALE = 1e4;   // 10000  (100%)
  uint256 constant internal MAX_ROYALTIES = 8e3;      // 8000   (80%)

  IUniverse internal _universe;
  IChargedState internal _chargedState;
  IChargedSettings internal _chargedSettings;
  IChargedParticles internal _chargedParticles;

  Counters.Counter internal _tokenIds;

  mapping (uint256 => address) internal _tokenCreator;
  mapping (uint256 => uint256) internal _tokenCreatorRoyaltiesPct;
  mapping (uint256 => address) internal _tokenCreatorRoyaltiesRedirect;
  mapping (address => uint256) internal _tokenCreatorClaimableRoyalties;

  mapping (uint256 => uint256) internal _tokenSalePrice;
  mapping (uint256 => uint256) internal _tokenLastSellPrice;

  bool internal _paused;


  /***********************************|
  |          Initialization           |
  |__________________________________*/

  constructor() public ERC721("Charged Particles - Proton", "PROTON") {}


  /***********************************|
  |              Public               |
  |__________________________________*/

  function creatorOf(uint256 tokenId) external view virtual override returns (address) {
    return _tokenCreator[tokenId];
  }

  function getSalePrice(uint256 tokenId) external view virtual override returns (uint256) {
    return _tokenSalePrice[tokenId];
  }

  function getLastSellPrice(uint256 tokenId) external view virtual override returns (uint256) {
    return _tokenLastSellPrice[tokenId];
  }

  function getCreatorRoyalties(address account) external view virtual override returns (uint256) {
    return _tokenCreatorClaimableRoyalties[account];
  }

  function getCreatorRoyaltiesPct(uint256 tokenId) external view virtual override returns (uint256) {
    return _tokenCreatorRoyaltiesPct[tokenId];
  }

  function getCreatorRoyaltiesReceiver(uint256 tokenId) external view virtual override returns (address) {
    return _creatorRoyaltiesReceiver(tokenId);
  }

  function claimCreatorRoyalties()
    external
    virtual
    override
    nonReentrant
    whenNotPaused
    returns (uint256)
  {
    return _claimCreatorRoyalties(_msgSender());
  }

  function createChargedParticle(
    address creator,
    address receiver,
    address referrer,
    string memory tokenMetaUri,
    string memory walletManagerId,
    address assetToken,
    uint256 assetAmount,
    uint256 annuityPercent
  )
    external
    virtual
    override
    nonReentrant
    whenNotPaused
    returns (uint256 newTokenId)
  {
    newTokenId = _createChargedParticle(
      creator,
      receiver,
      referrer,
      tokenMetaUri,
      walletManagerId,
      assetToken,
      assetAmount,
      annuityPercent
    );
  }

  function createBasicProton(
    address creator,
    address receiver,
    string memory tokenMetaUri
  )
    external
    virtual
    override
    whenNotPaused
    returns (uint256 newTokenId)
  {
    newTokenId = _createProton(
      creator,
      receiver,
      tokenMetaUri,
      0, // annuityPercent,
      0, // royaltiesPercent
      0  // salePrice
    );
  }

  function createProton(
    address creator,
    address receiver,
    string memory tokenMetaUri,
    uint256 annuityPercent
  )
    external
    virtual
    override
    whenNotPaused
    returns (uint256 newTokenId)
  {
    newTokenId = _createProton(
      creator,
      receiver,
      tokenMetaUri,
      annuityPercent,
      0, // royaltiesPercent
      0  // salePrice
    );
  }

  function createProtonForSale(
    address creator,
    address receiver,
    string memory tokenMetaUri,
    uint256 annuityPercent,
    uint256 royaltiesPercent,
    uint256 salePrice
  )
    external
    virtual
    override
    whenNotPaused
    returns (uint256 newTokenId)
  {
    newTokenId = _createProton(
      creator,
      receiver,
      tokenMetaUri,
      annuityPercent,
      royaltiesPercent,
      salePrice
    );
  }

  function batchProtonsForSale(
    address creator,
    uint256 annuityPercent,
    uint256 royaltiesPercent,
    string[] calldata tokenMetaUris,
    uint256[] calldata salePrices
  )
    external
    virtual
    override
    whenNotPaused
  {
    _batchProtonsForSale(
      creator,
      annuityPercent,
      royaltiesPercent,
      tokenMetaUris,
      salePrices
    );
  }

  function buyProton(uint256 tokenId)
    external
    payable
    virtual
    override
    nonReentrant
    whenNotPaused
    returns (bool)
  {
    return _buyProton(tokenId);
  }

  /***********************************|
  |     Only Token Creator/Owner      |
  |__________________________________*/

  function setSalePrice(uint256 tokenId, uint256 salePrice)
    external
    virtual
    override
    whenNotPaused
    onlyTokenOwnerOrApproved(tokenId)
  {
    _setSalePrice(tokenId, salePrice);
  }

  function setRoyaltiesPct(uint256 tokenId, uint256 royaltiesPct)
    external
    virtual
    override
    whenNotPaused
    onlyTokenCreator(tokenId)
    onlyTokenOwnerOrApproved(tokenId)
  {
    _setRoyaltiesPct(tokenId, royaltiesPct);
  }

  function setCreatorRoyaltiesReceiver(uint256 tokenId, address receiver)
    external
    virtual
    override
    whenNotPaused
    onlyTokenCreator(tokenId)
  {
    _tokenCreatorRoyaltiesRedirect[tokenId] = receiver;
  }


  /***********************************|
  |          Only Admin/DAO           |
  |__________________________________*/

  function setPausedState(bool state) external virtual onlyOwner {
    _paused = state;
    emit PausedStateSet(state);
  }

  /**
    * @dev Setup the ChargedParticles Interface
    */
  function setUniverse(address universe) external virtual onlyOwner {
    _universe = IUniverse(universe);
    emit UniverseSet(universe);
  }

  /**
    * @dev Setup the ChargedParticles Interface
    */
  function setChargedParticles(address chargedParticles) external virtual onlyOwner {
    _chargedParticles = IChargedParticles(chargedParticles);
    emit ChargedParticlesSet(chargedParticles);
  }

  /// @dev Setup the Charged-State Controller
  function setChargedState(address stateController) external virtual onlyOwner {
    _chargedState = IChargedState(stateController);
    emit ChargedStateSet(stateController);
  }

  /// @dev Setup the Charged-Settings Controller
  function setChargedSettings(address settings) external virtual onlyOwner {
    _chargedSettings = IChargedSettings(settings);
    emit ChargedSettingsSet(settings);
  }

  function setTrustedForwarder(address _trustedForwarder) external virtual onlyOwner {
    trustedForwarder = _trustedForwarder;
  }

  /***********************************|
  |          Only Admin/DAO           |
  |      (blackhole prevention)       |
  |__________________________________*/

  function withdrawEther(address payable receiver, uint256 amount) external onlyOwner {
    _withdrawEther(receiver, amount);
  }

  function withdrawErc20(address payable receiver, address tokenAddress, uint256 amount) external onlyOwner {
    _withdrawERC20(receiver, tokenAddress, amount);
  }

  function withdrawERC721(address payable receiver, address tokenAddress, uint256 tokenId) external onlyOwner {
    _withdrawERC721(receiver, tokenAddress, tokenId);
  }


  /***********************************|
  |         Private Functions         |
  |__________________________________*/

  function _setSalePrice(uint256 tokenId, uint256 salePrice) internal virtual {
    // Temp-Lock/Unlock NFT
    //  prevents front-running the sale and draining the value of the NFT just before sale
    _chargedState.setTemporaryLock(address(this), tokenId, (salePrice > 0));

    _tokenSalePrice[tokenId] = salePrice;
    emit SalePriceSet(tokenId, salePrice);
  }

  function _setRoyaltiesPct(uint256 tokenId, uint256 royaltiesPct) internal virtual {
    require(royaltiesPct <= MAX_ROYALTIES, "PRT:E-421");
    _tokenCreatorRoyaltiesPct[tokenId] = royaltiesPct;
    emit CreatorRoyaltiesSet(tokenId, royaltiesPct);
  }

  function _creatorRoyaltiesReceiver(uint256 tokenId) internal view virtual returns (address) {
    address receiver = _tokenCreatorRoyaltiesRedirect[tokenId];
    if (receiver == address(0x0)) {
      receiver = _tokenCreator[tokenId];
    }
    return receiver;
  }

  function _createChargedParticle(
    address creator,
    address receiver,
    address referrer,
    string memory tokenMetaUri,
    string memory walletManagerId,
    address assetToken,
    uint256 assetAmount,
    uint256 annuityPercent
  )
    internal
    virtual
    returns (uint256 newTokenId)
  {
    require(address(_chargedParticles) != address(0x0), "PRT:E-107");

    newTokenId = _createProton(creator, receiver, tokenMetaUri, annuityPercent, 0, 0);

    _chargeParticle(newTokenId, walletManagerId, assetToken, assetAmount, referrer);
  }

  function _createProton(
    address creator,
    address receiver,
    string memory tokenMetaUri,
    uint256 annuityPercent,
    uint256 royaltiesPercent,
    uint256 salePrice
  )
    internal
    virtual
    returns (uint256 newTokenId)
  {
    _tokenIds.increment();

    newTokenId = _tokenIds.current();
    _safeMint(receiver, newTokenId, "");
    _tokenCreator[newTokenId] = creator;

    _setTokenURI(newTokenId, tokenMetaUri);

    if (royaltiesPercent > 0) {
      _setRoyaltiesPct(newTokenId, royaltiesPercent);
    }

    if (salePrice > 0) {
      _setSalePrice(newTokenId, salePrice);
    }

    if (annuityPercent > 0) {
      _chargedSettings.setCreatorAnnuities(
        address(this),
        newTokenId,
        creator,
        annuityPercent
      );
    }
  }

  function _batchProtonsForSale(
    address creator,
    uint256 annuityPercent,
    uint256 royaltiesPercent,
    string[] calldata tokenMetaUris,
    uint256[] calldata salePrices
  )
    internal
    virtual
  {
    require(tokenMetaUris.length == salePrices.length, "PRT:E-202");
    address self = address(this);

    uint256 count = tokenMetaUris.length;
    for (uint256 i = 0; i < count; i++) {
      _tokenIds.increment();
      uint256 newTokenId = _tokenIds.current();

      _safeMint(creator, newTokenId, "");
      _tokenCreator[newTokenId] = creator;

      _setTokenURI(newTokenId, tokenMetaUris[i]);

      if (royaltiesPercent > 0) {
        _setRoyaltiesPct(newTokenId, royaltiesPercent);
      }

      uint256 salePrice = salePrices[i];
      if (salePrice > 0) {
        _setSalePrice(newTokenId, salePrice);
      }

      if (annuityPercent > 0) {
        _chargedSettings.setCreatorAnnuities(
          self,
          newTokenId,
          creator,
          annuityPercent
        );
      }
    }
  }

  function _chargeParticle(
    uint256 tokenId,
    string memory walletManagerId,
    address assetToken,
    uint256 assetAmount,
    address referrer
  )
    internal
    virtual
  {
    _collectAssetToken(_msgSender(), assetToken, assetAmount);

    IERC20(assetToken).approve(address(_chargedParticles), assetAmount);

    _chargedParticles.energizeParticle(
      address(this),
      tokenId,
      walletManagerId,
      assetToken,
      assetAmount,
      referrer
    );
  }

  function _buyProton(uint256 tokenId)
    internal
    virtual
    returns (bool)
  {
    uint256 salePrice = _tokenSalePrice[tokenId];
    require(salePrice > 0, "PRT:E-416");
    require(msg.value >= salePrice, "PRT:E-414");

    uint256 ownerAmount = salePrice;
    uint256 creatorAmount;
    address oldOwner = ownerOf(tokenId);
    address newOwner = _msgSender();

    // Creator Royalties
    address royaltiesReceiver = _creatorRoyaltiesReceiver(tokenId);
    uint256 royaltiesPct = _tokenCreatorRoyaltiesPct[tokenId];
    uint256 lastSellPrice = _tokenLastSellPrice[tokenId];
    if (royaltiesPct > 0 && lastSellPrice > 0 && salePrice > lastSellPrice) {
      creatorAmount = (salePrice - lastSellPrice).mul(royaltiesPct).div(PERCENTAGE_SCALE);
      ownerAmount = ownerAmount.sub(creatorAmount);
    }
    _tokenLastSellPrice[tokenId] = salePrice;

    // Signal to Universe Controller
    if (address(_universe) != address(0)) {
      _universe.onProtonSale(address(this), tokenId, oldOwner, newOwner, salePrice, royaltiesReceiver, creatorAmount);
    }

    // Unlock NFT
    _chargedState.setTemporaryLock(address(this), tokenId, false);

    // Reserve Royalties for Creator
    if (creatorAmount > 0) {
      _tokenCreatorClaimableRoyalties[royaltiesReceiver] = _tokenCreatorClaimableRoyalties[royaltiesReceiver].add(creatorAmount);
    }

    // Transfer Token
    _transfer(oldOwner, newOwner, tokenId);

    // Transfer Payment
    payable(oldOwner).sendValue(ownerAmount);

    emit ProtonSold(tokenId, oldOwner, newOwner, salePrice, royaltiesReceiver, creatorAmount);

    _refundOverpayment(salePrice);
    return true;
  }

  /**
    * @dev Pays out the Creator Royalties of the calling account
    * @param receiver  The receiver of the claimable royalties
    * @return          The amount of Creator Royalties claimed
    */
  function _claimCreatorRoyalties(address receiver) internal virtual returns (uint256) {
    uint256 claimableAmount = _tokenCreatorClaimableRoyalties[receiver];
    require(claimableAmount > 0, "PRT:E-411");

    delete _tokenCreatorClaimableRoyalties[receiver];
    payable(receiver).sendValue(claimableAmount);

    emit RoyaltiesClaimed(receiver, claimableAmount);
  }

  /**
    * @dev Collects the Required Asset Token from the users wallet
    * @param from         The owner address to collect the Assets from
    * @param assetAmount  The Amount of Asset Tokens to Collect
    */
  function _collectAssetToken(address from, address assetToken, uint256 assetAmount) internal virtual {
    uint256 _userAssetBalance = IERC20(assetToken).balanceOf(from);
    require(assetAmount <= _userAssetBalance, "PRT:E-411");
    // Be sure to Approve this Contract to transfer your Asset Token
    require(IERC20(assetToken).transferFrom(from, address(this), assetAmount), "PRT:E-401");
  }

  function _refundOverpayment(uint256 threshold) internal virtual {
    uint256 overage = msg.value.sub(threshold);
    if (overage > 0) {
      payable(_msgSender()).sendValue(overage);
    }
  }

  function _transfer(address from, address to, uint256 tokenId) internal virtual override {
    _tokenSalePrice[tokenId] = 0;
    _chargedState.setTemporaryLock(address(this), tokenId, false);
    super._transfer(from, to, tokenId);
  }


  /***********************************|
  |          GSN/MetaTx Relay         |
  |__________________________________*/

  /// @dev See {BaseRelayRecipient-_msgSender}.
  function _msgSender()
    internal
    view
    virtual
    override(BaseRelayRecipient, Context)
    returns (address payable)
  {
    return BaseRelayRecipient._msgSender();
  }

  /// @dev See {BaseRelayRecipient-_msgData}.
  function _msgData()
    internal
    view
    virtual
    override(BaseRelayRecipient, Context)
    returns (bytes memory)
  {
    return BaseRelayRecipient._msgData();
  }


  /***********************************|
  |             Modifiers             |
  |__________________________________*/

  modifier whenNotPaused() {
      require(!_paused, "PRT:E-101");
      _;
  }

  modifier onlyTokenOwnerOrApproved(uint256 tokenId) {
    require(_isApprovedOrOwner(_msgSender(), tokenId), "PRT:E-105");
    _;
  }

  modifier onlyTokenCreator(uint256 tokenId) {
    require(_tokenCreator[tokenId] == _msgSender(), "PRT:E-104");
    _;
  }
}

File 2 of 30 : ERC721.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import "@openzeppelin/contracts/GSN/Context.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Metadata.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import "@openzeppelin/contracts/introspection/ERC165.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/EnumerableSet.sol";
import "@openzeppelin/contracts/utils/EnumerableMap.sol";
import "@openzeppelin/contracts/utils/Strings.sol";

/**
 * @title ERC721 Non-Fungible Token Standard basic implementation
 * @dev see https://eips.ethereum.org/EIPS/eip-721
 */
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable {
    using SafeMath for uint256;
    using Address for address;
    using EnumerableSet for EnumerableSet.UintSet;
    using EnumerableMap for EnumerableMap.UintToAddressMap;
    using Strings for uint256;

    /**
     * @dev Emitted when `tokenId` token is transfered from `from` to `to`.
     */
    event TransferBatch(address indexed from, address indexed to, uint256 startTokenId, uint256 count);

    // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
    // which can be also obtained as `IERC721Receiver(0).onERC721Received.selector`
    bytes4 private constant _ERC721_RECEIVED = 0x150b7a02;

    // Mapping from holder address to their (enumerable) set of owned tokens
    mapping (address => EnumerableSet.UintSet) private _holderTokens;

    // Enumerable mapping from token ids to their owners
    EnumerableMap.UintToAddressMap private _tokenOwners;

    // 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;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    // Optional mapping for token URIs
    mapping(uint256 => string) private _tokenURIs;

    /*
     *     bytes4(keccak256('balanceOf(address)')) == 0x70a08231
     *     bytes4(keccak256('ownerOf(uint256)')) == 0x6352211e
     *     bytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3
     *     bytes4(keccak256('getApproved(uint256)')) == 0x081812fc
     *     bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465
     *     bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5
     *     bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872dd
     *     bytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0e
     *     bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde
     *
     *     => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^
     *        0xa22cb465 ^ 0xe985e9c ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd
     */
    bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd;

    /*
     *     bytes4(keccak256('name()')) == 0x06fdde03
     *     bytes4(keccak256('symbol()')) == 0x95d89b41
     *     bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd
     *
     *     => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f
     */
    bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f;

    /*
     *     bytes4(keccak256('totalSupply()')) == 0x18160ddd
     *     bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59
     *     bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7
     *
     *     => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63
     */
    bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63;

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

        // register the supported interfaces to conform to ERC721 via ERC165
        _registerInterface(_INTERFACE_ID_ERC721);
        _registerInterface(_INTERFACE_ID_ERC721_METADATA);
        _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE);
    }

    /**
     * @dev See {IERC721-balanceOf}.
     */
    function balanceOf(address owner) public view override returns (uint256) {
        require(owner != address(0), "ERC721:E-403");

        return _holderTokens[owner].length();
    }

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId) public view override returns (address) {
        return _tokenOwners.get(tokenId, "ERC721:E-405");
    }

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

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

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId) public view override returns (string memory) {
        require(_exists(tokenId), "ERC721:E-405");
        return _tokenURIs[tokenId];
    }

    /**
     * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) {
        return _holderTokens[owner].at(index);
    }

    /**
     * @dev See {IERC721Enumerable-totalSupply}.
     */
    function totalSupply() public view override returns (uint256) {
        // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds
        return _tokenOwners.length();
    }

    /**
     * @dev See {IERC721Enumerable-tokenByIndex}.
     */
    function tokenByIndex(uint256 index) public view override returns (uint256) {
        (uint256 tokenId, ) = _tokenOwners.at(index);
        return tokenId;
    }

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

        require(_msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721:E-105");

        _approve(to, tokenId);
    }

    /**
     * @dev See {IERC721-getApproved}.
     */
    function getApproved(uint256 tokenId) public view override returns (address) {
        require(_exists(tokenId), "ERC721:E-405");

        return _tokenApprovals[tokenId];
    }

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

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

    /**
     * @dev See {IERC721-isApprovedForAll}.
     */
    function isApprovedForAll(address owner, address operator) public view 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:E-105");

        _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:E-105");
        _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 mecanisms 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:E-402");
    }

    /**
     * @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 returns (bool) {
        return _tokenOwners.contains(tokenId);
    }

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

    /**
     * @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:E-402");
    }

    /**
     * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
     */
    function _safeMintBatch(address to, uint256 startTokenId, uint256 count, bytes memory _data) internal virtual {
        _mintBatch(to, startTokenId, count);
        require(_checkOnERC721Received(address(0), to, startTokenId, _data), "ERC721:E-402");
    }

    /**
     * @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:E-403");
        require(!_exists(tokenId), "ERC721:E-407");

        _holderTokens[to].add(tokenId);

        _tokenOwners.set(tokenId, to);

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

    /**
     * @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 _mintBatch(address to, uint256 startTokenId, uint256 count) internal virtual {
        require(to != address(0), "ERC721:E-403");
        require(!_exists(startTokenId), "ERC721:E-407");

        for (uint i = 0; i < count; i++) {
          uint256 tokenId = startTokenId.add(i);
          _holderTokens[to].add(tokenId);
          _tokenOwners.set(tokenId, to);
        }

        emit TransferBatch(address(0), to, startTokenId, count);
    }

    /**
     * @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(ownerOf(tokenId) == from, "ERC721:E-102");
        require(to != address(0), "ERC721:E-403");

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

        _holderTokens[from].remove(tokenId);
        _holderTokens[to].add(tokenId);

        _tokenOwners.set(tokenId, to);

        emit Transfer(from, to, tokenId);
    }

    /**
     * @dev Sets `_tokenURI` as the tokenURI of `tokenId`.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual {
        require(_exists(tokenId), "ERC721:E-405");
        _tokenURIs[tokenId] = _tokenURI;
    }

    /**
     * @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()) {
            return true;
        }
        bytes memory returndata = to.functionCall(abi.encodeWithSelector(
            IERC721Receiver(to).onERC721Received.selector,
            _msgSender(),
            from,
            tokenId,
            _data
        ), "ERC721:E-402");
        bytes4 retval = abi.decode(returndata, (bytes4));
        return (retval == _ERC721_RECEIVED);
    }

    function _approve(address to, uint256 tokenId) private {
        _tokenApprovals[tokenId] = to;
        emit Approval(ownerOf(tokenId), to, tokenId);
    }
}

File 3 of 30 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.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 4 of 30 : SafeMath.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @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) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }

    /**
     * @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 sub(a, b, "SafeMath: subtraction overflow");
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;

        return c;
    }

    /**
     * @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) {
        // 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 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * 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) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * 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) {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts 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 mod(a, b, "SafeMath: modulo by zero");
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
}

File 5 of 30 : Ownable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import "../GSN/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.
 */
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 () internal {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view 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 6 of 30 : Counters.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import "../math/SafeMath.sol";

/**
 * @title Counters
 * @author Matt Condon (@shrugs)
 * @dev Provides counters that can only be incremented or decremented by one. This can be used e.g. to track the number
 * of elements in a mapping, issuing ERC721 ids, or counting request ids.
 *
 * Include with `using Counters for Counters.Counter;`
 * Since it is not possible to overflow a 256 bit integer with increments of one, `increment` can skip the {SafeMath}
 * overflow check, thereby saving gas. This does assume however correct usage, in that the underlying `_value` is never
 * directly accessed.
 */
library Counters {
    using SafeMath for uint256;

    struct Counter {
        // This variable should never be directly accessed by users of the library: interactions must be restricted to
        // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
        // this feature: see https://github.com/ethereum/solidity/issues/4637
        uint256 _value; // default: 0
    }

    function current(Counter storage counter) internal view returns (uint256) {
        return counter._value;
    }

    function increment(Counter storage counter) internal {
        // The {SafeMath} overflow check can be skipped here, see the comment at the top
        counter._value += 1;
    }

    function decrement(Counter storage counter) internal {
        counter._value = counter._value.sub(1);
    }
}

File 7 of 30 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.2;

/**
 * @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) {
        // According to EIP-1052, 0x0 is the value returned for not-yet created accounts
        // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
        // for accounts without code, i.e. `keccak256('')`
        bytes32 codehash;
        bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
        // solhint-disable-next-line no-inline-assembly
        assembly { codehash := extcodehash(account) }
        return (codehash != accountHash && codehash != 0x0);
    }

    /**
     * @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");
        return _functionCallWithValue(target, data, value, errorMessage);
    }

    function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
        require(isContract(target), "Address: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
        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 8 of 30 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor () internal {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and make it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}

File 9 of 30 : IProton.sol
// SPDX-License-Identifier: MIT

// Proton.sol -- Part of the Charged Particles Protocol
// Copyright (c) 2021 Firma Lux, Inc. <https://charged.fi>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";

import "../interfaces/IUniverse.sol";
import "../interfaces/IChargedState.sol";
import "../interfaces/IChargedSettings.sol";
import "../interfaces/IChargedParticles.sol";

import "../lib/BlackholePrevention.sol";
import "../lib/RelayRecipient.sol";


interface IProton is IERC721 {
  event UniverseSet(address indexed universe);
  event ChargedStateSet(address indexed chargedState);
  event ChargedSettingsSet(address indexed chargedSettings);
  event ChargedParticlesSet(address indexed chargedParticles);
  event PausedStateSet(bool isPaused);
  event SalePriceSet(uint256 indexed tokenId, uint256 salePrice);
  event CreatorRoyaltiesSet(uint256 indexed tokenId, uint256 royaltiesPct);
  event FeesWithdrawn(address indexed receiver, uint256 amount);
  event ProtonSold(uint256 indexed tokenId, address indexed oldOwner, address indexed newOwner, uint256 salePrice, address creator, uint256 creatorRoyalties);
  event RoyaltiesClaimed(address indexed receiver, uint256 amountClaimed);

  /***********************************|
  |              Public               |
  |__________________________________*/

  function creatorOf(uint256 tokenId) external view returns (address);
  function getSalePrice(uint256 tokenId) external view returns (uint256);
  function getLastSellPrice(uint256 tokenId) external view returns (uint256);
  function getCreatorRoyalties(address account) external view returns (uint256);
  function getCreatorRoyaltiesPct(uint256 tokenId) external view returns (uint256);
  function getCreatorRoyaltiesReceiver(uint256 tokenId) external view returns (address);

  function buyProton(uint256 tokenId) external payable returns (bool);
  function claimCreatorRoyalties() external returns (uint256);

  function createChargedParticle(
    address creator,
    address receiver,
    address referrer,
    string memory tokenMetaUri,
    string memory walletManagerId,
    address assetToken,
    uint256 assetAmount,
    uint256 annuityPercent
  ) external returns (uint256 newTokenId);

  function createBasicProton(
    address creator,
    address receiver,
    string memory tokenMetaUri
  ) external returns (uint256 newTokenId);

  function createProton(
    address creator,
    address receiver,
    string memory tokenMetaUri,
    uint256 annuityPercent
  ) external returns (uint256 newTokenId);

  function createProtonForSale(
    address creator,
    address receiver,
    string memory tokenMetaUri,
    uint256 annuityPercent,
    uint256 royaltiesPercent,
    uint256 salePrice
  ) external returns (uint256 newTokenId);

  function batchProtonsForSale(
    address creator,
    uint256 annuityPercent,
    uint256 royaltiesPercent,
    string[] calldata tokenMetaUris,
    uint256[] calldata salePrices
  ) external;

  /***********************************|
  |     Only Token Creator/Owner      |
  |__________________________________*/

  function setSalePrice(uint256 tokenId, uint256 salePrice) external;
  function setRoyaltiesPct(uint256 tokenId, uint256 royaltiesPct) external;
  function setCreatorRoyaltiesReceiver(uint256 tokenId, address receiver) external;
}

File 10 of 30 : IUniverse.sol
// SPDX-License-Identifier: MIT

// IUniverse.sol -- Part of the Charged Particles Protocol
// Copyright (c) 2021 Firma Lux, Inc. <https://charged.fi>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

pragma solidity >=0.6.0;

/**
 * @title Universal Controller interface
 * @dev ...
 */
interface IUniverse {

  event ChargedParticlesSet(address indexed chargedParticles);
  event PhotonSet(address indexed photonToken, uint256 maxSupply);
  event ProtonTokenSet(address indexed protonToken);
  event LeptonTokenSet(address indexed leptonToken);
  event QuarkTokenSet(address indexed quarkToken);
  event BosonTokenSet(address indexed bosonToken);
  event EsaMultiplierSet(address indexed assetToken, uint256 multiplier);
  event ElectrostaticAttraction(address indexed account, address photonSource, uint256 energy, uint256 multiplier);
  event ElectrostaticDischarge(address indexed account, address photonSource, uint256 energy);

  function onEnergize(
    address sender,
    address referrer,
    address contractAddress,
    uint256 tokenId,
    string calldata managerId,
    address assetToken,
    uint256 assetEnergy
  ) external;

  function onDischarge(
    address contractAddress,
    uint256 tokenId,
    string calldata managerId,
    address assetToken,
    uint256 creatorEnergy,
    uint256 receiverEnergy
  ) external;

  function onDischargeForCreator(
    address contractAddress,
    uint256 tokenId,
    string calldata managerId,
    address creator,
    address assetToken,
    uint256 receiverEnergy
  ) external;

  function onRelease(
    address contractAddress,
    uint256 tokenId,
    string calldata managerId,
    address assetToken,
    uint256 principalEnergy,
    uint256 creatorEnergy,
    uint256 receiverEnergy
  ) external;

  function onCovalentBond(
    address contractAddress,
    uint256 tokenId,
    string calldata managerId,
    address nftTokenAddress,
    uint256 nftTokenId
  ) external;

  function onCovalentBreak(
    address contractAddress,
    uint256 tokenId,
    string calldata managerId,
    address nftTokenAddress,
    uint256 nftTokenId
  ) external;

  function onProtonSale(
    address contractAddress,
    uint256 tokenId,
    address oldOwner,
    address newOwner,
    uint256 salePrice,
    address creator,
    uint256 creatorRoyalties
  ) external;
}

File 11 of 30 : IChargedState.sol
// SPDX-License-Identifier: MIT

// IChargedSettings.sol -- Part of the Charged Particles Protocol
// Copyright (c) 2021 Firma Lux, Inc. <https://charged.fi>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

pragma solidity >=0.6.0;

import "./IChargedSettings.sol";

/**
 * @notice Interface for Charged State
 */
interface IChargedState {

  /***********************************|
  |             Public API            |
  |__________________________________*/

  function getDischargeTimelockExpiry(address contractAddress, uint256 tokenId) external view returns (uint256 lockExpiry);
  function getReleaseTimelockExpiry(address contractAddress, uint256 tokenId) external view returns (uint256 lockExpiry);
  function getBreakBondTimelockExpiry(address contractAddress, uint256 tokenId) external view returns (uint256 lockExpiry);

  function isApprovedForDischarge(address contractAddress, uint256 tokenId, address operator) external view returns (bool);
  function isApprovedForRelease(address contractAddress, uint256 tokenId, address operator) external view returns (bool);
  function isApprovedForBreakBond(address contractAddress, uint256 tokenId, address operator) external view returns (bool);
  function isApprovedForTimelock(address contractAddress, uint256 tokenId, address operator) external view returns (bool);

  function isEnergizeRestricted(address contractAddress, uint256 tokenId) external view returns (bool);
  function isCovalentBondRestricted(address contractAddress, uint256 tokenId) external view returns (bool);

  function getDischargeState(address contractAddress, uint256 tokenId, address sender) external view
    returns (bool allowFromAll, bool isApproved, uint256 timelock, uint256 tempLockExpiry);
  function getReleaseState(address contractAddress, uint256 tokenId, address sender) external view
    returns (bool allowFromAll, bool isApproved, uint256 timelock, uint256 tempLockExpiry);
  function getBreakBondState(address contractAddress, uint256 tokenId, address sender) external view
    returns (bool allowFromAll, bool isApproved, uint256 timelock, uint256 tempLockExpiry);

  /***********************************|
  |      Only NFT Owner/Operator      |
  |__________________________________*/

  function setDischargeApproval(address contractAddress, uint256 tokenId, address operator) external;
  function setReleaseApproval(address contractAddress, uint256 tokenId, address operator) external;
  function setBreakBondApproval(address contractAddress, uint256 tokenId, address operator) external;
  function setTimelockApproval(address contractAddress, uint256 tokenId, address operator) external;
  function setApprovalForAll(address contractAddress, uint256 tokenId, address operator) external;

  function setPermsForRestrictCharge(address contractAddress, uint256 tokenId, bool state) external;
  function setPermsForAllowDischarge(address contractAddress, uint256 tokenId, bool state) external;
  function setPermsForAllowRelease(address contractAddress, uint256 tokenId, bool state) external;
  function setPermsForRestrictBond(address contractAddress, uint256 tokenId, bool state) external;
  function setPermsForAllowBreakBond(address contractAddress, uint256 tokenId, bool state) external;

  function setDischargeTimelock(
    address contractAddress,
    uint256 tokenId,
    uint256 unlockBlock
  ) external;

  function setReleaseTimelock(
    address contractAddress,
    uint256 tokenId,
    uint256 unlockBlock
  ) external;

  function setBreakBondTimelock(
    address contractAddress,
    uint256 tokenId,
    uint256 unlockBlock
  ) external;

  /***********************************|
  |         Only NFT Contract         |
  |__________________________________*/

  function setTemporaryLock(
    address contractAddress,
    uint256 tokenId,
    bool isLocked
  ) external;

  /***********************************|
  |          Particle Events          |
  |__________________________________*/

  event ChargedSettingsSet(address indexed settingsController);

  event DischargeApproval(address indexed contractAddress, uint256 indexed tokenId, address indexed owner, address operator);
  event ReleaseApproval(address indexed contractAddress, uint256 indexed tokenId, address indexed owner, address operator);
  event BreakBondApproval(address indexed contractAddress, uint256 indexed tokenId, address indexed owner, address operator);
  event TimelockApproval(address indexed contractAddress, uint256 indexed tokenId, address indexed owner, address operator);

  event TokenDischargeTimelock(address indexed contractAddress, uint256 indexed tokenId, address indexed operator, uint256 unlockBlock);
  event TokenReleaseTimelock(address indexed contractAddress, uint256 indexed tokenId, address indexed operator, uint256 unlockBlock);
  event TokenBreakBondTimelock(address indexed contractAddress, uint256 indexed tokenId, address indexed operator, uint256 unlockBlock);
  event TokenTempLock(address indexed contractAddress, uint256 indexed tokenId, uint256 unlockBlock);

  event PermsSetForRestrictCharge(address indexed contractAddress, uint256 indexed tokenId, bool state);
  event PermsSetForAllowDischarge(address indexed contractAddress, uint256 indexed tokenId, bool state);
  event PermsSetForAllowRelease(address indexed contractAddress, uint256 indexed tokenId, bool state);
  event PermsSetForRestrictBond(address indexed contractAddress, uint256 indexed tokenId, bool state);
  event PermsSetForAllowBreakBond(address indexed contractAddress, uint256 indexed tokenId, bool state);
}

File 12 of 30 : IChargedSettings.sol
// SPDX-License-Identifier: MIT

// IChargedSettings.sol -- Part of the Charged Particles Protocol
// Copyright (c) 2021 Firma Lux, Inc. <https://charged.fi>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

pragma solidity >=0.6.0;

import "./IWalletManager.sol";
import "./IBasketManager.sol";

/**
 * @notice Interface for Charged Settings
 */
interface IChargedSettings {

  /***********************************|
  |             Public API            |
  |__________________________________*/

  function isContractOwner(address contractAddress, address account) external view returns (bool);
  function getCreatorAnnuities(address contractAddress, uint256 tokenId) external view returns (address creator, uint256 annuityPct);
  function getCreatorAnnuitiesRedirect(address contractAddress, uint256 tokenId) external view returns (address);
  function getTempLockExpiryBlocks() external view returns (uint256);
  function getTimelockApprovals(address operator) external view returns (bool timelockAny, bool timelockOwn);
  function getAssetRequirements(address contractAddress, address assetToken) external view
    returns (string memory requiredWalletManager, bool energizeEnabled, bool restrictedAssets, bool validAsset, uint256 depositCap, uint256 depositMin, uint256 depositMax);
  function getNftAssetRequirements(address contractAddress, address nftTokenAddress) external view
    returns (string memory requiredBasketManager, bool basketEnabled, uint256 maxNfts);

  // ERC20
  function isWalletManagerEnabled(string calldata walletManagerId) external view returns (bool);
  function getWalletManager(string calldata walletManagerId) external view returns (IWalletManager);

  // ERC721
  function isNftBasketEnabled(string calldata basketId) external view returns (bool);
  function getBasketManager(string calldata basketId) external view returns (IBasketManager);

  /***********************************|
  |         Only NFT Creator          |
  |__________________________________*/

  function setCreatorAnnuities(address contractAddress, uint256 tokenId, address creator, uint256 annuityPercent) external;
  function setCreatorAnnuitiesRedirect(address contractAddress, uint256 tokenId, address creator, address receiver) external;


  /***********************************|
  |      Only NFT Contract Owner      |
  |__________________________________*/

  function setRequiredWalletManager(address contractAddress, string calldata walletManager) external;
  function setRequiredBasketManager(address contractAddress, string calldata basketManager) external;
  function setAssetTokenRestrictions(address contractAddress, bool restrictionsEnabled) external;
  function setAllowedAssetToken(address contractAddress, address assetToken, bool isAllowed) external;
  function setAssetTokenLimits(address contractAddress, address assetToken, uint256 depositMin, uint256 depositMax) external;
  function setMaxNfts(address contractAddress, address nftTokenAddress, uint256 maxNfts) external;

  /***********************************|
  |          Only Admin/DAO           |
  |__________________________________*/

  function enableNftContracts(address[] calldata contracts) external;
  function setPermsForCharge(address contractAddress, bool state) external;
  function setPermsForBasket(address contractAddress, bool state) external;
  function setPermsForTimelockAny(address contractAddress, bool state) external;
  function setPermsForTimelockSelf(address contractAddress, bool state) external;

  /***********************************|
  |          Particle Events          |
  |__________________________________*/

  event DepositCapSet(address assetToken, uint256 depositCap);
  event TempLockExpirySet(uint256 expiryBlocks);

  event WalletManagerRegistered(string indexed walletManagerId, address indexed walletManager);
  event BasketManagerRegistered(string indexed basketId, address indexed basketManager);

  event RequiredWalletManagerSet(address indexed contractAddress, string walletManager);
  event RequiredBasketManagerSet(address indexed contractAddress, string basketManager);
  event AssetTokenRestrictionsSet(address indexed contractAddress, bool restrictionsEnabled);
  event AllowedAssetTokenSet(address indexed contractAddress, address assetToken, bool isAllowed);
  event AssetTokenLimitsSet(address indexed contractAddress, address assetToken, uint256 assetDepositMin, uint256 assetDepositMax);
  event MaxNftsSet(address indexed contractAddress, address indexed nftTokenAddress, uint256 maxNfts);

  event TokenCreatorConfigsSet(address indexed contractAddress, uint256 indexed tokenId, address indexed creatorAddress, uint256 annuityPercent);
  event TokenCreatorAnnuitiesRedirected(address indexed contractAddress, uint256 indexed tokenId, address indexed redirectAddress);

  event PermsSetForCharge(address indexed contractAddress, bool state);
  event PermsSetForBasket(address indexed contractAddress, bool state);
  event PermsSetForTimelockAny(address indexed contractAddress, bool state);
  event PermsSetForTimelockSelf(address indexed contractAddress, bool state);
}

File 13 of 30 : IChargedParticles.sol
// SPDX-License-Identifier: MIT

// IChargedParticles.sol -- Part of the Charged Particles Protocol
// Copyright (c) 2021 Firma Lux, Inc. <https://charged.fi>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

pragma solidity >=0.6.0;

/**
 * @notice Interface for Charged Particles
 */
interface IChargedParticles {

  /***********************************|
  |             Public API            |
  |__________________________________*/

  function getStateAddress() external view returns (address stateAddress);
  function getSettingsAddress() external view returns (address settingsAddress);

  function baseParticleMass(address contractAddress, uint256 tokenId, string calldata walletManagerId, address assetToken) external returns (uint256);
  function currentParticleCharge(address contractAddress, uint256 tokenId, string calldata walletManagerId, address assetToken) external returns (uint256);
  function currentParticleKinetics(address contractAddress, uint256 tokenId, string calldata walletManagerId, address assetToken) external returns (uint256);
  function currentParticleCovalentBonds(address contractAddress, uint256 tokenId, string calldata basketManagerId) external view returns (uint256);

  /***********************************|
  |        Particle Mechanics         |
  |__________________________________*/

  function energizeParticle(
      address contractAddress,
      uint256 tokenId,
      string calldata walletManagerId,
      address assetToken,
      uint256 assetAmount,
    address referrer
  ) external returns (uint256 yieldTokensAmount);

  function dischargeParticle(
      address receiver,
      address contractAddress,
      uint256 tokenId,
      string calldata walletManagerId,
      address assetToken
  ) external returns (uint256 creatorAmount, uint256 receiverAmount);

  function dischargeParticleAmount(
      address receiver,
      address contractAddress,
      uint256 tokenId,
      string calldata walletManagerId,
      address assetToken,
      uint256 assetAmount
  ) external returns (uint256 creatorAmount, uint256 receiverAmount);

  function dischargeParticleForCreator(
      address receiver,
      address contractAddress,
      uint256 tokenId,
      string calldata walletManagerId,
      address assetToken,
      uint256 assetAmount
  ) external returns (uint256 receiverAmount);

  function releaseParticle(
      address receiver,
      address contractAddress,
      uint256 tokenId,
      string calldata walletManagerId,
      address assetToken
  ) external returns (uint256 creatorAmount, uint256 receiverAmount);

  function releaseParticleAmount(
    address receiver,
    address contractAddress,
    uint256 tokenId,
    string calldata walletManagerId,
    address assetToken,
    uint256 assetAmount
  ) external returns (uint256 creatorAmount, uint256 receiverAmount);

  function covalentBond(
    address contractAddress,
    uint256 tokenId,
    string calldata basketManagerId,
    address nftTokenAddress,
    uint256 nftTokenId
  ) external returns (bool success);

  function breakCovalentBond(
    address receiver,
    address contractAddress,
    uint256 tokenId,
    string calldata basketManagerId,
    address nftTokenAddress,
    uint256 nftTokenId
  ) external returns (bool success);

  /***********************************|
  |          Particle Events          |
  |__________________________________*/

  event UniverseSet(address indexed universeAddress);
  event ChargedStateSet(address indexed chargedState);
  event ChargedSettingsSet(address indexed chargedSettings);
  event LeptonTokenSet(address indexed leptonToken);
}

File 14 of 30 : BlackholePrevention.sol
// SPDX-License-Identifier: MIT

// BlackholePrevention.sol -- Part of the Charged Particles Protocol
// Copyright (c) 2021 Firma Lux, Inc. <https://charged.fi>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

pragma solidity >=0.6.0;

import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";

/**
 * @notice Prevents ETH or Tokens from getting stuck in a contract by allowing
 *  the Owner/DAO to pull them out on behalf of a user
 * This is only meant to contracts that are not expected to hold tokens, but do handle transferring them.
 */
contract BlackholePrevention {
  using Address for address payable;
  using SafeERC20 for IERC20;

  event WithdrawStuckEther(address indexed receiver, uint256 amount);
  event WithdrawStuckERC20(address indexed receiver, address indexed tokenAddress, uint256 amount);
  event WithdrawStuckERC721(address indexed receiver, address indexed tokenAddress, uint256 indexed tokenId);

  function _withdrawEther(address payable receiver, uint256 amount) internal virtual {
    require(receiver != address(0x0), "BHP:E-403");
    if (address(this).balance >= amount) {
      receiver.sendValue(amount);
      emit WithdrawStuckEther(receiver, amount);
    }
  }

  function _withdrawERC20(address payable receiver, address tokenAddress, uint256 amount) internal virtual {
    require(receiver != address(0x0), "BHP:E-403");
    if (IERC20(tokenAddress).balanceOf(address(this)) >= amount) {
      IERC20(tokenAddress).safeTransfer(receiver, amount);
      emit WithdrawStuckERC20(receiver, tokenAddress, amount);
    }
  }

  function _withdrawERC721(address payable receiver, address tokenAddress, uint256 tokenId) internal virtual {
    require(receiver != address(0x0), "BHP:E-403");
    if (IERC721(tokenAddress).ownerOf(tokenId) == address(this)) {
      IERC721(tokenAddress).transferFrom(address(this), receiver, tokenId);
      emit WithdrawStuckERC721(receiver, tokenAddress, tokenId);
    }
  }
}

File 15 of 30 : RelayRecipient.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0;

import "@opengsn/gsn/contracts/BaseRelayRecipient.sol";

contract RelayRecipient is BaseRelayRecipient {
  function versionRecipient() external override view returns (string memory) {
    return "1.0.0-beta.1/charged-particles.relay.recipient";
  }
}

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

pragma solidity ^0.6.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 GSN 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 payable) {
        return msg.sender;
    }

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

File 17 of 30 : IERC721.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.2;

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

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transfered 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 18 of 30 : IERC721Metadata.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.2;

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 19 of 30 : IERC721Enumerable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.2;

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 20 of 30 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.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 21 of 30 : ERC165.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts may inherit from this and call {_registerInterface} to declare
 * their support of an interface.
 */
contract ERC165 is IERC165 {
    /*
     * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7
     */
    bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;

    /**
     * @dev Mapping of interface ids to whether or not it's supported.
     */
    mapping(bytes4 => bool) private _supportedInterfaces;

    constructor () internal {
        // Derived contracts need only register support for their own interfaces,
        // we register support for ERC165 itself here
        _registerInterface(_INTERFACE_ID_ERC165);
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     *
     * Time complexity O(1), guaranteed to always use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) public view override returns (bool) {
        return _supportedInterfaces[interfaceId];
    }

    /**
     * @dev Registers the contract as an implementer of the interface defined by
     * `interfaceId`. Support of the actual ERC165 interface is automatic and
     * registering its interface id is not required.
     *
     * See {IERC165-supportsInterface}.
     *
     * Requirements:
     *
     * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`).
     */
    function _registerInterface(bytes4 interfaceId) internal virtual {
        require(interfaceId != 0xffffffff, "ERC165: invalid interface id");
        _supportedInterfaces[interfaceId] = true;
    }
}

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

pragma solidity ^0.6.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.0.0, only sets of type `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];
    }

    // 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(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(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(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(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));
    }
}

File 23 of 30 : EnumerableMap.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

/**
 * @dev Library for managing an enumerable variant of Solidity's
 * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`]
 * type.
 *
 * Maps have the following properties:
 *
 * - Entries are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Entries are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableMap for EnumerableMap.UintToAddressMap;
 *
 *     // Declare a set state variable
 *     EnumerableMap.UintToAddressMap private myMap;
 * }
 * ```
 *
 * As of v3.0.0, only maps of type `uint256 -> address` (`UintToAddressMap`) are
 * supported.
 */
library EnumerableMap {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Map type with
    // bytes32 keys and values.
    // The Map implementation uses private functions, and user-facing
    // implementations (such as Uint256ToAddressMap) are just wrappers around
    // the underlying Map.
    // This means that we can only create new EnumerableMaps for types that fit
    // in bytes32.

    struct MapEntry {
        bytes32 _key;
        bytes32 _value;
    }

    struct Map {
        // Storage of map keys and values
        MapEntry[] _entries;

        // Position of the entry defined by a key in the `entries` array, plus 1
        // because index 0 means a key is not in the map.
        mapping (bytes32 => uint256) _indexes;
    }

    /**
     * @dev Adds a key-value pair to a map, or updates the value for an existing
     * key. O(1).
     *
     * Returns true if the key was added to the map, that is if it was not
     * already present.
     */
    function _set(Map storage map, bytes32 key, bytes32 value) private returns (bool) {
        // We read and store the key's index to prevent multiple reads from the same storage slot
        uint256 keyIndex = map._indexes[key];

        if (keyIndex == 0) { // Equivalent to !contains(map, key)
            map._entries.push(MapEntry({ _key: key, _value: value }));
            // The entry is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            map._indexes[key] = map._entries.length;
            return true;
        } else {
            map._entries[keyIndex - 1]._value = value;
            return false;
        }
    }

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

        if (keyIndex != 0) { // Equivalent to contains(map, key)
            // To delete a key-value pair from the _entries array in O(1), we swap the entry to delete with the last one
            // in the array, and then remove the last entry (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = keyIndex - 1;
            uint256 lastIndex = map._entries.length - 1;

            // When the entry 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.

            MapEntry storage lastEntry = map._entries[lastIndex];

            // Move the last entry to the index where the entry to delete is
            map._entries[toDeleteIndex] = lastEntry;
            // Update the index for the moved entry
            map._indexes[lastEntry._key] = toDeleteIndex + 1; // All indexes are 1-based

            // Delete the slot where the moved entry was stored
            map._entries.pop();

            // Delete the index for the deleted slot
            delete map._indexes[key];

            return true;
        } else {
            return false;
        }
    }

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

    /**
     * @dev Returns the number of key-value pairs in the map. O(1).
     */
    function _length(Map storage map) private view returns (uint256) {
        return map._entries.length;
    }

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

        MapEntry storage entry = map._entries[index];
        return (entry._key, entry._value);
    }

    /**
     * @dev Returns the value associated with `key`.  O(1).
     *
     * Requirements:
     *
     * - `key` must be in the map.
     */
    function _get(Map storage map, bytes32 key) private view returns (bytes32) {
        return _get(map, key, "EnumerableMap: nonexistent key");
    }

    /**
     * @dev Same as {_get}, with a custom error message when `key` is not in the map.
     */
    function _get(Map storage map, bytes32 key, string memory errorMessage) private view returns (bytes32) {
        uint256 keyIndex = map._indexes[key];
        require(keyIndex != 0, errorMessage); // Equivalent to contains(map, key)
        return map._entries[keyIndex - 1]._value; // All indexes are 1-based
    }

    // UintToAddressMap

    struct UintToAddressMap {
        Map _inner;
    }

    /**
     * @dev Adds a key-value pair to a map, or updates the value for an existing
     * key. O(1).
     *
     * Returns true if the key was added to the map, that is if it was not
     * already present.
     */
    function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) {
        return _set(map._inner, bytes32(key), bytes32(uint256(value)));
    }

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

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

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

   /**
    * @dev Returns the element 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(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) {
        (bytes32 key, bytes32 value) = _at(map._inner, index);
        return (uint256(key), address(uint256(value)));
    }

    /**
     * @dev Returns the value associated with `key`.  O(1).
     *
     * Requirements:
     *
     * - `key` must be in the map.
     */
    function get(UintToAddressMap storage map, uint256 key) internal view returns (address) {
        return address(uint256(_get(map._inner, bytes32(key))));
    }

    /**
     * @dev Same as {get}, with a custom error message when `key` is not in the map.
     */
    function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) {
        return address(uint256(_get(map._inner, bytes32(key), errorMessage)));
    }
}

File 24 of 30 : Strings.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

/**
 * @dev String operations.
 */
library Strings {
    /**
     * @dev Converts a `uint256` to its ASCII `string` 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);
        uint256 index = digits - 1;
        temp = value;
        while (temp != 0) {
            buffer[index--] = byte(uint8(48 + temp % 10));
            temp /= 10;
        }
        return string(buffer);
    }
}

File 25 of 30 : IERC165.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.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 26 of 30 : IWalletManager.sol
// SPDX-License-Identifier: MIT

// IWalletManager.sol -- Part of the Charged Particles Protocol
// Copyright (c) 2021 Firma Lux, Inc. <https://charged.fi>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

pragma solidity >=0.6.0;

/**
 * @title Particle Wallet Manager interface
 * @dev The wallet-manager for underlying assets attached to Charged Particles
 * @dev Manages the link between NFTs and their respective Smart-Wallets
 */
interface IWalletManager {

  event ControllerSet(address indexed controller);
  event PausedStateSet(bool isPaused);
  event NewSmartWallet(address indexed contractAddress, uint256 indexed tokenId, address indexed smartWallet, address creator, uint256 annuityPct);
  event WalletEnergized(address indexed contractAddress, uint256 indexed tokenId, address indexed assetToken, uint256 assetAmount, uint256 yieldTokensAmount);
  event WalletDischarged(address indexed contractAddress, uint256 indexed tokenId, address indexed assetToken, uint256 creatorAmount, uint256 receiverAmount);
  event WalletDischargedForCreator(address indexed contractAddress, uint256 indexed tokenId, address indexed assetToken, address creator, uint256 receiverAmount);
  event WalletReleased(address indexed contractAddress, uint256 indexed tokenId, address indexed receiver, address assetToken, uint256 principalAmount, uint256 creatorAmount, uint256 receiverAmount);
  event WalletRewarded(address indexed contractAddress, uint256 indexed tokenId, address indexed receiver, address rewardsToken, uint256 rewardsAmount);

  function isPaused() external view returns (bool);

  function isReserveActive(address contractAddress, uint256 tokenId, address assetToken) external view returns (bool);
  function getReserveInterestToken(address contractAddress, uint256 tokenId, address assetToken) external view returns (address);

  function getTotal(address contractAddress, uint256 tokenId, address assetToken) external returns (uint256);
  function getPrincipal(address contractAddress, uint256 tokenId, address assetToken) external returns (uint256);
  function getInterest(address contractAddress, uint256 tokenId, address assetToken) external returns (uint256 creatorInterest, uint256 ownerInterest);
  function getRewards(address contractAddress, uint256 tokenId, address rewardToken) external returns (uint256);

  function energize(address contractAddress, uint256 tokenId, address assetToken, uint256 assetAmount) external returns (uint256 yieldTokensAmount);
  function discharge(address receiver, address contractAddress, uint256 tokenId, address assetToken, address creatorRedirect) external returns (uint256 creatorAmount, uint256 receiverAmount);
  function dischargeAmount(address receiver, address contractAddress, uint256 tokenId, address assetToken, uint256 assetAmount, address creatorRedirect) external returns (uint256 creatorAmount, uint256 receiverAmount);
  function dischargeAmountForCreator(address receiver, address contractAddress, uint256 tokenId, address creator, address assetToken, uint256 assetAmount) external returns (uint256 receiverAmount);
  function release(address receiver, address contractAddress, uint256 tokenId, address assetToken, address creatorRedirect) external returns (uint256 principalAmount, uint256 creatorAmount, uint256 receiverAmount);
  function releaseAmount(address receiver, address contractAddress, uint256 tokenId, address assetToken, uint256 assetAmount, address creatorRedirect) external returns (uint256 principalAmount, uint256 creatorAmount, uint256 receiverAmount);
  function withdrawRewards(address receiver, address contractAddress, uint256 tokenId, address rewardsToken, uint256 rewardsAmount) external returns (uint256 amount);
  function executeForAccount(address contractAddress, uint256 tokenId, address externalAddress, uint256 ethValue, bytes memory encodedParams) external returns (bytes memory);
  function getWalletAddressById(address contractAddress, uint256 tokenId, address creator, uint256 annuityPct) external returns (address);

  function withdrawEther(address contractAddress, uint256 tokenId, address payable receiver, uint256 amount) external;
  function withdrawERC20(address contractAddress, uint256 tokenId, address payable receiver, address tokenAddress, uint256 amount) external;
  function withdrawERC721(address contractAddress, uint256 tokenId, address payable receiver, address nftTokenAddress, uint256 nftTokenId) external;
}

File 27 of 30 : IBasketManager.sol
// SPDX-License-Identifier: MIT

// IBasketManager.sol -- Part of the Charged Particles Protocol
// Copyright (c) 2021 Firma Lux, Inc. <https://charged.fi>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

pragma solidity >=0.6.0;

/**
 * @title Particle Basket Manager interface
 * @dev The basket-manager for underlying assets attached to Charged Particles
 * @dev Manages the link between NFTs and their respective Smart-Baskets
 */
interface IBasketManager {

  event ControllerSet(address indexed controller);
  event PausedStateSet(bool isPaused);
  event NewSmartBasket(address indexed contractAddress, uint256 indexed tokenId, address indexed smartBasket);
  event BasketAdd(address indexed contractAddress, uint256 indexed tokenId, address basketTokenAddress, uint256 basketTokenId);
  event BasketRemove(address indexed receiver, address indexed contractAddress, uint256 indexed tokenId, address basketTokenAddress, uint256 basketTokenId);

  function isPaused() external view returns (bool);

  function getTokenTotalCount(address contractAddress, uint256 tokenId) external view returns (uint256);
  function getTokenCountByType(address contractAddress, uint256 tokenId, address basketTokenAddress, uint256 basketTokenId) external returns (uint256);

  function addToBasket(address contractAddress, uint256 tokenId, address basketTokenAddress, uint256 basketTokenId) external returns (bool);
  function removeFromBasket(address receiver, address contractAddress, uint256 tokenId, address basketTokenAddress, uint256 basketTokenId) external returns (bool);
  function executeForAccount(address contractAddress, uint256 tokenId, address externalAddress, uint256 ethValue, bytes memory encodedParams) external returns (bytes memory);
  function getBasketAddressById(address contractAddress, uint256 tokenId) external returns (address);

  function withdrawEther(address contractAddress, uint256 tokenId, address payable receiver, uint256 amount) external;
  function withdrawERC20(address contractAddress, uint256 tokenId, address payable receiver, address tokenAddress, uint256 amount) external;
  function withdrawERC721(address contractAddress, uint256 tokenId, address payable receiver, address nftTokenAddress, uint256 nftTokenId) external;
}

File 28 of 30 : SafeERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import "./IERC20.sol";
import "../../math/SafeMath.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 SafeMath for uint256;
    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).add(value);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
        _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 29 of 30 : BaseRelayRecipient.sol
// SPDX-License-Identifier:MIT
// solhint-disable no-inline-assembly
pragma solidity ^0.6.2;

import "./interfaces/IRelayRecipient.sol";

/**
 * A base contract to be inherited by any contract that want to receive relayed transactions
 * A subclass must use "_msgSender()" instead of "msg.sender"
 */
abstract contract BaseRelayRecipient is IRelayRecipient {

    /*
     * Forwarder singleton we accept calls from
     */
    address public trustedForwarder;

    function isTrustedForwarder(address forwarder) public override view returns(bool) {
        return forwarder == trustedForwarder;
    }

    /**
     * return the sender of this call.
     * if the call came through our trusted forwarder, return the original sender.
     * otherwise, return `msg.sender`.
     * should be used in the contract anywhere instead of msg.sender
     */
    function _msgSender() internal override virtual view returns (address payable ret) {
        if (msg.data.length >= 24 && isTrustedForwarder(msg.sender)) {
            // At this point we know that the sender is a trusted forwarder,
            // so we trust that the last bytes of msg.data are the verified sender address.
            // extract sender address from the end of msg.data
            assembly {
                ret := shr(96,calldataload(sub(calldatasize(),20)))
            }
        } else {
            return msg.sender;
        }
    }

    /**
     * return the msg.data of this call.
     * if the call came through our trusted forwarder, then the real sender was appended as the last 20 bytes
     * of the msg.data - so this method will strip those 20 bytes off.
     * otherwise, return `msg.data`
     * should be used in the contract instead of msg.data, where the difference matters (e.g. when explicitly
     * signing or hashing the
     */
    function _msgData() internal override virtual view returns (bytes memory ret) {
        if (msg.data.length >= 24 && isTrustedForwarder(msg.sender)) {
            // At this point we know that the sender is a trusted forwarder,
            // we copy the msg.data , except the last 20 bytes (and update the total length)
            assembly {
                let ptr := mload(0x40)
                // copy only size-20 bytes
                let size := sub(calldatasize(),20)
                // structure RLP data as <offset> <length> <bytes>
                mstore(ptr, 0x20)
                mstore(add(ptr,32), size)
                calldatacopy(add(ptr,64), 0, size)
                return(ptr, add(size,64))
            }
        } else {
            return msg.data;
        }
    }
}

File 30 of 30 : IRelayRecipient.sol
// SPDX-License-Identifier:MIT
pragma solidity ^0.6.2;

/**
 * a contract must implement this interface in order to support relayed transaction.
 * It is better to inherit the BaseRelayRecipient as its implementation.
 */
abstract contract IRelayRecipient {

    /**
     * return if the forwarder is trusted to forward relayed transactions to us.
     * the forwarder is required to verify the sender's signature, and verify
     * the call is not a replay.
     */
    function isTrustedForwarder(address forwarder) public virtual view returns(bool);

    /**
     * return the sender of this call.
     * if the call came through our trusted forwarder, then the real sender is appended as the last 20 bytes
     * of the msg.data.
     * otherwise, return `msg.sender`
     * should be used in the contract anywhere instead of msg.sender
     */
    function _msgSender() internal virtual view returns (address payable);

    /**
     * return the msg.data of this call.
     * if the call came through our trusted forwarder, then the real sender was appended as the last 20 bytes
     * of the msg.data - so this method will strip those 20 bytes off.
     * otherwise, return `msg.data`
     * should be used in the contract instead of msg.data, where the difference matters (e.g. when explicitly
     * signing or hashing the
     */
    function _msgData() internal virtual view returns (bytes memory);

    function versionRecipient() external virtual view returns (string memory);
}

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

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"chargedParticles","type":"address"}],"name":"ChargedParticlesSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"chargedSettings","type":"address"}],"name":"ChargedSettingsSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"chargedState","type":"address"}],"name":"ChargedStateSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"royaltiesPct","type":"uint256"}],"name":"CreatorRoyaltiesSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"FeesWithdrawn","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"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"isPaused","type":"bool"}],"name":"PausedStateSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"},{"indexed":false,"internalType":"uint256","name":"salePrice","type":"uint256"},{"indexed":false,"internalType":"address","name":"creator","type":"address"},{"indexed":false,"internalType":"uint256","name":"creatorRoyalties","type":"uint256"}],"name":"ProtonSold","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountClaimed","type":"uint256"}],"name":"RoyaltiesClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"salePrice","type":"uint256"}],"name":"SalePriceSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"startTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"count","type":"uint256"}],"name":"TransferBatch","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"universe","type":"address"}],"name":"UniverseSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":true,"internalType":"address","name":"tokenAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawStuckERC20","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":true,"internalType":"address","name":"tokenAddress","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"WithdrawStuckERC721","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawStuckEther","type":"event"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"uint256","name":"annuityPercent","type":"uint256"},{"internalType":"uint256","name":"royaltiesPercent","type":"uint256"},{"internalType":"string[]","name":"tokenMetaUris","type":"string[]"},{"internalType":"uint256[]","name":"salePrices","type":"uint256[]"}],"name":"batchProtonsForSale","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"buyProton","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"claimCreatorRoyalties","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"string","name":"tokenMetaUri","type":"string"}],"name":"createBasicProton","outputs":[{"internalType":"uint256","name":"newTokenId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"referrer","type":"address"},{"internalType":"string","name":"tokenMetaUri","type":"string"},{"internalType":"string","name":"walletManagerId","type":"string"},{"internalType":"address","name":"assetToken","type":"address"},{"internalType":"uint256","name":"assetAmount","type":"uint256"},{"internalType":"uint256","name":"annuityPercent","type":"uint256"}],"name":"createChargedParticle","outputs":[{"internalType":"uint256","name":"newTokenId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"string","name":"tokenMetaUri","type":"string"},{"internalType":"uint256","name":"annuityPercent","type":"uint256"}],"name":"createProton","outputs":[{"internalType":"uint256","name":"newTokenId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"string","name":"tokenMetaUri","type":"string"},{"internalType":"uint256","name":"annuityPercent","type":"uint256"},{"internalType":"uint256","name":"royaltiesPercent","type":"uint256"},{"internalType":"uint256","name":"salePrice","type":"uint256"}],"name":"createProtonForSale","outputs":[{"internalType":"uint256","name":"newTokenId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"creatorOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getCreatorRoyalties","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getCreatorRoyaltiesPct","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getCreatorRoyaltiesReceiver","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getLastSellPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getSalePrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"forwarder","type":"address"}],"name":"isTrustedForwarder","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"chargedParticles","type":"address"}],"name":"setChargedParticles","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"settings","type":"address"}],"name":"setChargedSettings","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"stateController","type":"address"}],"name":"setChargedState","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"setCreatorRoyaltiesReceiver","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"state","type":"bool"}],"name":"setPausedState","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"royaltiesPct","type":"uint256"}],"name":"setRoyaltiesPct","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"salePrice","type":"uint256"}],"name":"setSalePrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_trustedForwarder","type":"address"}],"name":"setTrustedForwarder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"universe","type":"address"}],"name":"setUniverse","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"trustedForwarder","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"versionRecipient","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address payable","name":"receiver","type":"address"},{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"withdrawERC721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"receiver","type":"address"},{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawErc20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"receiver","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawEther","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60806040523480156200001157600080fd5b50604080518082018252601a81527f43686172676564205061727469636c6573202d2050726f746f6e00000000000060208083019190915282518084019093526006835265282927aa27a760d11b9083015290620000766301ffc9a760e01b62000140565b81516200008b90600690602085019062000204565b508051620000a190600790602084019062000204565b50620000b46380ac58cd60e01b62000140565b620000c6635b5e139f60e01b62000140565b620000d863780e9d6360e01b62000140565b5060009050620000e76200019b565b600980546001600160a01b0319166001600160a01b038316908117909155604051919250906000907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3506001600b55620002d7565b6001600160e01b03198082161415620001765760405162461bcd60e51b81526004016200016d90620002a0565b60405180910390fd5b6001600160e01b0319166000908152602081905260409020805460ff19166001179055565b6000620001b2620001b860201b620016ac1760201c565b90505b90565b600060183610801590620001d25750620001d233620001f0565b15620001e8575060131936013560601c620001b5565b5033620001b5565b600a546001600160a01b0390811691161490565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106200024757805160ff191683800117855562000277565b8280016001018555821562000277579182015b82811115620002775782518255916020019190600101906200025a565b506200028592915062000289565b5090565b5b808211156200028557600081556001016200028a565b6020808252601c908201527f4552433136353a20696e76616c696420696e7465726661636520696400000000604082015260600190565b613e7c80620002e76000396000f3fe6080604052600436106102875760003560e01c80636e5559fd1161015a578063ad82c42c116100c1578063c95d09981161007a578063c95d099814610786578063da742228146107a6578063db9f60ff146107c6578063e985e9c5146107e6578063f2fde38b14610806578063f8eb5fc51461082657610287565b8063ad82c42c146106c6578063ae9704cd146106e6578063b7683e9314610706578063b88d4fde14610726578063c87b56dd14610746578063c8c680d51461076657610287565b806382e9870f1161011357806382e9870f14610629578063846ec08c1461063c5780638da5cb5b1461065c5780639390afc71461067157806395d89b4114610691578063a22cb465146106a657610287565b80636e5559fd1461057f5780636ed6237e1461059f57806370a08231146105bf578063715018a6146105df57806371e715f4146105f45780637da0a8771461061457610287565b80632f745c59116101fe578063522f6815116101b7578063522f6815146104ca578063572b6c05146104ea578063589a17431461050a57806362c517491461052a5780636348af341461054a5780636352211e1461055f57610287565b80632f745c59146104155780632fc77797146104355780634025feb21461045557806342842e0e14610475578063486ff0cd146104955780634f6ccce7146104aa57610287565b8063095ea7b311610250578063095ea7b3146103605780631593dee11461038057806318160ddd146103a057806323b872dd146103b5578063250b2c80146103d55780632c0cd5a3146103f557610287565b8062e4eb991461028c57806301ffc9a7146102c2578063053992c5146102ef57806306fdde0314610311578063081812fc14610333575b600080fd5b34801561029857600080fd5b506102ac6102a736600461332f565b610846565b6040516102b99190613d43565b60405180910390f35b3480156102ce57600080fd5b506102e26102dd366004613589565b61088d565b6040516102b991906137d7565b3480156102fb57600080fd5b5061030f61030a366004613615565b6108ac565b005b34801561031d57600080fd5b5061032661090c565b6040516102b991906137e2565b34801561033f57600080fd5b5061035361034e3660046135c1565b6109a3565b6040516102b9919061367e565b34801561036c57600080fd5b5061030f61037b3660046131ad565b6109e6565b34801561038c57600080fd5b5061030f61039b36600461316d565b610a79565b3480156103ac57600080fd5b506102ac610ab9565b3480156103c157600080fd5b5061030f6103d0366004613413565b610aca565b3480156103e157600080fd5b506102ac6103f03660046135c1565b610afc565b34801561040157600080fd5b506102ac6104103660046132cf565b610b0e565b34801561042157600080fd5b506102ac6104303660046131ad565b610b4c565b34801561044157600080fd5b5061030f6104503660046135f1565b610b77565b34801561046157600080fd5b5061030f61047036600461316d565b610c0b565b34801561048157600080fd5b5061030f610490366004613413565b610c4b565b3480156104a157600080fd5b50610326610c66565b3480156104b657600080fd5b506102ac6104c53660046135c1565b610c86565b3480156104d657600080fd5b5061030f6104e53660046131ad565b610c9c565b3480156104f657600080fd5b506102e2610505366004613135565b610cdf565b34801561051657600080fd5b506103536105253660046135c1565b610cf3565b34801561053657600080fd5b506102ac610545366004613210565b610d0e565b34801561055657600080fd5b506102ac610d7d565b34801561056b57600080fd5b5061035361057a3660046135c1565b610de4565b34801561058b57600080fd5b5061030f61059a366004613135565b610e20565b3480156105ab57600080fd5b5061030f6105ba3660046134be565b610e9f565b3480156105cb57600080fd5b506102ac6105da366004613135565b610eda565b3480156105eb57600080fd5b5061030f610f23565b34801561060057600080fd5b5061035361060f3660046135c1565b610fa2565b34801561062057600080fd5b50610353610fad565b6102e26106373660046135c1565b610fbc565b34801561064857600080fd5b506102ac610657366004613135565b61101d565b34801561066857600080fd5b50610353611038565b34801561067d57600080fd5b506102ac61068c366004613397565b611047565b34801561069d57600080fd5b50610326611086565b3480156106b257600080fd5b5061030f6106c1366004613491565b6110e7565b3480156106d257600080fd5b506102ac6106e13660046135c1565b6111b5565b3480156106f257600080fd5b5061030f610701366004613135565b6111c7565b34801561071257600080fd5b5061030f610721366004613135565b611246565b34801561073257600080fd5b5061030f610741366004613427565b6112c5565b34801561075257600080fd5b506103266107613660046135c1565b611304565b34801561077257600080fd5b5061030f610781366004613615565b6113ca565b34801561079257600080fd5b5061030f6107a1366004613135565b611461565b3480156107b257600080fd5b5061030f6107c1366004613135565b6114e0565b3480156107d257600080fd5b5061030f6107e1366004613551565b611537565b3480156107f257600080fd5b506102e26108013660046131d8565b6115b5565b34801561081257600080fd5b5061030f610821366004613135565b6115e3565b34801561083257600080fd5b506102ac6108413660046135c1565b61169a565b60175460009060ff16156108755760405162461bcd60e51b815260040161086c90613c0d565b60405180910390fd5b610884858585856000806116de565b95945050505050565b6001600160e01b03191660009081526020819052604090205460ff1690565b60175460ff16156108cf5760405162461bcd60e51b815260040161086c90613c0d565b816108e16108db6117da565b826117e4565b6108fd5760405162461bcd60e51b815260040161086c90613cfa565b6109078383611861565b505050565b60068054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156109985780601f1061096d57610100808354040283529160200191610998565b820191906000526020600020905b81548152906001019060200180831161097b57829003601f168201915b505050505090505b90565b60006109ae82611918565b6109ca5760405162461bcd60e51b815260040161086c90613c9d565b506000908152600460205260409020546001600160a01b031690565b60006109f182610de4565b9050806001600160a01b0316836001600160a01b03161415610a255760405162461bcd60e51b815260040161086c90613d1d565b806001600160a01b0316610a376117da565b6001600160a01b03161480610a535750610a53816108016117da565b610a6f5760405162461bcd60e51b815260040161086c90613b21565b6109078383611925565b610a816117da565b6009546001600160a01b03908116911614610aae5760405162461bcd60e51b815260040161086c90613ac6565b610907838383611993565b6000610ac56002611aa0565b905090565b610ad56108db6117da565b610af15760405162461bcd60e51b815260040161086c90613b21565b610907838383611aab565b60009081526016602052604090205490565b60175460009060ff1615610b345760405162461bcd60e51b815260040161086c90613c0d565b610b4484848460008060006116de565b949350505050565b6001600160a01b0382166000908152600160205260408120610b6e9083611b2c565b90505b92915050565b60175460ff1615610b9a5760405162461bcd60e51b815260040161086c90613c0d565b81610ba36117da565b6000828152601160205260409020546001600160a01b03908116911614610bdc5760405162461bcd60e51b815260040161086c90613b47565b5060009182526013602052604090912080546001600160a01b0319166001600160a01b03909216919091179055565b610c136117da565b6009546001600160a01b03908116911614610c405760405162461bcd60e51b815260040161086c90613ac6565b610907838383611b38565b610907838383604051806020016040528060008152506112c5565b60606040518060600160405280602e8152602001613e19602e9139905090565b600080610c94600284611c93565b509392505050565b610ca46117da565b6009546001600160a01b03908116911614610cd15760405162461bcd60e51b815260040161086c90613ac6565b610cdb8282611cb1565b5050565b600a546001600160a01b0390811691161490565b6000908152601160205260409020546001600160a01b031690565b60006002600b541415610d335760405162461bcd60e51b815260040161086c90613cc3565b6002600b5560175460ff1615610d5b5760405162461bcd60e51b815260040161086c90613c0d565b610d6b8989898989898989611d29565b6001600b559998505050505050505050565b60006002600b541415610da25760405162461bcd60e51b815260040161086c90613cc3565b6002600b5560175460ff1615610dca5760405162461bcd60e51b815260040161086c90613c0d565b610dda610dd56117da565b611d7e565b90506001600b5590565b6000610b71826040518060400160405280600c81526020016b4552433732313a452d34303560a01b8152506002611e1e9092919063ffffffff16565b610e286117da565b6009546001600160a01b03908116911614610e555760405162461bcd60e51b815260040161086c90613ac6565b600f80546001600160a01b0319166001600160a01b0383169081179091556040517f5ce0e6b7fd36339ee97339831b6c72694ecee88c62aab49919d9cabe0a732e4190600090a250565b60175460ff1615610ec25760405162461bcd60e51b815260040161086c90613c0d565b610ed187878787878787611e35565b50505050505050565b60006001600160a01b038216610f025760405162461bcd60e51b815260040161086c906138a0565b6001600160a01b0382166000908152600160205260409020610b7190611aa0565b610f2b6117da565b6009546001600160a01b03908116911614610f585760405162461bcd60e51b815260040161086c90613ac6565b6009546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600980546001600160a01b0319169055565b6000610b7182611fe6565b600a546001600160a01b031681565b60006002600b541415610fe15760405162461bcd60e51b815260040161086c90613cc3565b6002600b5560175460ff16156110095760405162461bcd60e51b815260040161086c90613c0d565b61101282612020565b6001600b5592915050565b6001600160a01b031660009081526014602052604090205490565b6009546001600160a01b031690565b60175460009060ff161561106d5760405162461bcd60e51b815260040161086c90613c0d565b61107b8787878787876116de565b979650505050505050565b60078054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156109985780601f1061096d57610100808354040283529160200191610998565b6110ef6117da565b6001600160a01b0316826001600160a01b031614156111205760405162461bcd60e51b815260040161086c90613d1d565b806005600061112d6117da565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff1916921515929092179091556111716117da565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516111a991906137d7565b60405180910390a35050565b60009081526012602052604090205490565b6111cf6117da565b6009546001600160a01b039081169116146111fc5760405162461bcd60e51b815260040161086c90613ac6565b600c80546001600160a01b0319166001600160a01b0383169081179091556040517ff28fa0fe2abe5dad2066ebce6edc9d403e4facb3603e47e6c0e7ea3e57dfe03290600090a250565b61124e6117da565b6009546001600160a01b0390811691161461127b5760405162461bcd60e51b815260040161086c90613ac6565b600d80546001600160a01b0319166001600160a01b0383169081179091556040517f62ff39aed768a426c7582b6e1062ab2631df1869b2d574e36f8274d2e2b0ab8190600090a250565b6112d66112d06117da565b836117e4565b6112f25760405162461bcd60e51b815260040161086c90613b21565b6112fe848484846122bc565b50505050565b606061130f82611918565b61132b5760405162461bcd60e51b815260040161086c90613c9d565b60008281526008602090815260409182902080548351601f6002600019610100600186161502019093169290920491820184900484028101840190945280845290918301828280156113be5780601f10611393576101008083540402835291602001916113be565b820191906000526020600020905b8154815290600101906020018083116113a157829003601f168201915b50505050509050919050565b60175460ff16156113ed5760405162461bcd60e51b815260040161086c90613c0d565b816113f66117da565b6000828152601160205260409020546001600160a01b0390811691161461142f5760405162461bcd60e51b815260040161086c90613b47565b8261143b6108db6117da565b6114575760405162461bcd60e51b815260040161086c90613cfa565b6112fe84846122ef565b6114696117da565b6009546001600160a01b039081169116146114965760405162461bcd60e51b815260040161086c90613ac6565b600e80546001600160a01b0319166001600160a01b0383169081179091556040517f7ad4c1bc3e874ec0bf47846feb5648b384e8511dc9e5f9803578c9d2b4ec9e6e90600090a250565b6114e86117da565b6009546001600160a01b039081169116146115155760405162461bcd60e51b815260040161086c90613ac6565b600a80546001600160a01b0319166001600160a01b0392909216919091179055565b61153f6117da565b6009546001600160a01b0390811691161461156c5760405162461bcd60e51b815260040161086c90613ac6565b6017805460ff19168215151790556040517fa9bfed3d98385b3777389e321dbde773cf7d335fa604fefbae3dca93564f5586906115aa9083906137d7565b60405180910390a150565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b6115eb6117da565b6009546001600160a01b039081169116146116185760405162461bcd60e51b815260040161086c90613ac6565b6001600160a01b03811661163e5760405162461bcd60e51b815260040161086c90613837565b6009546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600980546001600160a01b0319166001600160a01b0392909216919091179055565b60009081526015602052604090205490565b6000601836108015906116c357506116c333610cdf565b156116d7575060131936013560601c6109a0565b50336109a0565b60006116ea6010612354565b6116f4601061235d565b9050611710868260405180602001604052806000815250612361565b600081815260116020526040902080546001600160a01b0319166001600160a01b0389161790556117418186612394565b82156117515761175181846122ef565b8115611761576117618183611861565b83156117d057600e546040516315aea5d760e01b81526001600160a01b03909116906315aea5d79061179d90309085908c908a90600401613742565b600060405180830381600087803b1580156117b757600080fd5b505af11580156117cb573d6000803e3d6000fd5b505050505b9695505050505050565b6000610ac56116ac565b60006117ef82611918565b61180b5760405162461bcd60e51b815260040161086c90613c9d565b600061181683610de4565b9050806001600160a01b0316846001600160a01b031614806118515750836001600160a01b0316611846846109a3565b6001600160a01b0316145b80610b445750610b4481856115b5565b600d54604051636a5fcc8b60e11b81526001600160a01b039091169063d4bf99169061189790309086908615159060040161376c565b600060405180830381600087803b1580156118b157600080fd5b505af11580156118c5573d6000803e3d6000fd5b50505060008381526015602052604090819020839055518391507fe23ea816dce6d7f5c0b85cbd597e7c3b97b2453791152c0b94e5e5c5f314d2f09061190c908490613d43565b60405180910390a25050565b6000610b716002836123d8565b600081815260046020526040902080546001600160a01b0319166001600160a01b038416908117909155819061195a82610de4565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6001600160a01b0383166119b95760405162461bcd60e51b815260040161086c9061387d565b6040516370a0823160e01b815281906001600160a01b038416906370a08231906119e790309060040161367e565b60206040518083038186803b1580156119ff57600080fd5b505afa158015611a13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a3791906135d9565b1061090757611a506001600160a01b03831684836123e4565b816001600160a01b0316836001600160a01b03167f6c9d637297625e945b296ff73a71fcfbd0a9e062652b6491a921c4c60194176b83604051611a939190613d43565b60405180910390a3505050565b6000610b718261235d565b600081815260156020526040808220829055600d549051636a5fcc8b60e11b81526001600160a01b039091169163d4bf991691611aef91309186919060040161376c565b600060405180830381600087803b158015611b0957600080fd5b505af1158015611b1d573d6000803e3d6000fd5b5050505061090783838361243a565b6000610b6e838361253d565b6001600160a01b038316611b5e5760405162461bcd60e51b815260040161086c9061387d565b6040516331a9108f60e11b815230906001600160a01b03841690636352211e90611b8c908590600401613d43565b60206040518083038186803b158015611ba457600080fd5b505afa158015611bb8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bdc9190613151565b6001600160a01b03161415610907576040516323b872dd60e01b81526001600160a01b038316906323b872dd90611c1b903090879086906004016136c5565b600060405180830381600087803b158015611c3557600080fd5b505af1158015611c49573d6000803e3d6000fd5b5050505080826001600160a01b0316846001600160a01b03167ffefe036cac4ee3a4aca074a81cbcc4376e1484693289078dbec149c890101d5b60405160405180910390a4505050565b6000808080611ca28686612582565b909450925050505b9250929050565b6001600160a01b038216611cd75760405162461bcd60e51b815260040161086c9061387d565b804710610cdb57611cf16001600160a01b038316826125de565b816001600160a01b03167eddb683bb45cd5d0ad8a200c6fae7152b1c236ee90a4a37db692407f5cc38bd8260405161190c9190613d43565b600f546000906001600160a01b0316611d545760405162461bcd60e51b815260040161086c90613ba1565b611d63898988856000806116de565b9050611d72818686868b61267a565b98975050505050505050565b6001600160a01b03811660009081526014602052604081205480611db45760405162461bcd60e51b815260040161086c90613bea565b6001600160a01b038316600081815260146020526040812055611dd790826125de565b826001600160a01b03167f8fbbda19f4a70036f6f585dc4160142a8fa2a20ffb9393d23274f78de4e3988882604051611e109190613d43565b60405180910390a250919050565b6000611e2b8484846127a7565b90505b9392505050565b828114611e545760405162461bcd60e51b815260040161086c906138fd565b308360005b81811015611fda57611e6b6010612354565b6000611e77601061235d565b9050611e938b8260405180602001604052806000815250612361565b600081815260116020526040902080546001600160a01b0319166001600160a01b038d16179055611f1681898985818110611eca57fe5b9050602002810190611edc9190613d6b565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061239492505050565b8815611f2657611f26818a6122ef565b6000868684818110611f3457fe5b9050602002013590506000811115611f5057611f508282611861565b8a15611fd057600e60009054906101000a90046001600160a01b03166001600160a01b03166315aea5d786848f8f6040518563ffffffff1660e01b8152600401611f9d9493929190613742565b600060405180830381600087803b158015611fb757600080fd5b505af1158015611fcb573d6000803e3d6000fd5b505050505b5050600101611e59565b50505050505050505050565b6000818152601360205260408120546001600160a01b031680610b715750506000908152601160205260409020546001600160a01b031690565b6000818152601560205260408120548061204c5760405162461bcd60e51b815260040161086c906139d7565b8034101561206c5760405162461bcd60e51b815260040161086c906139b4565b8060008061207986610de4565b905060006120856117da565b9050600061209288611fe6565b6000898152601260209081526040808320546016909252909120549192509081158015906120c05750600081115b80156120cb57508088115b156120f7576120e86127106120e2838b0385612806565b90612840565b95506120f48787612882565b96505b60008a8152601660205260409020889055600c546001600160a01b03161561218857600c546040516345c984d960e11b81526001600160a01b0390911690638b9309b2906121559030908e908a908a908f908b908f90600401613702565b600060405180830381600087803b15801561216f57600080fd5b505af1158015612183573d6000803e3d6000fd5b505050505b600d54604051636a5fcc8b60e11b81526001600160a01b039091169063d4bf9916906121bd9030908e9060009060040161376c565b600060405180830381600087803b1580156121d757600080fd5b505af11580156121eb573d6000803e3d6000fd5b505050506000861115612235576001600160a01b03831660009081526014602052604090205461221b90876128c4565b6001600160a01b0384166000908152601460205260409020555b61224085858c611aab565b6122536001600160a01b038616886125de565b836001600160a01b0316856001600160a01b03168b7f71a2ee63bc7695052e3a9837d5a45dd1cc0ce12717e39cef6eb6afb0d91697ed8b878b60405161229b93929190613d4c565b60405180910390a46122ac886128e9565b5060019998505050505050505050565b6122c7848484611aab565b6122d384848484612918565b6112fe5760405162461bcd60e51b815260040161086c90613a1d565b611f408111156123115760405162461bcd60e51b815260040161086c906139fa565b600082815260126020526040908190208290555182907fd91bd92b973231f564eaa17c9bc62c86b96a8885f3cdcb990d5a3f0415580d909061190c908490613d43565b80546001019055565b5490565b61236b8383612a00565b6123786000848484612918565b6109075760405162461bcd60e51b815260040161086c90613a1d565b61239d82611918565b6123b95760405162461bcd60e51b815260040161086c90613c9d565b6000828152600860209081526040909120825161090792840190612fe2565b6000610b6e8383612ab8565b6109078363a9059cbb60e01b84846040516024016124039291906136e9565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612ad0565b826001600160a01b031661244d82610de4565b6001600160a01b0316146124735760405162461bcd60e51b815260040161086c90613bc4565b6001600160a01b0382166124995760405162461bcd60e51b815260040161086c906138a0565b6124a4600082611925565b6001600160a01b03831660009081526001602052604090206124c69082612b5f565b506001600160a01b03821660009081526001602052604090206124e99082612b6b565b506124f660028284612b77565b5080826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b815460009082106125605760405162461bcd60e51b815260040161086c906137f5565b82600001828154811061256f57fe5b9060005260206000200154905092915050565b8154600090819083106125a75760405162461bcd60e51b815260040161086c90613a43565b60008460000184815481106125b857fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b804710156125fe5760405162461bcd60e51b815260040161086c9061397d565b6000826001600160a01b031682604051612617906109a0565b60006040518083038185875af1925050503d8060008114612654576040519150601f19603f3d011682016040523d82523d6000602084013e612659565b606091505b50509050806109075760405162461bcd60e51b815260040161086c90613920565b61268c6126856117da565b8484612b8d565b600f5460405163095ea7b360e01b81526001600160a01b038581169263095ea7b3926126c0929091169086906004016136e9565b602060405180830381600087803b1580156126da57600080fd5b505af11580156126ee573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612712919061356d565b50600f546040516305eef16560e11b81526001600160a01b0390911690630bdde2ca9061274d9030908990899089908990899060040161378f565b602060405180830381600087803b15801561276757600080fd5b505af115801561277b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061279f91906135d9565b505050505050565b600082815260018401602052604081205482816127d75760405162461bcd60e51b815260040161086c91906137e2565b508460000160018203815481106127ea57fe5b9060005260206000209060020201600101549150509392505050565b60008261281557506000610b71565b8282028284828161282257fe5b0414610b6e5760405162461bcd60e51b815260040161086c90613a85565b6000610b6e83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612ccc565b6000610b6e83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612d03565b600082820183811015610b6e5760405162461bcd60e51b815260040161086c906138c6565b60006128f53483612882565b90508015610cdb57610cdb816129096117da565b6001600160a01b0316906125de565b600061292c846001600160a01b0316612d2f565b61293857506001610b44565b60606129c9630a85bd0160e11b61294d6117da565b8887876040516024016129639493929190613692565b60408051601f19818403018152918152602080830180516001600160e01b03166001600160e01b0319909516949094179093528051808201909152600c81526b22a9219b99189d22969a181960a11b928101929092526001600160a01b03881691612d68565b90506000818060200190518101906129e191906135a5565b6001600160e01b031916630a85bd0160e11b1492505050949350505050565b6001600160a01b038216612a265760405162461bcd60e51b815260040161086c906138a0565b612a2f81611918565b15612a4c5760405162461bcd60e51b815260040161086c90613afb565b6001600160a01b0382166000908152600160205260409020612a6e9082612b6b565b50612a7b60028284612b77565b5060405181906001600160a01b038416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b60009081526001919091016020526040902054151590565b6060612b25826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612d689092919063ffffffff16565b8051909150156109075780806020019051810190612b43919061356d565b6109075760405162461bcd60e51b815260040161086c90613c30565b6000610b6e8383612d77565b6000610b6e8383612e3d565b6000610b4484846001600160a01b038516612e87565b6040516370a0823160e01b81526000906001600160a01b038416906370a0823190612bbc90879060040161367e565b60206040518083038186803b158015612bd457600080fd5b505afa158015612be8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c0c91906135d9565b905080821115612c2e5760405162461bcd60e51b815260040161086c90613bea565b6040516323b872dd60e01b81526001600160a01b038416906323b872dd90612c5e908790309087906004016136c5565b602060405180830381600087803b158015612c7857600080fd5b505af1158015612c8c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cb0919061356d565b6112fe5760405162461bcd60e51b815260040161086c90613c7a565b60008183612ced5760405162461bcd60e51b815260040161086c91906137e2565b506000838581612cf957fe5b0495945050505050565b60008184841115612d275760405162461bcd60e51b815260040161086c91906137e2565b505050900390565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470818114801590610b44575050151592915050565b6060610b448484600085612f1e565b60008181526001830160205260408120548015612e335783546000198083019190810190600090879083908110612daa57fe5b9060005260206000200154905080876000018481548110612dc757fe5b600091825260208083209091019290925582815260018981019092526040902090840190558654879080612df757fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050610b71565b6000915050610b71565b6000612e498383612ab8565b612e7f57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610b71565b506000610b71565b600082815260018401602052604081205480612eec575050604080518082018252838152602080820184815286546001818101895560008981528481209551600290930290950191825591519082015586548684528188019092529290912055611e2e565b82856000016001830381548110612eff57fe5b9060005260206000209060020201600101819055506000915050611e2e565b6060612f2985612d2f565b612f455760405162461bcd60e51b815260040161086c90613b6a565b60006060866001600160a01b03168587604051612f629190613662565b60006040518083038185875af1925050503d8060008114612f9f576040519150601f19603f3d011682016040523d82523d6000602084013e612fa4565b606091505b50915091508115612fb8579150610b449050565b805115612fc85780518082602001fd5b8360405162461bcd60e51b815260040161086c91906137e2565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061302357805160ff1916838001178555613050565b82800160010185558215613050579182015b82811115613050578251825591602001919060010190613035565b5061305c929150613060565b5090565b5b8082111561305c5760008155600101613061565b60008083601f840112613086578182fd5b50813567ffffffffffffffff81111561309d578182fd5b6020830191508360208083028501011115611caa57600080fd5b600082601f8301126130c7578081fd5b813567ffffffffffffffff808211156130de578283fd5b604051601f8301601f1916810160200182811182821017156130fe578485fd5b60405282815292508284830160200186101561311957600080fd5b8260208601602083013760006020848301015250505092915050565b600060208284031215613146578081fd5b8135610b6e81613ddc565b600060208284031215613162578081fd5b8151610b6e81613ddc565b600080600060608486031215613181578182fd5b833561318c81613ddc565b9250602084013561319c81613ddc565b929592945050506040919091013590565b600080604083850312156131bf578182fd5b82356131ca81613ddc565b946020939093013593505050565b600080604083850312156131ea578182fd5b82356131f581613ddc565b9150602083013561320581613ddc565b809150509250929050565b600080600080600080600080610100898b03121561322c578384fd5b883561323781613ddc565b9750602089013561324781613ddc565b9650604089013561325781613ddc565b9550606089013567ffffffffffffffff80821115613273578586fd5b61327f8c838d016130b7565b965060808b0135915080821115613294578586fd5b506132a18b828c016130b7565b94505060a08901356132b281613ddc565b979a969950949793969295929450505060c08201359160e0013590565b6000806000606084860312156132e3578283fd5b83356132ee81613ddc565b925060208401356132fe81613ddc565b9150604084013567ffffffffffffffff811115613319578182fd5b613325868287016130b7565b9150509250925092565b60008060008060808587031215613344578384fd5b843561334f81613ddc565b9350602085013561335f81613ddc565b9250604085013567ffffffffffffffff81111561337a578283fd5b613386878288016130b7565b949793965093946060013593505050565b60008060008060008060c087890312156133af578182fd5b86356133ba81613ddc565b955060208701356133ca81613ddc565b9450604087013567ffffffffffffffff8111156133e5578283fd5b6133f189828a016130b7565b945050606087013592506080870135915060a087013590509295509295509295565b600080600060608486031215613181578081fd5b6000806000806080858703121561343c578182fd5b843561344781613ddc565b9350602085013561345781613ddc565b925060408501359150606085013567ffffffffffffffff811115613479578182fd5b613485878288016130b7565b91505092959194509250565b600080604083850312156134a3578182fd5b82356134ae81613ddc565b9150602083013561320581613df4565b600080600080600080600060a0888a0312156134d8578081fd5b87356134e381613ddc565b96506020880135955060408801359450606088013567ffffffffffffffff8082111561350d578283fd5b6135198b838c01613075565b909650945060808a0135915080821115613531578283fd5b5061353e8a828b01613075565b989b979a50959850939692959293505050565b600060208284031215613562578081fd5b8135610b6e81613df4565b60006020828403121561357e578081fd5b8151610b6e81613df4565b60006020828403121561359a578081fd5b8135610b6e81613e02565b6000602082840312156135b6578081fd5b8151610b6e81613e02565b6000602082840312156135d2578081fd5b5035919050565b6000602082840312156135ea578081fd5b5051919050565b60008060408385031215613603578182fd5b82359150602083013561320581613ddc565b60008060408385031215613627578182fd5b50508035926020909101359150565b6000815180845261364e816020860160208601613db0565b601f01601f19169290920160200192915050565b60008251613674818460208701613db0565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906117d090830184613636565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039788168152602081019690965293861660408601529185166060850152608084015290921660a082015260c081019190915260e00190565b6001600160a01b039485168152602081019390935292166040820152606081019190915260800190565b6001600160a01b0393909316835260208301919091521515604082015260600190565b600060018060a01b03808916835287602084015260c060408401526137b760c0840188613636565b9581166060840152608083019490945250911660a0909101529392505050565b901515815260200190565b600060208252610b6e6020830184613636565b60208082526022908201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e604082015261647360f01b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252600990820152684248503a452d34303360b81b604082015260600190565b6020808252600c908201526b4552433732313a452d34303360a01b604082015260600190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b60208082526009908201526828292a1d229699181960b91b604082015260600190565b6020808252603a908201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260408201527f6563697069656e74206d61792068617665207265766572746564000000000000606082015260800190565b6020808252601d908201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604082015260600190565b6020808252600990820152681414950e914b4d0c4d60ba1b604082015260600190565b60208082526009908201526828292a1d22969a189b60b91b604082015260600190565b6020808252600990820152685052543a452d34323160b81b604082015260600190565b6020808252600c908201526b22a9219b99189d22969a181960a11b604082015260600190565b60208082526022908201527f456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e604082015261647360f01b606082015260800190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252600c908201526b4552433732313a452d34303760a01b604082015260600190565b6020808252600c908201526b4552433732313a452d31303560a01b604082015260600190565b6020808252600990820152681414950e914b4c4c0d60ba1b604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252600990820152685052543a452d31303760b81b604082015260600190565b6020808252600c908201526b22a9219b99189d229698981960a11b604082015260600190565b6020808252600990820152685052543a452d34313160b81b604082015260600190565b6020808252600990820152685052543a452d31303160b81b604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b6020808252600990820152685052543a452d34303160b81b604082015260600190565b6020808252600c908201526b4552433732313a452d34303560a01b604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b6020808252600990820152685052543a452d31303560b81b604082015260600190565b6020808252600c908201526b4552433732313a452d31313160a01b604082015260600190565b90815260200190565b9283526001600160a01b03919091166020830152604082015260600190565b6000808335601e19843603018112613d81578283fd5b83018035915067ffffffffffffffff821115613d9b578283fd5b602001915036819003821315611caa57600080fd5b60005b83811015613dcb578181015183820152602001613db3565b838111156112fe5750506000910152565b6001600160a01b0381168114613df157600080fd5b50565b8015158114613df157600080fd5b6001600160e01b031981168114613df157600080fdfe312e302e302d626574612e312f636861726765642d7061727469636c65732e72656c61792e726563697069656e74a264697066735822122028fbe68b62bbb0e10110074cd41f6ee66954e8de08551f27375a59b09be3843d64736f6c634300060c0033

Block Transaction Difficulty Gas Used Reward
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.