Address Contract Partially Verified
Address
0x87b008E57F640D94Ee44Fd893F0323AF933F9195
Balance
0 ETH
Nonce
1
Code Size
9049 bytes
Creator
0x3E395051...a0CF at tx 0x50a4be29...148ffe
Indexed Transactions
0
Contract Bytecode
9049 bytes
0x60806040526004361061019c5760003560e01c806370a08231116100ec578063986502751161008a578063aa271e1a11610064578063aa271e1a146105ca578063d54f9d09146105fd578063dd62ed3e14610605578063e6b9e897146106405761019c565b80639865027514610543578063a457c2d714610558578063a9059cbb146105915761019c565b8063841815ef116100c6578063841815ef146104d15780638456cb59146104e657806395d89b41146104fb578063983b2d56146105105761019c565b806370a082311461043257806379cc67901461046557806382dc1ec41461049e5761019c565b8063395093511161015957806342966c681161013357806342966c68146103ab57806346fbf68e146103d55780635c975abb146104085780636ef8d66d1461041d5761019c565b806339509351146103225780633f4ba83a1461035b57806340c10f19146103725761019c565b806306fdde03146101a1578063095ea7b31461022b57806318160ddd1461027857806323b872dd1461029f578063313ce567146102e2578063355274ea1461030d575b600080fd5b3480156101ad57600080fd5b506101b6610673565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101f05781810151838201526020016101d8565b50505050905090810190601f16801561021d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561023757600080fd5b506102646004803603604081101561024e57600080fd5b506001600160a01b038135169060200135610709565b604080519115158252519081900360200190f35b34801561028457600080fd5b5061028d610768565b60408051918252519081900360200190f35b3480156102ab57600080fd5b50610264600480360360608110156102c257600080fd5b506001600160a01b0381358116916020810135909116906040013561076e565b3480156102ee57600080fd5b506102f76107cf565b6040805160ff9092168252519081900360200190f35b34801561031957600080fd5b5061028d6107d8565b34801561032e57600080fd5b506102646004803603604081101561034557600080fd5b506001600160a01b0381351690602001356107de565b34801561036757600080fd5b50610370610836565b005b34801561037e57600080fd5b506102646004803603604081101561039557600080fd5b506001600160a01b03813516906020013561091f565b3480156103b757600080fd5b50610370600480360360208110156103ce57600080fd5b503561097f565b3480156103e157600080fd5b50610264600480360360208110156103f857600080fd5b50356001600160a01b0316610993565b34801561041457600080fd5b506102646109ac565b34801561042957600080fd5b506103706109b5565b34801561043e57600080fd5b5061028d6004803603602081101561045557600080fd5b50356001600160a01b03166109c7565b34801561047157600080fd5b506103706004803603604081101561048857600080fd5b506001600160a01b0381351690602001356109e2565b3480156104aa57600080fd5b50610370600480360360208110156104c157600080fd5b50356001600160a01b03166109f0565b3480156104dd57600080fd5b50610264610a3f565b3480156104f257600080fd5b50610370610a4f565b34801561050757600080fd5b506101b6610b16565b34801561051c57600080fd5b506103706004803603602081101561053357600080fd5b50356001600160a01b0316610b76565b34801561054f57600080fd5b50610370610bc5565b34801561056457600080fd5b506102646004803603604081101561057b57600080fd5b506001600160a01b038135169060200135610bd5565b34801561059d57600080fd5b50610264600480360360408110156105b457600080fd5b506001600160a01b038135169060200135610c2d565b3480156105d657600080fd5b50610264600480360360208110156105ed57600080fd5b50356001600160a01b0316610c85565b610370610c98565b34801561061157600080fd5b5061028d6004803603604081101561062857600080fd5b506001600160a01b0381358116916020013516611005565b34801561064c57600080fd5b506103706004803603602081101561066357600080fd5b50356001600160a01b0316611030565b60008054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106ff5780601f106106d4576101008083540402835291602001916106ff565b820191906000526020600020905b8154815290600101906020018083116106e257829003601f168201915b5050505050905090565b60095460009060ff1615610757576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b61076183836114ef565b9392505050565b60055490565b60095460009060ff16156107bc576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6107c7848484611503565b949350505050565b60025460ff1690565b60075490565b60095460009060ff161561082c576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6107618383611590565b6108466108416115e4565b610993565b6108815760405162461bcd60e51b8152600401808060200182810382526030815260200180611fc86030913960400191505060405180910390fd5b60095460ff166108cf576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b6009805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6109026115e4565b604080516001600160a01b039092168252519081900360200190a1565b600061093161092c6115e4565b610c85565b61096c5760405162461bcd60e51b81526004018080602001828103825260308152602001806120f66030913960400191505060405180910390fd5b61097683836115e8565b50600192915050565b61099061098a6115e4565b82611660565b50565b60006109a660088363ffffffff61175c16565b92915050565b60095460ff1690565b6109c56109c06115e4565b6117c3565b565b6001600160a01b031660009081526003602052604090205490565b6109ec828261180b565b5050565b6109fb6108416115e4565b610a365760405162461bcd60e51b8152600401808060200182810382526030815260200180611fc86030913960400191505060405180910390fd5b6109908161185f565b600954600160a81b900460ff1690565b610a5a6108416115e4565b610a955760405162461bcd60e51b8152600401808060200182810382526030815260200180611fc86030913960400191505060405180910390fd5b60095460ff1615610ae0576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6009805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586109026115e4565b60018054604080516020601f600260001961010087891615020190951694909404938401819004810282018101909252828152606093909290918301828280156106ff5780601f106106d4576101008083540402835291602001916106ff565b610b8161092c6115e4565b610bbc5760405162461bcd60e51b81526004018080602001828103825260308152602001806120f66030913960400191505060405180910390fd5b610990816118a7565b6109c5610bd06115e4565b6118ef565b60095460009060ff1615610c23576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6107618383611937565b60095460009060ff1615610c7b576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b61076183836119a5565b60006109a660068363ffffffff61175c16565b600954600160a81b900460ff1615610ce15760405162461bcd60e51b815260040180806020018281038252602581526020018061204b6025913960400191505060405180910390fd5b600960019054906101000a90046001600160a01b03166001600160a01b031663d7a97c7f6040518163ffffffff1660e01b815260040160206040518083038186803b158015610d2f57600080fd5b505afa158015610d43573d6000803e3d6000fd5b505050506040513d6020811015610d5957600080fd5b5051610d965760405162461bcd60e51b81526004018080602001828103825260408152602001806121476040913960400191505060405180910390fd5b600960019054906101000a90046001600160a01b03166001600160a01b031663b871a57e6040518163ffffffff1660e01b815260040160206040518083038186803b158015610de457600080fd5b505afa158015610df8573d6000803e3d6000fd5b505050506040513d6020811015610e0e57600080fd5b5051610e4b5760405162461bcd60e51b81526004018080602001828103825260308152602001806120c66030913960400191505060405180910390fd5b60003411610e8a5760405162461bcd60e51b815260040180806020018281038252604b815260200180612289604b913960600191505060405180910390fd5b6000610e95336109c7565b905060008111610ed65760405162461bcd60e51b8152600401808060200182810382526030815260200180611f766030913960400191505060405180910390fd5b610ede6107d8565b8110610f1b5760405162461bcd60e51b815260040180806020018281038252602c8152602001806122d4602c913960400191505060405180910390fd5b600954610f3e9061010090046001600160a01b0316610f39336109c7565b610c2d565b5060095460408051631cdc340160e01b815233600482015260248101849052905160009261010090046001600160a01b031691631cdc340191349160448082019260209290919082900301818588803b158015610f9a57600080fd5b505af1158015610fae573d6000803e3d6000fd5b50505050506040513d6020811015610fc557600080fd5b50519050806109ec5760405162461bcd60e51b815260040180806020018281038252602a815260200180612216602a913960400191505060405180910390fd5b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b60008190506000816001600160a01b0316634faf28386040518163ffffffff1660e01b815260040160206040518083038186803b15801561107057600080fd5b505afa158015611084573d6000803e3d6000fd5b505050506040513d602081101561109a57600080fd5b50519050806110f757816001600160a01b031663767c56a26040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156110de57600080fd5b505af11580156110f2573d6000803e3d6000fd5b505050505b80806111645750816001600160a01b0316634faf28386040518163ffffffff1660e01b815260040160206040518083038186803b15801561113757600080fd5b505afa15801561114b573d6000803e3d6000fd5b505050506040513d602081101561116157600080fd5b50515b61119f5760405162461bcd60e51b81526004018080602001828103825260308152602001806120966030913960400191505060405180910390fd5b60006111aa336109c7565b905060008111806112275750826001600160a01b0316636dce6c5e6040518163ffffffff1660e01b815260040160206040518083038186803b1580156111ef57600080fd5b505afa158015611203573d6000803e3d6000fd5b505050506040513d602081101561121957600080fd5b50516001600160a01b031633145b6112625760405162461bcd60e51b815260040180806020018281038252603181526020018061201a6031913960400191505060405180910390fd5b6001836001600160a01b031663237297a46040518163ffffffff1660e01b815260040160206040518083038186803b15801561129d57600080fd5b505afa1580156112b1573d6000803e3d6000fd5b505050506040513d60208110156112c757600080fd5b505160028111156112d457fe5b14801561134e5750826001600160a01b0316636dce6c5e6040518163ffffffff1660e01b815260040160206040518083038186803b15801561131557600080fd5b505afa158015611329573d6000803e3d6000fd5b505050506040513d602081101561133f57600080fd5b50516001600160a01b03163314155b8061143f57506002836001600160a01b031663237297a46040518163ffffffff1660e01b815260040160206040518083038186803b15801561138f57600080fd5b505afa1580156113a3573d6000803e3d6000fd5b505050506040513d60208110156113b957600080fd5b505160028111156113c657fe5b14801561143f5750826001600160a01b0316636dce6c5e6040518163ffffffff1660e01b815260040160206040518083038186803b15801561140757600080fd5b505afa15801561141b573d6000803e3d6000fd5b505050506040513d602081101561143157600080fd5b50516001600160a01b031633145b61147a5760405162461bcd60e51b8152600401808060200182810382526042815260200180611f116042913960600191505060405180910390fd5b6114838161097f565b6040805163100928bb60e11b81526004810183905233602482015290516001600160a01b03851691632012517691604480830192600092919082900301818387803b1580156114d157600080fd5b505af11580156114e5573d6000803e3d6000fd5b5050505050505050565b60006109766114fc6115e4565b84846119b9565b6000611510848484611aa5565b6115868461151c6115e4565b61158185604051806060016040528060288152602001612187602891396001600160a01b038a1660009081526004602052604081209061155a6115e4565b6001600160a01b03168152602081019190915260400160002054919063ffffffff611c0316565b6119b9565b5060019392505050565b600061097661159d6115e4565b8461158185600460006115ae6115e4565b6001600160a01b03908116825260208083019390935260409182016000908120918c16815292529020549063ffffffff611c9a16565b3390565b600754611603826115f7610768565b9063ffffffff611c9a16565b1115611656576040805162461bcd60e51b815260206004820152601960248201527f45524332304361707065643a2063617020657863656564656400000000000000604482015290519081900360640190fd5b6109ec8282611cf4565b6001600160a01b0382166116a55760405162461bcd60e51b81526004018080602001828103825260218152602001806121f56021913960400191505060405180910390fd5b6116e881604051806060016040528060228152602001611fa6602291396001600160a01b038516600090815260036020526040902054919063ffffffff611c0316565b6001600160a01b038316600090815260036020526040902055600554611714908263ffffffff611de616565b6005556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b60006001600160a01b0382166117a35760405162461bcd60e51b81526004018080602001828103825260228152602001806121af6022913960400191505060405180910390fd5b506001600160a01b03166000908152602091909152604090205460ff1690565b6117d460088263ffffffff611e2816565b6040516001600160a01b038216907fcd265ebaf09df2871cc7bd4133404a235ba12eff2041bb89d9c714a2621c7c7e90600090a250565b6118158282611660565b6109ec826118216115e4565b611581846040518060600160405280602481526020016121d1602491396001600160a01b03881660009081526004602052604081209061155a6115e4565b61187060088263ffffffff611e8f16565b6040516001600160a01b038216907f6719d08c1888103bea251a4ed56406bd0c3e69723c8a1686e017e7bbe159b6f890600090a250565b6118b860068263ffffffff611e8f16565b6040516001600160a01b038216907f6ae172837ea30b801fbfcdd4108aa1d5bf8ff775444fd70256b44e6bf3dfc3f690600090a250565b61190060068263ffffffff611e2816565b6040516001600160a01b038216907fe94479a9f7e1952cc78f2d6baab678adc1b772d936c6583def489e524cb6669290600090a250565b60006109766119446115e4565b8461158185604051806060016040528060258152602001612300602591396004600061196e6115e4565b6001600160a01b03908116825260208083019390935260409182016000908120918d1681529252902054919063ffffffff611c0316565b60006109766119b26115e4565b8484611aa5565b6001600160a01b0383166119fe5760405162461bcd60e51b81526004018080602001828103825260248152602001806122656024913960400191505060405180910390fd5b6001600160a01b038216611a435760405162461bcd60e51b8152600401808060200182810382526022815260200180611ff86022913960400191505060405180910390fd5b6001600160a01b03808416600081815260046020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b038316611aea5760405162461bcd60e51b81526004018080602001828103825260258152602001806122406025913960400191505060405180910390fd5b6001600160a01b038216611b2f5760405162461bcd60e51b8152600401808060200182810382526023815260200180611f536023913960400191505060405180910390fd5b611b7281604051806060016040528060268152602001612070602691396001600160a01b038616600090815260036020526040902054919063ffffffff611c0316565b6001600160a01b038085166000908152600360205260408082209390935590841681522054611ba7908263ffffffff611c9a16565b6001600160a01b0380841660008181526003602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b60008184841115611c925760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611c57578181015183820152602001611c3f565b50505050905090810190601f168015611c845780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600082820183811015610761576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6001600160a01b038216611d4f576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b600554611d62908263ffffffff611c9a16565b6005556001600160a01b038216600090815260036020526040902054611d8e908263ffffffff611c9a16565b6001600160a01b03831660008181526003602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b600061076183836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611c03565b611e32828261175c565b611e6d5760405162461bcd60e51b81526004018080602001828103825260218152602001806121266021913960400191505060405180910390fd5b6001600160a01b0316600090815260209190915260409020805460ff19169055565b611e99828261175c565b15611eeb576040805162461bcd60e51b815260206004820152601f60248201527f526f6c65733a206163636f756e7420616c72656164792068617320726f6c6500604482015290519081900360640190fd5b6001600160a01b0316600090815260209190915260409020805460ff1916600117905556fe5b6275726e416e64436f6c6c65637445746865725d204163636f756e7420646f6573206e6f74206861766520726967687420746f20636f6c6c65637420657468657245524332303a207472616e7366657220746f20746865207a65726f20616464726573735b6c6f636b536861726473416e64436c61696d5d204163636f756e7420646f6573206e6f74206f776e2053686172647345524332303a206275726e20616d6f756e7420657863656564732062616c616e6365506175736572526f6c653a2063616c6c657220646f6573206e6f742068617665207468652050617573657220726f6c6545524332303a20617070726f766520746f20746865207a65726f20616464726573735b6275726e416e64436f6c6c65637445746865725d204163636f756e7420646f6573206e6f74206f776e205368617264735b6c6f636b536861726473416e64436c61696d5d2053686f7467756e2064697361626c656445524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e63655b6275726e416e64436f6c6c65637445746865725d2053686f7467756e20436c61757365206e6f7420656e61637465645b6c6f636b536861726473416e64436c61696d5d2053686f7467756e20616c726561647920696e2070726f67726573734d696e746572526f6c653a2063616c6c657220646f6573206e6f74206861766520746865204d696e74657220726f6c65526f6c65733a206163636f756e7420646f6573206e6f74206861766520726f6c655b6c6f636b536861726473416e64436c61696d5d204e4654206e6f74206c6f636b65642c2053686f7467756e2063616e6e6f742062652074726967676572656445524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365526f6c65733a206163636f756e7420697320746865207a65726f206164647265737345524332303a206275726e20616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f20616464726573735b6c6f636b5368617264735d20457468657220666f7277617264696e6720756e7375636365737366756c45524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573735b6c6f636b536861726473416e64436c61696d5d205472616e73616374696f6e206d7573742073656e6420657468657220746f2061637469766174652053686f7467756e20436c617573655b6c6f636b536861726473416e64436c61696d5d204163636f756e74206f776e7320616c6c2053686172647345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa265627a7a72315820626974d54c21d3f9a09ce4d5fe8b932dbc17dcb401e0424d78e13d4fbd6ccf2064736f6c634300050f0032
Verified Source Code Partial Match
Compiler: v0.5.15+commit.6a57276f
EVM: istanbul
Optimization: Yes (200 runs)
ShardRegistry.sol 1826 lines
/**
*Submitted for verification at Etherscan.io on 2020-09-03
*/
/* solhint-disable no-mix-tabs-and-spaces */
/* solhint-disable indent */
pragma solidity 0.5.15;
/**
* @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);
}
/**
* @dev Required interface of an ERC721 compliant contract.
*/
contract IERC721 is IERC165 {
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of NFTs in `owner`'s account.
*/
function balanceOf(address owner) public view returns (uint256 balance);
/**
* @dev Returns the owner of the NFT specified by `tokenId`.
*/
function ownerOf(uint256 tokenId) public view returns (address owner);
/**
* @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to
* another (`to`).
*
*
*
* Requirements:
* - `from`, `to` cannot be zero.
* - `tokenId` must be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this
* NFT by either {approve} or {setApprovalForAll}.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) public;
/**
* @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to
* another (`to`).
*
* Requirements:
* - If the caller is not `from`, it must be approved to move this NFT by
* either {approve} or {setApprovalForAll}.
*/
function transferFrom(address from, address to, uint256 tokenId) public;
function approve(address to, uint256 tokenId) public;
function getApproved(uint256 tokenId) public view returns (address operator);
function setApprovalForAll(address operator, bool _approved) public;
function isApprovedForAll(address owner, address operator) public view returns (bool);
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public;
}
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
contract IERC721Receiver {
/**
* @notice Handle the receipt of an NFT
* @dev The ERC721 smart contract calls this function on the recipient
* after a {IERC721-safeTransferFrom}. This function MUST return the function selector,
* otherwise the caller will revert the transaction. The selector to be
* returned can be obtained as `this.onERC721Received.selector`. This
* function MAY throw to revert and reject the transfer.
* Note: the ERC721 contract address is always the message sender.
* @param operator The address which called `safeTransferFrom` function
* @param from The address which previously owned the token
* @param tokenId The NFT identifier which is being transferred
* @param data Additional data with no specified format
* @return bytes4 `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
*/
function onERC721Received(address operator, address from, uint256 tokenId, bytes memory data)
public returns (bytes4);
}
/**
* @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.
*
* _Available since v2.4.0._
*/
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.
*
* _Available since v2.4.0._
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
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.
*
* _Available since v2.4.0._
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
/* solhint-disable no-mix-tabs-and-spaces */
/* solhint-disable indent */
/**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/
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);
}
/**
* @dev Optional functions from the ERC20 standard.
*/
contract ERC20Detailed is IERC20 {
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for `name`, `symbol`, and `decimals`. All three of
* these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name, string memory symbol, uint8 decimals) public {
_name = name;
_symbol = symbol;
_decimals = decimals;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
}
/*
* @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.
*/
contract Context {
// Empty internal constructor, to prevent people from mistakenly deploying
// an instance of this contract, which should be used via inheritance.
constructor () internal { }
// solhint-disable-previous-line no-empty-blocks
function _msgSender() internal view returns (address payable) {
return msg.sender;
}
function _msgData() internal view returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20Mintable}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for `sender`'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Destroys `amount` tokens from `account`.`amount` is then deducted
* from the caller's allowance.
*
* See {_burn} and {_approve}.
*/
function _burnFrom(address account, uint256 amount) internal {
_burn(account, amount);
_approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance"));
}
}
/**
* @title Roles
* @dev Library for managing addresses assigned to a Role.
*/
library Roles {
struct Role {
mapping (address => bool) bearer;
}
/**
* @dev Give an account access to this role.
*/
function add(Role storage role, address account) internal {
require(!has(role, account), "Roles: account already has role");
role.bearer[account] = true;
}
/**
* @dev Remove an account's access to this role.
*/
function remove(Role storage role, address account) internal {
require(has(role, account), "Roles: account does not have role");
role.bearer[account] = false;
}
/**
* @dev Check if an account has this role.
* @return bool
*/
function has(Role storage role, address account) internal view returns (bool) {
require(account != address(0), "Roles: account is the zero address");
return role.bearer[account];
}
}
contract MinterRole is Context {
using Roles for Roles.Role;
event MinterAdded(address indexed account);
event MinterRemoved(address indexed account);
Roles.Role private _minters;
constructor () internal {
_addMinter(_msgSender());
}
modifier onlyMinter() {
require(isMinter(_msgSender()), "MinterRole: caller does not have the Minter role");
_;
}
function isMinter(address account) public view returns (bool) {
return _minters.has(account);
}
function addMinter(address account) public onlyMinter {
_addMinter(account);
}
function renounceMinter() public {
_removeMinter(_msgSender());
}
function _addMinter(address account) internal {
_minters.add(account);
emit MinterAdded(account);
}
function _removeMinter(address account) internal {
_minters.remove(account);
emit MinterRemoved(account);
}
}
/**
* @dev Extension of {ERC20} that adds a set of accounts with the {MinterRole},
* which have permission to mint (create) new tokens as they see fit.
*
* At construction, the deployer of the contract is the only minter.
*/
contract ERC20Mintable is ERC20, MinterRole {
/**
* @dev See {ERC20-_mint}.
*
* Requirements:
*
* - the caller must have the {MinterRole}.
*/
function mint(address account, uint256 amount) public onlyMinter returns (bool) {
_mint(account, amount);
return true;
}
}
/**
* @dev Extension of {ERC20Mintable} that adds a cap to the supply of tokens.
*/
contract ERC20Capped is ERC20Mintable {
uint256 private _cap;
/**
* @dev Sets the value of the `cap`. This value is immutable, it can only be
* set once during construction.
*/
constructor (uint256 cap) public {
require(cap > 0, "ERC20Capped: cap is 0");
_cap = cap;
}
/**
* @dev Returns the cap on the token's total supply.
*/
function cap() public view returns (uint256) {
return _cap;
}
/**
* @dev See {ERC20Mintable-mint}.
*
* Requirements:
*
* - `value` must not cause the total supply to go over the cap.
*/
function _mint(address account, uint256 value) internal {
require(totalSupply().add(value) <= _cap, "ERC20Capped: cap exceeded");
super._mint(account, value);
}
}
/**
* @dev Extension of {ERC20} that allows token holders to destroy both their own
* tokens and those that they have an allowance for, in a way that can be
* recognized off-chain (via event analysis).
*/
contract ERC20Burnable is Context, ERC20 {
/**
* @dev Destroys `amount` tokens from the caller.
*
* See {ERC20-_burn}.
*/
function burn(uint256 amount) public {
_burn(_msgSender(), amount);
}
/**
* @dev See {ERC20-_burnFrom}.
*/
function burnFrom(address account, uint256 amount) public {
_burnFrom(account, amount);
}
}
contract PauserRole is Context {
using Roles for Roles.Role;
event PauserAdded(address indexed account);
event PauserRemoved(address indexed account);
Roles.Role private _pausers;
constructor () internal {
_addPauser(_msgSender());
}
modifier onlyPauser() {
require(isPauser(_msgSender()), "PauserRole: caller does not have the Pauser role");
_;
}
function isPauser(address account) public view returns (bool) {
return _pausers.has(account);
}
function addPauser(address account) public onlyPauser {
_addPauser(account);
}
function renouncePauser() public {
_removePauser(_msgSender());
}
function _addPauser(address account) internal {
_pausers.add(account);
emit PauserAdded(account);
}
function _removePauser(address account) internal {
_pausers.remove(account);
emit PauserRemoved(account);
}
}
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
contract Pausable is Context, PauserRole {
/**
* @dev Emitted when the pause is triggered by a pauser (`account`).
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by a pauser (`account`).
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state. Assigns the Pauser role
* to the deployer.
*/
constructor () internal {
_paused = false;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view returns (bool) {
return _paused;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!_paused, "Pausable: paused");
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(_paused, "Pausable: not paused");
_;
}
/**
* @dev Called by a pauser to pause, triggers stopped state.
*/
function pause() public onlyPauser whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Called by a pauser to unpause, returns to normal state.
*/
function unpause() public onlyPauser whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
/**
* @title Pausable token
* @dev ERC20 with pausable transfers and allowances.
*
* Useful if you want to stop trades until the end of a crowdsale, or have
* an emergency switch for freezing all token transfers in the event of a large
* bug.
*/
contract ERC20Pausable is ERC20, Pausable {
function transfer(address to, uint256 value) public whenNotPaused returns (bool) {
return super.transfer(to, value);
}
function transferFrom(address from, address to, uint256 value) public whenNotPaused returns (bool) {
return super.transferFrom(from, to, value);
}
function approve(address spender, uint256 value) public whenNotPaused returns (bool) {
return super.approve(spender, value);
}
function increaseAllowance(address spender, uint256 addedValue) public whenNotPaused returns (bool) {
return super.increaseAllowance(spender, addedValue);
}
function decreaseAllowance(address spender, uint256 subtractedValue) public whenNotPaused returns (bool) {
return super.decreaseAllowance(spender, subtractedValue);
}
}
/* solhint-disable no-mix-tabs-and-spaces */
/* solhint-disable indent */
/**
* @title Contract managing Shotgun Clause lifecycle
* @author Joel Hubert (Metalith.io)
* @dev OpenZeppelin contracts are not ready for 0.6.0 yet, using 0.5.16.
* @dev This contract is deployed once a Shotgun is initiated by calling the Registry.
*/
contract ShotgunClause {
using SafeMath for uint256;
ShardGovernor private _shardGovernor;
ShardRegistry private _shardRegistry;
enum ClaimWinner { None, Claimant, Counterclaimant }
ClaimWinner private _claimWinner = ClaimWinner.None;
uint private _deadlineTimestamp;
uint private _initialOfferInWei;
uint private _pricePerShardInWei;
address payable private _initialClaimantAddress;
uint private _initialClaimantBalance;
bool private _shotgunEnacted = false;
uint private _counterWeiContributed;
address[] private _counterclaimants;
mapping(address => uint) private _counterclaimContribs;
event Countercommit(address indexed committer, uint indexed weiAmount);
event EtherCollected(address indexed collector, uint indexed weiAmount);
constructor(
address payable initialClaimantAddress,
uint initialClaimantBalance,
address shardRegistryAddress
) public payable {
_shardGovernor = ShardGovernor(msg.sender);
_shardRegistry = ShardRegistry(shardRegistryAddress);
_deadlineTimestamp = now.add(1 * 14 days);
_initialClaimantAddress = initialClaimantAddress;
_initialClaimantBalance = initialClaimantBalance;
_initialOfferInWei = msg.value;
_pricePerShardInWei = (_initialOfferInWei.mul(10**18)).div(_shardRegistry.cap().sub(_initialClaimantBalance));
_claimWinner = ClaimWinner.Claimant;
}
/**
* @notice Contribute Ether to the counterclaim for this Shotgun.
* @dev Automatically enacts Shotgun once enough Ether is raised and
returns initial claimant's Ether offer.
*/
function counterCommitEther() external payable {
require(
_shardRegistry.balanceOf(msg.sender) > 0,
"[counterCommitEther] Account does not own Shards"
);
require(
msg.value > 0,
"[counterCommitEther] Ether is required"
);
require(
_initialClaimantAddress != address(0),
"[counterCommitEther] Initial claimant does not exist"
);
require(
msg.sender != _initialClaimantAddress,
"[counterCommitEther] Initial claimant cannot countercommit"
);
require(
!_shotgunEnacted,
"[counterCommitEther] Shotgun already enacted"
);
require(
now < _deadlineTimestamp,
"[counterCommitEther] Deadline has expired"
);
require(
msg.value + _counterWeiContributed <= getRequiredWeiForCounterclaim(),
"[counterCommitEther] Ether exceeds goal"
);
if (_counterclaimContribs[msg.sender] == 0) {
_counterclaimants.push(msg.sender);
}
_counterclaimContribs[msg.sender] = _counterclaimContribs[msg.sender].add(msg.value);
_counterWeiContributed = _counterWeiContributed.add(msg.value);
emit Countercommit(msg.sender, msg.value);
if (_counterWeiContributed == getRequiredWeiForCounterclaim()) {
_claimWinner = ClaimWinner.Counterclaimant;
enactShotgun();
}
}
/**
* @notice Collect ether from completed Shotgun.
* @dev Called by Shard Registry after burning caller's Shards.
* @dev For counterclaimants, returns both the proportional worth of their
Shards in Ether AND any counterclaim contributions they have made.
* @dev alternative: OpenZeppelin PaymentSplitter
*/
function collectEtherProceeds(uint balance, address payable caller) external {
require(
msg.sender == address(_shardRegistry),
"[collectEtherProceeds] Caller not authorized"
);
if (_claimWinner == ClaimWinner.Claimant && caller != _initialClaimantAddress) {
uint weiProceeds = (_pricePerShardInWei.mul(balance)).div(10**18);
weiProceeds = weiProceeds.add(_counterclaimContribs[caller]);
_counterclaimContribs[caller] = 0;
(bool success, ) = address(caller).call.value(weiProceeds)("");
require(success, "[collectEtherProceeds] Transfer failed.");
emit EtherCollected(caller, weiProceeds);
} else if (_claimWinner == ClaimWinner.Counterclaimant && caller == _initialClaimantAddress) {
uint amount = (_pricePerShardInWei.mul(_initialClaimantBalance)).div(10**18);
amount = amount.add(_initialOfferInWei);
_initialClaimantBalance = 0;
(bool success, ) = address(caller).call.value(amount)("");
require(success, "[collectEtherProceeds] Transfer failed.");
emit EtherCollected(caller, amount);
}
}
/**
* @notice Use by successful counterclaimants to collect Shards from initial claimant.
*/
function collectShardProceeds() external {
require(
_shotgunEnacted && _claimWinner == ClaimWinner.Counterclaimant,
"[collectShardProceeds] Shotgun has not been enacted or invalid winner"
);
require(
_counterclaimContribs[msg.sender] != 0,
"[collectShardProceeds] Account has not participated in counterclaim"
);
uint proportionContributed = (_counterclaimContribs[msg.sender].mul(10**18)).div(_counterWeiContributed);
_counterclaimContribs[msg.sender] = 0;
uint shardsToReceive = (proportionContributed.mul(_initialClaimantBalance)).div(10**18);
_shardGovernor.transferShards(msg.sender, shardsToReceive);
}
function deadlineTimestamp() external view returns (uint256) {
return _deadlineTimestamp;
}
function shotgunEnacted() external view returns (bool) {
return _shotgunEnacted;
}
function initialClaimantAddress() external view returns (address) {
return _initialClaimantAddress;
}
function initialClaimantBalance() external view returns (uint) {
return _initialClaimantBalance;
}
function initialOfferInWei() external view returns (uint256) {
return _initialOfferInWei;
}
function pricePerShardInWei() external view returns (uint256) {
return _pricePerShardInWei;
}
function claimWinner() external view returns (ClaimWinner) {
return _claimWinner;
}
function counterclaimants() external view returns (address[] memory) {
return _counterclaimants;
}
function getCounterclaimantContribution(address counterclaimant) external view returns (uint) {
return _counterclaimContribs[counterclaimant];
}
function counterWeiContributed() external view returns (uint) {
return _counterWeiContributed;
}
function getContractBalance() external view returns (uint) {
return address(this).balance;
}
function shardGovernor() external view returns (address) {
return address(_shardGovernor);
}
function getRequiredWeiForCounterclaim() public view returns (uint) {
return (_pricePerShardInWei.mul(_initialClaimantBalance)).div(10**18);
}
/**
* @notice Initiate Shotgun enactment.
* @dev Automatically called if enough Ether is raised by counterclaimants,
or manually called if deadline expires without successful counterclaim.
*/
function enactShotgun() public {
require(
!_shotgunEnacted,
"[enactShotgun] Shotgun already enacted"
);
require(
_claimWinner == ClaimWinner.Counterclaimant ||
(_claimWinner == ClaimWinner.Claimant && now > _deadlineTimestamp),
"[enactShotgun] Conditions not met to enact Shotgun Clause"
);
_shotgunEnacted = true;
_shardGovernor.enactShotgun();
}
}
/**
* @title ERC20 base for Shards with additional methods related to governance
* @author Joel Hubert (Metalith.io)
* @dev OpenZeppelin contracts are not ready for 0.6.0 yet, using 0.5.16.
*/
contract ShardRegistry is ERC20Detailed, ERC20Capped, ERC20Burnable, ERC20Pausable {
ShardGovernor private _shardGovernor;
enum ClaimWinner { None, Claimant, Counterclaimant }
bool private _shotgunDisabled;
constructor (
uint256 cap,
string memory name,
string memory symbol,
bool shotgunDisabled
) ERC20Detailed(name, symbol, 18) ERC20Capped(cap) public {
_shardGovernor = ShardGovernor(msg.sender);
_shotgunDisabled = shotgunDisabled;
}
/**
* @notice Called to initiate Shotgun claim. Requires Ether.
* @dev Transfers claimant's Shards into Governor contract's custody until
claim is resolved.
* @dev Forwards Ether to Shotgun contract through Governor contract.
*/
function lockShardsAndClaim() external payable {
require(
!_shotgunDisabled,
"[lockShardsAndClaim] Shotgun disabled"
);
require(
_shardGovernor.checkLock(),
"[lockShardsAndClaim] NFT not locked, Shotgun cannot be triggered"
);
require(
_shardGovernor.checkShotgunState(),
"[lockShardsAndClaim] Shotgun already in progress"
);
require(
msg.value > 0,
"[lockShardsAndClaim] Transaction must send ether to activate Shotgun Clause"
);
uint initialClaimantBalance = balanceOf(msg.sender);
require(
initialClaimantBalance > 0,
"[lockShardsAndClaim] Account does not own Shards"
);
require(
initialClaimantBalance < cap(),
"[lockShardsAndClaim] Account owns all Shards"
);
transfer(address(_shardGovernor), balanceOf(msg.sender));
(bool success) = _shardGovernor.claimInitialShotgun.value(msg.value)(
msg.sender, initialClaimantBalance
);
require(
success,
"[lockShards] Ether forwarding unsuccessful"
);
}
/**
* @notice Called to collect Ether from Shotgun proceeds. Burns Shard holdings.
* @dev can be called in both Shotgun outcome scenarios by:
- Initial claimant, if they lose the claim to counterclaimants and their
Shards are bought out
- Counterclaimants, bought out if initial claimant is successful.
* @dev initial claimant does not own Shards at this point because they have
been custodied in Governor contract at start of Shotgun.
* @param shotgunClause address of the relevant Shotgun contract.
*/
function burnAndCollectEther(address shotgunClause) external {
ShotgunClause _shotgunClause = ShotgunClause(shotgunClause);
bool enacted = _shotgunClause.shotgunEnacted();
if (!enacted) {
_shotgunClause.enactShotgun();
}
require(
enacted || _shotgunClause.shotgunEnacted(),
"[burnAndCollectEther] Shotgun Clause not enacted"
);
uint balance = balanceOf(msg.sender);
require(
balance > 0 || msg.sender == _shotgunClause.initialClaimantAddress(),
"[burnAndCollectEther] Account does not own Shards"
);
require(
uint(_shotgunClause.claimWinner()) == uint(ClaimWinner.Claimant) &&
msg.sender != _shotgunClause.initialClaimantAddress() ||
uint(_shotgunClause.claimWinner()) == uint(ClaimWinner.Counterclaimant) &&
msg.sender == _shotgunClause.initialClaimantAddress(),
"[burnAndCollectEther] Account does not have right to collect ether"
);
burn(balance);
_shotgunClause.collectEtherProceeds(balance, msg.sender);
}
function shotgunDisabled() external view returns (bool) {
return _shotgunDisabled;
}
}
/* solhint-disable no-mix-tabs-and-spaces */
/* solhint-disable indent */
/**
* @title Contract managing Shard Offering lifecycle, similar to a crowdsale.
* @author Joel Hubert (Metalith.io)
* @dev OpenZeppelin contracts are not ready for 0.6.0 yet, using 0.5.16.
* @dev Acts as a wallet containing subscriber Ether.
*/
contract ShardOffering {
using SafeMath for uint256;
ShardGovernor private _shardGovernor;
uint private _offeringDeadline;
uint private _pricePerShardInWei;
uint private _contributionTargetInWei;
uint private _liqProviderCutInShards;
uint private _artistCutInShards;
uint private _offererShardAmount;
address[] private _contributors;
mapping(address => uint) private _contributionsinWei;
mapping(address => uint) private _contributionsInShards;
mapping(address => bool) private _hasClaimedShards;
uint private _totalWeiContributed;
uint private _totalShardsClaimed;
bool private _offeringCompleted;
event Contribution(address indexed contributor, uint indexed weiAmount);
event OfferingWrappedUp();
constructor(
uint pricePerShardInWei,
uint shardAmountOffered,
uint liqProviderCutInShards,
uint artistCutInShards,
uint offeringDeadline,
uint cap
) public {
_pricePerShardInWei = pricePerShardInWei;
_liqProviderCutInShards = liqProviderCutInShards;
_artistCutInShards = artistCutInShards;
_offeringDeadline = offeringDeadline;
_shardGovernor = ShardGovernor(msg.sender);
_contributionTargetInWei = (pricePerShardInWei.mul(shardAmountOffered)).div(10**18);
_offererShardAmount = cap.sub(shardAmountOffered).sub(liqProviderCutInShards).sub(artistCutInShards);
}
/**
* @notice Contribute Ether to offering.
* @dev Blocks Offerer from contributing. May be exaggerated.
* @dev if target Ether amount is raised, automatically transfers Ether to Offerer.
*/
function contribute() external payable {
require(
!_offeringCompleted,
"[contribute] Offering is complete"
);
require(
msg.value > 0,
"[contribute] Contribution requires ether"
);
require(
msg.value <= _contributionTargetInWei - _totalWeiContributed,
"[contribute] Ether value exceeds remaining quota"
);
require(
msg.sender != _shardGovernor.offererAddress(),
"[contribute] Offerer cannot contribute"
);
require(
now < _offeringDeadline,
"[contribute] Deadline for offering expired"
);
require(
_shardGovernor.checkLock(),
"[contribute] NFT not locked yet"
);
if (_contributionsinWei[msg.sender] == 0) {
_contributors.push(msg.sender);
}
_contributionsinWei[msg.sender] = _contributionsinWei[msg.sender].add(msg.value);
uint shardAmount = (msg.value.mul(10**18)).div(_pricePerShardInWei);
_contributionsInShards[msg.sender] = _contributionsInShards[msg.sender].add(shardAmount);
_totalWeiContributed = _totalWeiContributed.add(msg.value);
_totalShardsClaimed = _totalShardsClaimed.add(shardAmount);
if (_totalWeiContributed == _contributionTargetInWei) {
_offeringCompleted = true;
(bool success, ) = _shardGovernor.offererAddress().call.value(address(this).balance)("");
require(success, "[contribute] Transfer failed.");
}
emit Contribution(msg.sender, msg.value);
}
/**
* @notice Prematurely end Offering.
* @dev Called by Governor contract when Offering deadline expires and has not
* raised the target amount of Ether.
* @dev reentrancy is guarded in _shardGovernor.checkOfferingAndIssue() by
`hasClaimedShards`.
*/
function wrapUpOffering() external {
require(
msg.sender == address(_shardGovernor),
"[wrapUpOffering] Unauthorized caller"
);
_offeringCompleted = true;
(bool success, ) = _shardGovernor.offererAddress().call.value(address(this).balance)("");
require(success, "[wrapUpOffering] Transfer failed.");
emit OfferingWrappedUp();
}
/**
* @notice Records Shard claim for subcriber.
* @dev Can only be called by Governor contract on Offering close.
* @param claimant wallet address of the person claiming the Shards they
subscribed to.
*/
function claimShards(address claimant) external {
require(
msg.sender == address(_shardGovernor),
"[claimShards] Unauthorized caller"
);
_hasClaimedShards[claimant] = true;
}
function offeringDeadline() external view returns (uint) {
return _offeringDeadline;
}
function getSubEther(address sub) external view returns (uint) {
return _contributionsinWei[sub];
}
function getSubShards(address sub) external view returns (uint) {
return _contributionsInShards[sub];
}
function hasClaimedShards(address claimant) external view returns (bool) {
return _hasClaimedShards[claimant];
}
function pricePerShardInWei() external view returns (uint) {
return _pricePerShardInWei;
}
function offererShardAmount() external view returns (uint) {
return _offererShardAmount;
}
function liqProviderCutInShards() external view returns (uint) {
return _liqProviderCutInShards;
}
function artistCutInShards() external view returns (uint) {
return _artistCutInShards;
}
function offeringCompleted() external view returns (bool) {
return _offeringCompleted;
}
function totalShardsClaimed() external view returns (uint) {
return _totalShardsClaimed;
}
function totalWeiContributed() external view returns (uint) {
return _totalWeiContributed;
}
function contributionTargetInWei() external view returns (uint) {
return _contributionTargetInWei;
}
function getContractBalance() external view returns (uint) {
return address(this).balance;
}
function contributors() external view returns (address[] memory) {
return _contributors;
}
}
/* solhint-disable no-mix-tabs-and-spaces */
/* solhint-disable indent */
interface IUniswapExchange {
function removeLiquidity(
uint256 uniTokenAmount,
uint256 minEth,
uint256 minTokens,
uint256 deadline
) external returns(
uint256, uint256
);
function transferFrom(
address from,
address to,
uint256 value
) external returns (bool);
}
/**
* @title Contract managing Shard lifecycle (NFT custody + Shard issuance and redemption)
* @author Joel Hubert (Metalith.io)
* @dev OpenZeppelin contracts are not ready for 0.6.0 yet, using 0.5.15.
* @dev This contract owns the Registry, Offering and any Shotgun contracts,
* making it the gateway for core state changes.
*/
contract ShardGovernor is IERC721Receiver {
using SafeMath for uint256;
// Equals `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
bytes4 private constant _ERC721_RECEIVED = 0x150b7a02;
ShardRegistry private _shardRegistry;
ShardOffering private _shardOffering;
ShotgunClause private _currentShotgunClause;
address payable private _offererAddress;
address private _nftRegistryAddress;
address payable private _niftexWalletAddress;
address payable private _artistWalletAddress;
uint256 private _tokenId;
enum ClaimWinner { None, Claimant, Counterclaimant }
address[] private _shotgunAddressArray;
mapping(address => uint) private _shotgunMapping;
uint private _shotgunCounter;
event NewShotgun(address indexed shotgun);
event ShardsClaimed(address indexed claimant, uint indexed shardAmount);
event NftRedeemed(address indexed redeemer);
event ShotgunEnacted(address indexed enactor);
event ShardsCollected(address...
// [truncated — 61909 bytes total]
Read Contract
allowance 0xdd62ed3e → uint256
balanceOf 0x70a08231 → uint256
cap 0x355274ea → uint256
decimals 0x313ce567 → uint8
isMinter 0xaa271e1a → bool
isPauser 0x46fbf68e → bool
name 0x06fdde03 → string
paused 0x5c975abb → bool
shotgunDisabled 0x841815ef → bool
symbol 0x95d89b41 → string
totalSupply 0x18160ddd → uint256
Write Contract 16 functions
These functions modify contract state and require a wallet transaction to execute.
addMinter 0x983b2d56
address account
addPauser 0x82dc1ec4
address account
approve 0x095ea7b3
address spender
uint256 value
returns: bool
burn 0x42966c68
uint256 amount
burnAndCollectEther 0xe6b9e897
address shotgunClause
burnFrom 0x79cc6790
address account
uint256 amount
decreaseAllowance 0xa457c2d7
address spender
uint256 subtractedValue
returns: bool
increaseAllowance 0x39509351
address spender
uint256 addedValue
returns: bool
lockShardsAndClaim 0xd54f9d09
No parameters
mint 0x40c10f19
address account
uint256 amount
returns: bool
pause 0x8456cb59
No parameters
renounceMinter 0x98650275
No parameters
renouncePauser 0x6ef8d66d
No parameters
transfer 0xa9059cbb
address to
uint256 value
returns: bool
transferFrom 0x23b872dd
address from
address to
uint256 value
returns: bool
unpause 0x3f4ba83a
No parameters
Recent Transactions
No transactions found for this address