USA Node
Top Transactions
Blocks
Staking
Tokens
Broadcast TXN
CLI Interface
Developer API
Smart Contract HQ
Contact Us
Donate
Node Status
Node:
Main Net - US
Search
Token Contract Details
Contract:
0x4d080101e350f2a7bf879293c223dfa48eddc93d
Name:
t
Symbol:
t
Total Supply:
4
Decimal:
Compiler Version:
v0.6.2
Published Contract:
Send Transactions
TNT-20 Transactions
TNT-721 Transactions
Contract
Contract ByteCode:
0x6080604052600436106101235760003560e01c80636352211e116100a0578063b88d4fde11610064578063b88d4fde146104a3578063c87b56dd14610576578063d0def521146105a0578063d0e30db014610656578063e985e9c51461065e57610164565b80636352211e146103e15780636c0360eb1461040b57806370a082311461042057806395d89b4114610453578063a22cb4651461046857610164565b806323b872dd116100e757806323b872dd146102e35780632f745c59146103265780633ccfd60b1461035f57806342842e0e146103745780634f6ccce7146103b757610164565b806301ffc9a71461016957806306fdde03146101b1578063081812fc1461023b578063095ea7b31461028157806318160ddd146102bc57610164565b36610164576040805133815234602082015281517f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f88525874929181900390910190a1005b600080fd5b34801561017557600080fd5b5061019d6004803603602081101561018c57600080fd5b50356001600160e01b031916610699565b604080519115158252519081900360200190f35b3480156101bd57600080fd5b506101c66106bc565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102005781810151838201526020016101e8565b50505050905090810190601f16801561022d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561024757600080fd5b506102656004803603602081101561025e57600080fd5b5035610753565b604080516001600160a01b039092168252519081900360200190f35b34801561028d57600080fd5b506102ba600480360360408110156102a457600080fd5b506001600160a01b0381351690602001356107b5565b005b3480156102c857600080fd5b506102d1610890565b60408051918252519081900360200190f35b3480156102ef57600080fd5b506102ba6004803603606081101561030657600080fd5b506001600160a01b038135811691602081013590911690604001356108a1565b34801561033257600080fd5b506102d16004803603604081101561034957600080fd5b506001600160a01b0381351690602001356108f8565b34801561036b57600080fd5b506102ba610929565b34801561038057600080fd5b506102ba6004803603606081101561039757600080fd5b506001600160a01b03813581169160208101359091169060400135610976565b3480156103c357600080fd5b506102d1600480360360208110156103da57600080fd5b5035610991565b3480156103ed57600080fd5b506102656004803603602081101561040457600080fd5b50356109ad565b34801561041757600080fd5b506101c66109db565b34801561042c57600080fd5b506102d16004803603602081101561044357600080fd5b50356001600160a01b0316610a3c565b34801561045f57600080fd5b506101c6610aa4565b34801561047457600080fd5b506102ba6004803603604081101561048b57600080fd5b506001600160a01b0381351690602001351515610b05565b3480156104af57600080fd5b506102ba600480360360808110156104c657600080fd5b6001600160a01b0382358116926020810135909116916040820135919081019060808101606082013564010000000081111561050157600080fd5b82018360208201111561051357600080fd5b8035906020019184600183028401116401000000008311171561053557600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610c0a945050505050565b34801561058257600080fd5b506101c66004803603602081101561059957600080fd5b5035610c62565b6102ba600480360360408110156105b657600080fd5b6001600160a01b0382351691908101906040810160208201356401000000008111156105e157600080fd5b8201836020820111156105f357600080fd5b8035906020019184600183028401116401000000008311171561061557600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610f09945050505050565b6102ba610f29565b34801561066a57600080fd5b5061019d6004803603604081101561068157600080fd5b506001600160a01b0381358116916020013516610f2b565b6001600160e01b0319811660009081526020819052604090205460ff165b919050565b60068054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107485780601f1061071d57610100808354040283529160200191610748565b820191906000526020600020905b81548152906001019060200180831161072b57829003601f168201915b505050505090505b90565b600061075e82610f59565b6107995760405162461bcd60e51b815260040180806020018281038252602c815260200180611e2e602c913960400191505060405180910390fd5b506000908152600460205260409020546001600160a01b031690565b60006107c0826109ad565b9050806001600160a01b0316836001600160a01b031614156108135760405162461bcd60e51b8152600401808060200182810382526021815260200180611d2e6021913960400191505060405180910390fd5b806001600160a01b0316610825610f6c565b6001600160a01b03161480610846575061084681610841610f6c565b610f2b565b6108815760405162461bcd60e51b8152600401808060200182810382526038815260200180611d816038913960400191505060405180910390fd5b61088b8383610f70565b505050565b600061089c6002610fde565b905090565b6108b26108ac610f6c565b82610fe9565b6108ed5760405162461bcd60e51b8152600401808060200182810382526031815260200180611eb06031913960400191505060405180910390fd5b61088b83838361108d565b6001600160a01b0382166000908152600160205260408120610920908363ffffffff6111eb16565b90505b92915050565b604051600090339047908381818185875af1925050503d806000811461096b576040519150601f19603f3d011682016040523d82523d6000602084013e610970565b606091505b50505050565b61088b83838360405180602001604052806000815250610c0a565b6000806109a560028463ffffffff6111f716565b509392505050565b600061092382604051806060016040528060298152602001611d05602991396002919063ffffffff61121316565b60098054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107485780601f1061071d57610100808354040283529160200191610748565b60006001600160a01b038216610a835760405162461bcd60e51b815260040180806020018281038252602a815260200180611e86602a913960400191505060405180910390fd5b6001600160a01b038216600090815260016020526040902061092390610fde565b60078054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107485780601f1061071d57610100808354040283529160200191610748565b610b0d610f6c565b6001600160a01b0316826001600160a01b03161415610b73576040805162461bcd60e51b815260206004820152601960248201527f544e543732313a20617070726f766520746f2063616c6c657200000000000000604482015290519081900360640190fd5b8060056000610b80610f6c565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff191692151592909217909155610bc4610f6c565b60408051841515815290516001600160a01b0392909216917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c319181900360200190a35050565b610c1b610c15610f6c565b83610fe9565b610c565760405162461bcd60e51b8152600401808060200182810382526031815260200180611eb06031913960400191505060405180910390fd5b6109708484848461122a565b6060610c6d82610f59565b610ca85760405162461bcd60e51b815260040180806020018281038252602f815260200180611ddd602f913960400191505060405180910390fd5b60008281526008602090815260409182902080548351601f6002600019610100600186161502019093169290920491820184900484028101840190945280845260609392830182828015610d3d5780601f10610d1257610100808354040283529160200191610d3d565b820191906000526020600020905b815481529060010190602001808311610d2057829003601f168201915b505060095493945050505060026000196101006001841615020190911604610d665790506106b7565b805115610e37576009816040516020018083805460018160011615610100020316600290048015610dce5780601f10610dac576101008083540402835291820191610dce565b820191906000526020600020905b815481529060010190602001808311610dba575b5050825160208401908083835b60208310610dfa5780518252601f199092019160209182019101610ddb565b6001836020036101000a038019825116818451168082178552505050505050905001925050506040516020818303038152906040529150506106b7565b6009610e428461127c565b6040516020018083805460018160011615610100020316600290048015610ea05780601f10610e7e576101008083540402835291820191610ea0565b820191906000526020600020905b815481529060010190602001808311610e8c575b5050825160208401908083835b60208310610ecc5780518252601f199092019160209182019101610ead565b6001836020036101000a03801982511681845116808217855250505050505090500192505050604051602081830303815290604052915050919050565b6000610f13610890565b9050610f1f8382611340565b61088b818361135e565b565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b600061092360028363ffffffff6113c116565b3390565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190610fa5826109ad565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000610923826113cd565b6000610ff482610f59565b61102f5760405162461bcd60e51b815260040180806020018281038252602c815260200180611cb0602c913960400191505060405180910390fd5b600061103a836109ad565b9050806001600160a01b0316846001600160a01b031614806110755750836001600160a01b031661106a84610753565b6001600160a01b0316145b8061108557506110858185610f2b565b949350505050565b826001600160a01b03166110a0826109ad565b6001600160a01b0316146110e55760405162461bcd60e51b8152600401808060200182810382526029815260200180611cdc6029913960400191505060405180910390fd5b6001600160a01b03821661112a5760405162461bcd60e51b8152600401808060200182810382526024815260200180611db96024913960400191505060405180910390fd5b61113583838361088b565b611140600082610f70565b6001600160a01b0383166000908152600160205260409020611168908263ffffffff6113d116565b506001600160a01b0382166000908152600160205260409020611191908263ffffffff6113dd16565b506111a46002828463ffffffff6113e916565b5080826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b600061092083836113ff565b60008080806112068686611463565b9097909650945050505050565b60006112208484846114de565b90505b9392505050565b61123584848461108d565b611241848484846115a8565b6109705760405162461bcd60e51b8152600401808060200182810382526032815260200180611d4f6032913960400191505060405180910390fd5b6060816112a157506040805180820190915260018152600360fc1b60208201526106b7565b8160005b81156112b957600101600a820491506112a5565b6060816040519080825280601f01601f1916602001820160405280156112e6576020820181803883390190505b50859350905060001982015b831561133757600a840660300160f81b8282806001900393508151811061131557fe5b60200101906001600160f81b031916908160001a905350600a840493506112f2565b50949350505050565b61135a828260405180602001604052806000815250611728565b5050565b61136782610f59565b6113a25760405162461bcd60e51b815260040180806020018281038252602c815260200180611e5a602c913960400191505060405180910390fd5b6000828152600860209081526040909120825161088b92840190611bf5565b6000610920838361177a565b5490565b60006109208383611792565b60006109208383611858565b600061122084846001600160a01b0385166118a2565b815460009082106114415760405162461bcd60e51b8152600401808060200182810382526022815260200180611c8e6022913960400191505060405180910390fd5b82600001828154811061145057fe5b9060005260206000200154905092915050565b8154600090819083106114a75760405162461bcd60e51b8152600401808060200182810382526022815260200180611e0c6022913960400191505060405180910390fd5b60008460000184815481106114b857fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b600082815260018401602052604081205482816115795760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561153e578181015183820152602001611526565b50505050905090810190601f16801561156b5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5084600001600182038154811061158c57fe5b9060005260206000209060020201600101549150509392505050565b60006115bc846001600160a01b0316611939565b6115c857506001611085565b60606116ee63df20cc6d60e01b6115dd610f6c565b88878760405160240180856001600160a01b03166001600160a01b03168152602001846001600160a01b03166001600160a01b0316815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561165657818101518382015260200161163e565b50505050905090810190601f1680156116835780820380516001836020036101000a031916815260200191505b5095505050505050604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b038381831617835250505050604051806060016040528060328152602001611d4f603291396001600160a01b038816919063ffffffff61193f16565b9050600081806020019051602081101561170757600080fd5b50516001600160e01b031916630a85bd0160e11b1492505050949350505050565b611732838361194e565b61173f60008484846115a8565b61088b5760405162461bcd60e51b8152600401808060200182810382526032815260200180611d4f6032913960400191505060405180910390fd5b60009081526001919091016020526040902054151590565b6000818152600183016020526040812054801561184e57835460001980830191908101906000908790839081106117c557fe5b90600052602060002001549050808760000184815481106117e257fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061181257fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050610923565b6000915050610923565b6000611864838361177a565b61189a57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610923565b506000610923565b600082815260018401602052604081205480611907575050604080518082018252838152602080820184815286546001818101895560008981528481209551600290930290950191825591519082015586548684528188019092529290912055611223565b8285600001600183038154811061191a57fe5b9060005260206000209060020201600101819055506000915050611223565b3b151590565b60606112208484600085611a88565b6001600160a01b0382166119a9576040805162461bcd60e51b815260206004820181905260248201527f544e543732313a206d696e7420746f20746865207a65726f2061646472657373604482015290519081900360640190fd5b6119b281610f59565b15611a04576040805162461bcd60e51b815260206004820152601c60248201527f544e543732313a20746f6b656e20616c7265616479206d696e74656400000000604482015290519081900360640190fd5b611a106000838361088b565b6001600160a01b0382166000908152600160205260409020611a38908263ffffffff6113dd16565b50611a4b6002828463ffffffff6113e916565b5060405181906001600160a01b038416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6060611a9385611939565b611ae4576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b60208310611b235780518252601f199092019160209182019101611b04565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114611b85576040519150601f19603f3d011682016040523d82523d6000602084013e611b8a565b606091505b50915091508115611b9e5791506110859050565b805115611bae5780518082602001fd5b60405162461bcd60e51b815260206004820181815286516024840152865187939192839260440191908501908083836000831561153e578181015183820152602001611526565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10611c3657805160ff1916838001178555611c63565b82800160010185558215611c63579182015b82811115611c63578251825591602001919060010190611c48565b50611c6f929150611c73565b5090565b61075091905b80821115611c6f5760008155600101611c7956fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e6473544e543732313a206f70657261746f7220717565727920666f72206e6f6e6578697374656e7420746f6b656e544e543732313a207472616e73666572206f6620746f6b656e2074686174206973206e6f74206f776e544e543732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656e544e543732313a20617070726f76616c20746f2063757272656e74206f776e6572544e543732313a207472616e7366657220746f206e6f6e20544e54373231526563656976657220696d706c656d656e746572544e543732313a20617070726f76652063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f76656420666f7220616c6c544e543732313a207472616e7366657220746f20746865207a65726f2061646472657373544e543732314d657461646174613a2055524920717565727920666f72206e6f6e6578697374656e7420746f6b656e456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e6473544e543732313a20617070726f76656420717565727920666f72206e6f6e6578697374656e7420746f6b656e544e543732314d657461646174613a2055524920736574206f66206e6f6e6578697374656e7420746f6b656e544e543732313a2062616c616e636520717565727920666f7220746865207a65726f2061646472657373544e543732313a207472616e736665722063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f766564a26469706673582212204d60a28b9509d1bdbde51001a5cc32f6ff3ff0103badec979b434fa0941af2fb64736f6c63430006020033
Published Contract:
// SPDX-License-Identifier: MIT // // TNT-721 Non-Fungible Token implementation based on the OpenZeppelin Lib // pragma solidity ^0.6.2; 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; } } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 9a9 not being zero, but the // benefit is lost if 9b9 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; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by 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 doesn9t hold return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } library Address { function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } 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"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } 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"); } 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); } } } } library EnumerableSet { 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; } 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; } } function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value9s 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 9swap and pop9). // 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 9if9 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; } } function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } function _length(Set storage set) private view returns (uint256) { return set._values.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]; } struct AddressSet { Set _inner; } function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(value))); } function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(value))); } function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(value))); } function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint256(_at(set._inner, index))); } struct UintSet { Set _inner; } function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } } library EnumerableMap { 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; } function _set(Map storage map, bytes32 key, bytes32 value) private returns (bool) { // We read and store the key9s 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; } } function _remove(Map storage map, bytes32 key) private returns (bool) { // We read and store the key9s 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 9swap and pop9). // 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 9if9 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; } } function _contains(Map storage map, bytes32 key) private view returns (bool) { return map._indexes[key] != 0; } function _length(Map storage map) private view returns (uint256) { return map._entries.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); } function _get(Map storage map, bytes32 key) private view returns (bytes32) { return _get(map, key, "EnumerableMap: nonexistent key"); } 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 } struct UintToAddressMap { Map _inner; } function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) { return _set(map._inner, bytes32(key), bytes32(uint256(value))); } function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) { return _remove(map._inner, bytes32(key)); } function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) { return _contains(map._inner, bytes32(key)); } function length(UintToAddressMap storage map) internal view returns (uint256) { return _length(map._inner); } 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))); } function get(UintToAddressMap storage map, uint256 key) internal view returns (address) { return address(uint256(_get(map._inner, bytes32(key)))); } function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) { return address(uint256(_get(map._inner, bytes32(key), errorMessage))); } } library Strings { function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI9s 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); } } interface ITNT165 { function supportsInterface(bytes4 interfaceId) external view returns (bool); } interface ITNT721 is ITNT165 { 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); function balanceOf(address owner) external view returns (uint256 balance); function ownerOf(uint256 tokenId) external view returns (address owner); function safeTransferFrom(address from, address to, uint256 tokenId) external; function transferFrom(address from, address to, uint256 tokenId) external; function approve(address to, uint256 tokenId) external; function getApproved(uint256 tokenId) external view returns (address operator); function setApprovalForAll(address operator, bool _approved) external; function isApprovedForAll(address owner, address operator) external view returns (bool); function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; } interface ITNT721Metadata is ITNT721 { function name() external view returns (string memory); function symbol() external view returns (string memory); function tokenURI(uint256 tokenId) external view returns (string memory); } interface ITNT721Enumerable is ITNT721 { function totalSupply() external view returns (uint256); function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); function tokenByIndex(uint256 index) external view returns (uint256); } interface ITNT721Receiver { function onTNT721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4); } contract TNT165 is ITNT165 { bytes4 private constant _INTERFACE_ID_TNT165 = 0x01ffc9a7; mapping(bytes4 => bool) private _supportedInterfaces; constructor () internal { _registerInterface(_INTERFACE_ID_TNT165); } function supportsInterface(bytes4 interfaceId) public view override returns (bool) { return _supportedInterfaces[interfaceId]; } function _registerInterface(bytes4 interfaceId) internal virtual { require(interfaceId != 0xffffffff, "TNT165: invalid interface id"); _supportedInterfaces[interfaceId] = true; } } // TNT stands for "Theta Network Token", TNT-721 is the non-fungible token // standard on the Theta network, similar to the ERC-721 standard on Ethereum contract TNT721 is Context, TNT165, ITNT721, ITNT721Metadata, ITNT721Enumerable { using SafeMath for uint256; using Address for address; using EnumerableSet for EnumerableSet.UintSet; using EnumerableMap for EnumerableMap.UintToAddressMap; using Strings for uint256; bytes4 private constant _TNT721_RECEIVED = 0x150b7a02; mapping (address => EnumerableSet.UintSet) private _holderTokens; EnumerableMap.UintToAddressMap private _tokenOwners; mapping (uint256 => address) private _tokenApprovals; mapping (address => mapping (address => bool)) private _operatorApprovals; string private _name; string private _symbol; mapping (uint256 => string) private _tokenURIs; string private _baseURI; bytes4 private constant _INTERFACE_ID_TNT721 = 0x80ac58cd; bytes4 private constant _INTERFACE_ID_TNT721_METADATA = 0x5b5e139f; bytes4 private constant _INTERFACE_ID_TNT721_ENUMERABLE = 0x780e9d63; constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _registerInterface(_INTERFACE_ID_TNT721); _registerInterface(_INTERFACE_ID_TNT721_METADATA); _registerInterface(_INTERFACE_ID_TNT721_ENUMERABLE); } function balanceOf(address owner) public view override returns (uint256) { require(owner != address(0), "TNT721: balance query for the zero address"); return _holderTokens[owner].length(); } event Received(address, uint); receive() external payable { emit Received(msg.sender, msg.value); } function ownerOf(uint256 tokenId) public view override returns (address) { return _tokenOwners.get(tokenId, "TNT721: owner query for nonexistent token"); } function name() public view override returns (string memory) { return _name; } function symbol() public view override returns (string memory) { return _symbol; } function tokenURI(uint256 tokenId) public view override returns (string memory) { require(_exists(tokenId), "TNT721Metadata: URI query for nonexistent token"); string memory _tokenURI = _tokenURIs[tokenId]; // If there is no base URI, return the token URI. if (bytes(_baseURI).length == 0) { return _tokenURI; } // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked). if (bytes(_tokenURI).length > 0) { return string(abi.encodePacked(_baseURI, _tokenURI)); } // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI. return string(abi.encodePacked(_baseURI, tokenId.toString())); } function baseURI() public view returns (string memory) { return _baseURI; } function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) { return _holderTokens[owner].at(index); } function totalSupply() public view override returns (uint256) { // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds return _tokenOwners.length(); } function tokenByIndex(uint256 index) public view override returns (uint256) { (uint256 tokenId, ) = _tokenOwners.at(index); return tokenId; } function approve(address to, uint256 tokenId) public virtual override { address owner = ownerOf(tokenId); require(to != owner, "TNT721: approval to current owner"); require(_msgSender() == owner || isApprovedForAll(owner, _msgSender()), "TNT721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } function getApproved(uint256 tokenId) public view override returns (address) { require(_exists(tokenId), "TNT721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "TNT721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } function isApprovedForAll(address owner, address operator) public view override returns (bool) { return _operatorApprovals[owner][operator]; } function transferFrom(address from, address to, uint256 tokenId) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "TNT721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override { safeTransferFrom(from, to, tokenId, ""); } function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "TNT721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual { _transfer(from, to, tokenId); require(_checkOnTNT721Received(from, to, tokenId, _data), "TNT721: transfer to non TNT721Receiver implementer"); } function _exists(uint256 tokenId) internal view returns (bool) { return _tokenOwners.contains(tokenId); } function _isApprovedOrOwner(address spender, uint256 tokenId) internal view returns (bool) { require(_exists(tokenId), "TNT721: operator query for nonexistent token"); address owner = ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } function _safeMint(address to, uint256 tokenId, bytes memory _data) internal virtual { _mint(to, tokenId); require(_checkOnTNT721Received(address(0), to, tokenId, _data), "TNT721: transfer to non TNT721Receiver implementer"); } function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "TNT721: mint to the zero address"); require(!_exists(tokenId), "TNT721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(address(0), to, tokenId); } function _burn(uint256 tokenId) internal virtual { address owner = ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); // Clear metadata (if any) if (bytes(_tokenURIs[tokenId]).length != 0) { delete _tokenURIs[tokenId]; } _holderTokens[owner].remove(tokenId); _tokenOwners.remove(tokenId); emit Transfer(owner, address(0), tokenId); } function _transfer(address from, address to, uint256 tokenId) internal virtual { require(ownerOf(tokenId) == from, "TNT721: transfer of token that is not own"); require(to != address(0), "TNT721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // 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); } function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual { require(_exists(tokenId), "TNT721Metadata: URI set of nonexistent token"); _tokenURIs[tokenId] = _tokenURI; } function _setBaseURI(string memory baseURI_) internal virtual { _baseURI = baseURI_; } function _checkOnTNT721Received(address from, address to, uint256 tokenId, bytes memory _data) private returns (bool) { if (!to.isContract()) { return true; } bytes memory returndata = to.functionCall(abi.encodeWithSelector( ITNT721Receiver(to).onTNT721Received.selector, _msgSender(), from, tokenId, _data ), "TNT721: transfer to non TNT721Receiver implementer"); bytes4 retval = abi.decode(returndata, (bytes4)); return (retval == _TNT721_RECEIVED); } function _approve(address to, uint256 tokenId) private { _tokenApprovals[tokenId] = to; emit Approval(ownerOf(tokenId), to, tokenId); } function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { } } contract CoolNFT is TNT721 { function deposit() payable public { // nothing to do! } function withdraw() public { (bool success, ) = msg.sender.call{value: address(this).balance}(""); } function mint(address to, string memory uri) public payable virtual { uint mintIndex = totalSupply(); _safeMint(to, mintIndex); _setTokenURI(mintIndex, uri); } constructor (string memory name, string memory symbol, string memory uri) public TNT721(name, symbol) { uint mintIndex = totalSupply(); _safeMint(msg.sender, mintIndex); _setTokenURI(mintIndex, uri); } }
Contract ABI:
[{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"string","name":"uri","type":"string"}],"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":false,"internalType":"address","name":"","type":"address"},{"indexed":false,"internalType":"uint256","name":"","type":"uint256"}],"name":"Received","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"},{"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":[],"name":"baseURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"deposit","outputs":[],"stateMutability":"payable","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":"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":"to","type":"address"},{"internalType":"string","name":"uri","type":"string"}],"name":"mint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","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":"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":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]