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:
0x63d45993c17d85cadafb0a3a88117f9766d126af
Name:
TraderPunks
Symbol:
TPUNK$
Total Supply:
339
Decimal:
Compiler Version:
v0.8.9
Published Contract:
Send Transactions
TNT-20 Transactions
TNT-721 Transactions
Contract
Contract ByteCode:
0x6080604052600436106102e45760003560e01c80636a491d8611610190578063b5077f44116100dc578063d547741f11610095578063eb8d24441161006f578063eb8d24441461098c578063f54b8c2a146109a6578063faa71128146109da578063fb107a4f14610a0e57600080fd5b8063d547741f14610903578063dc982d5814610923578063e985e9c51461094357600080fd5b8063b5077f441461083a578063b88d4fde1461084f578063c5b70f691461086f578063c87b56dd1461088f578063cd87d766146108af578063cdecb841146108cf57600080fd5b80638585a526116101495780639745cc3d116101235780639745cc3d146107a857806397d78dfc146107e5578063a217fddf14610805578063a22cb4651461081a57600080fd5b80638585a5261461075357806391d148541461077357806395d89b411461079357600080fd5b80636a491d861461067c57806370a082311461069257806371902b1b146106b2578063806c79f3146106df57806381530b6814610713578063841718a61461073357600080fd5b80632cac44ca1161024f5780633b065f6d1161020857806349cb89c1116101e257806349cb89c1146105e85780634f6ccce7146106085780636352211e1461062857806366b879e11461064857600080fd5b80633b065f6d1461059557806340d097c3146105b557806342842e0e146105c857600080fd5b80632cac44ca146104ad5780632e876a64146104cd5780632f2ff15d146105015780632f745c591461052157806336568abe146105415780633ad200741461056157600080fd5b806312cd400a116102a157806312cd400a146103de57806318160ddd1461041257806323b872dd14610427578063248a9ca31461044757806324c979a31461047757806324fd37711461048d57600080fd5b806301ffc9a7146102e957806303339bcb1461031e57806306fdde0314610340578063081812fc14610362578063095ea7b31461039a5780630d39fc81146103ba575b600080fd5b3480156102f557600080fd5b50610309610304366004612fce565b610a23565b60405190151581526020015b60405180910390f35b34801561032a57600080fd5b5061033e610339366004613007565b610a34565b005b34801561034c57600080fd5b50610355610a99565b604051610315919061308b565b34801561036e57600080fd5b5061038261037d36600461309e565b610b2b565b6040516001600160a01b039091168152602001610315565b3480156103a657600080fd5b5061033e6103b53660046130b7565b610b52565b3480156103c657600080fd5b506103d0600d5481565b604051908152602001610315565b3480156103ea57600080fd5b506103d07fb2a508921331412525a7b4d249337c9642a0ac9246c1647dc4c310aa7ec34cbb81565b34801561041e57600080fd5b506008546103d0565b34801561043357600080fd5b5061033e6104423660046130e1565b610c6d565b34801561045357600080fd5b506103d061046236600461309e565b6000908152600a602052604090206001015490565b34801561048357600080fd5b506103d0600f5481565b34801561049957600080fd5b5061033e6104a83660046131dc565b610c9e565b3480156104b957600080fd5b5061033e6104c83660046130b7565b610cd6565b3480156104d957600080fd5b506103d07f174905d478b5d8485e11ad01d627eb5f32a8fff3776f70563e499b6969e383e681565b34801561050d57600080fd5b5061033e61051c366004613007565b610e88565b34801561052d57600080fd5b506103d061053c3660046130b7565b610ead565b34801561054d57600080fd5b5061033e61055c366004613007565b610f43565b34801561056d57600080fd5b506103d07fe40e72c9e62f3502d3c5341b30fe0fb024238174d5fe4b02f4ee8f5992b2d48e81565b3480156105a157600080fd5b5061033e6105b0366004613223565b610fc1565b61033e6105c33660046132d0565b61103a565b3480156105d457600080fd5b5061033e6105e33660046130e1565b6110d0565b3480156105f457600080fd5b5061033e6106033660046132d0565b6110eb565b34801561061457600080fd5b506103d061062336600461309e565b611151565b34801561063457600080fd5b5061038261064336600461309e565b6111e4565b34801561065457600080fd5b506103d07f125c175abea62c761efba8e639955fe4ffa02f9fd97af6d2dcfe82dac4d1fbb581565b34801561068857600080fd5b506103d0600e5481565b34801561069e57600080fd5b506103d06106ad3660046132d0565b611244565b3480156106be57600080fd5b506106d26106cd3660046132eb565b6112ca565b604051610315919061330c565b3480156106eb57600080fd5b506103d07f6b1d205222639f45a1784c5e4e7f983edb11ec13b25b2a06b51d0a5b8fac24ed81565b34801561071f57600080fd5b5061033e61072e36600461309e565b61140d565b34801561073f57600080fd5b5061033e61074e366004613360565b611474565b34801561075f57600080fd5b5061033e61076e36600461337b565b6114df565b34801561077f57600080fd5b5061030961078e366004613007565b61151c565b34801561079f57600080fd5b50610355611547565b3480156107b457600080fd5b506107d86107c336600461309e565b60009081526010602052604090205460ff1690565b60405161031591906133c6565b3480156107f157600080fd5b5061033e6108003660046131dc565b611556565b34801561081157600080fd5b506103d0600081565b34801561082657600080fd5b5061033e6108353660046133ee565b61158e565b34801561084657600080fd5b50600e546103d0565b34801561085b57600080fd5b5061033e61086a366004613418565b611599565b34801561087b57600080fd5b5061033e61088a3660046132d0565b6115cb565b34801561089b57600080fd5b506103556108aa36600461309e565b611618565b3480156108bb57600080fd5b5061033e6108ca3660046130b7565b61186c565b3480156108db57600080fd5b506103d07f12cc0b00309860b97de0ea5330488ad36ba40c428840aeae0f66b931cf9a8f8881565b34801561090f57600080fd5b5061033e61091e366004613007565b6119c8565b34801561092f57600080fd5b5061033e61093e36600461309e565b6119ed565b34801561094f57600080fd5b5061030961095e366004613494565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561099857600080fd5b50600c546103099060ff1681565b3480156109b257600080fd5b506103d07fd215a282efb1efb1537607fd2c50f5b303a081c3ef2819cc0088f318ba11999881565b3480156109e657600080fd5b506103d07f9a4a1aa0af6fb08c0dee4907f836cfcb01d60bcd172193323076bc484ecd4b1f81565b348015610a1a57600080fd5b50600d546103d0565b6000610a2e82611b14565b92915050565b7fd215a282efb1efb1537607fd2c50f5b303a081c3ef2819cc0088f318ba119998610a5e81611b39565b60005b8381108015610a735750600e54600854105b15610a9357610a8183611b43565b80610a8b816134d4565b915050610a61565b50505050565b606060008054610aa8906134ef565b80601f0160208091040260200160405190810160405280929190818152602001828054610ad4906134ef565b8015610b215780601f10610af657610100808354040283529160200191610b21565b820191906000526020600020905b815481529060010190602001808311610b0457829003601f168201915b5050505050905090565b6000610b3682611bca565b506000908152600460205260409020546001600160a01b031690565b6000610b5d826111e4565b9050806001600160a01b0316836001600160a01b03161415610bd05760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b336001600160a01b0382161480610bec5750610bec813361095e565b610c5e5760405162461bcd60e51b815260206004820152603e60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206e6f7220617070726f76656420666f7220616c6c00006064820152608401610bc7565b610c688383611c29565b505050565b610c773382611c97565b610c935760405162461bcd60e51b8152600401610bc79061352a565b610c68838383611d16565b7f125c175abea62c761efba8e639955fe4ffa02f9fd97af6d2dcfe82dac4d1fbb5610cc881611b39565b610c68836001600285611ebd565b610ce1601533611f77565b610d2d5760405162461bcd60e51b815260206004820152601e60248201527f796f7520646f206e6f7420726563656976652061206665652073706c697400006044820152606401610bc7565b610d38601533611f93565b811115610dad5760405162461bcd60e51b815260206004820152603960248201527f796f752063616e6e6f74207472616e736665722061206c61726765722066656560448201527f2073706c6974207468616e207768617420796f752068617665000000000000006064820152608401610bc7565b80610db9601584611f77565b15610dd657610dc9601584611f93565b610dd39082613578565b90505b600082610de4601533611f93565b610dee9190613590565b9050610dfc60153383611fa8565b50610e0960158584611fa8565b5060405181815233907f55b44f0aab9d06b43c6f493c1625172db5b86542b6fdd665ebd4e98729db21cd9060200160405180910390a2836001600160a01b03167f55b44f0aab9d06b43c6f493c1625172db5b86542b6fdd665ebd4e98729db21cd83604051610e7a91815260200190565b60405180910390a250505050565b6000828152600a6020526040902060010154610ea381611b39565b610c688383611fbe565b6000610eb883611244565b8210610f1a5760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610bc7565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b6001600160a01b0381163314610fb35760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610bc7565b610fbd8282612044565b5050565b7fd215a282efb1efb1537607fd2c50f5b303a081c3ef2819cc0088f318ba119998610feb81611b39565b60005b8251811080156110015750600e54600854105b15610c685761102883828151811061101b5761101b6135a7565b6020026020010151611b43565b80611032816134d4565b915050610fee565b600c5460ff166110815760405162461bcd60e51b815260206004820152601260248201527173616c65206973206e6f742061637469766560701b6044820152606401610bc7565b600d5434146110c45760405162461bcd60e51b815260206004820152600f60248201526e696e636f72726563742066756e647360881b6044820152606401610bc7565b6110cd816120ab565b50565b610c6883838360405180602001604052806000815250611599565b6110f6601533611f77565b6111425760405162461bcd60e51b815260206004820152601e60248201527f796f7520646f206e6f7420726563656976652061206665652073706c697400006044820152606401610bc7565b6110cd816104c8601533611f93565b600061115c60085490565b82106111bf5760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610bc7565b600882815481106111d2576111d26135a7565b90600052602060002001549050919050565b6000818152600260205260408120546001600160a01b031680610a2e5760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610bc7565b60006001600160a01b0382166112ae5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b6064820152608401610bc7565b506001600160a01b031660009081526003602052604090205490565b6060600060015b6008548111611335578360038111156112ec576112ec6133b0565b60008281526010602052604090205460ff16600381111561130f5761130f6133b0565b1415611323578161131f816134d4565b9250505b8061132d816134d4565b9150506112d1565b5060008167ffffffffffffffff8111156113515761135161311d565b60405190808252806020026020018201604052801561137a578160200160208202803683370190505b509050600060015b60085481116114035785600381111561139d5761139d6133b0565b60008281526010602052604090205460ff1660038111156113c0576113c06133b0565b14156113f1578083836113d2816134d4565b9450815181106113e4576113e46135a7565b6020026020010181815250505b806113fb816134d4565b915050611382565b5090949350505050565b7fe40e72c9e62f3502d3c5341b30fe0fb024238174d5fe4b02f4ee8f5992b2d48e61143781611b39565b600d8290556040518281527fa6dc15bdb68da224c66db4b3838d9a2b205138e8cff6774e57d0af91e196d622906020015b60405180910390a15050565b7f12cc0b00309860b97de0ea5330488ad36ba40c428840aeae0f66b931cf9a8f8861149e81611b39565b600c805460ff19168315159081179091556040519081527fc7f33a5383230bbf7b13084a2dfbbfbd53fadeaf6de5eab4a39250452f6e26ae90602001611468565b7fb2a508921331412525a7b4d249337c9642a0ac9246c1647dc4c310aa7ec34cbb61150981611b39565b8151610c68906011906020850190612f1f565b6000918252600a602090815260408084206001600160a01b0393909316845291905290205460ff1690565b606060018054610aa8906134ef565b7f9a4a1aa0af6fb08c0dee4907f836cfcb01d60bcd172193323076bc484ecd4b1f61158081611b39565b610c68836002600385611ebd565b610fbd33838361218c565b6115a33383611c97565b6115bf5760405162461bcd60e51b8152600401610bc79061352a565b610a938484848461225b565b7f6b1d205222639f45a1784c5e4e7f983edb11ec13b25b2a06b51d0a5b8fac24ed6115f581611b39565b50601480546001600160a01b0319166001600160a01b0392909216919091179055565b606061162382611bca565b6000828152600b60205260408120805461163c906134ef565b80601f0160208091040260200160405190810160405280929190818152602001828054611668906134ef565b80156116b55780601f1061168a576101008083540402835291602001916116b5565b820191906000526020600020905b81548152906001019060200180831161169857829003601f168201915b50505060008681526010602052604090205492935060609260ff169150600390508160038111156116e8576116e86133b0565b141561178057601380546116fb906134ef565b80601f0160208091040260200160405190810160405280929190818152602001828054611727906134ef565b80156117745780601f1061174957610100808354040283529160200191611774565b820191906000526020600020905b81548152906001019060200180831161175757829003601f168201915b50505050509150611840565b6002816003811115611794576117946133b0565b14156117a757601280546116fb906134ef565b601180546117b4906134ef565b80601f01602080910402602001604051908101604052809291908181526020018280546117e0906134ef565b801561182d5780601f106118025761010080835404028352916020019161182d565b820191906000526020600020905b81548152906001019060200180831161181057829003601f168201915b5050505050915061183d8561228e565b92505b81836040516020016118539291906135bd565b6040516020818303038152906040529350505050919050565b7f6b1d205222639f45a1784c5e4e7f983edb11ec13b25b2a06b51d0a5b8fac24ed61189681611b39565b6000805b6118a4601561238c565b8110156118ff576000806118b9601584612397565b91509150866001600160a01b0316826001600160a01b031614156118de5750506118ed565b6118e88185613578565b935050505b806118f7816134d4565b91505061189a565b5061271061190d8483613578565b11156119695760405162461bcd60e51b815260206004820152602560248201527f73756d206f66206665652073706c697473206d6179206e6f7420657863656564604482015264203130302560d81b6064820152608401610bc7565b8261197f576119796015856123b3565b5061198d565b61198b60158585611fa8565b505b836001600160a01b03167f55b44f0aab9d06b43c6f493c1625172db5b86542b6fdd665ebd4e98729db21cd84604051610e7a91815260200190565b6000828152600a60205260409020600101546119e381611b39565b610c688383612044565b7f174905d478b5d8485e11ad01d627eb5f32a8fff3776f70563e499b6969e383e6611a1781611b39565b600854821015611a775760405162461bcd60e51b815260206004820152602560248201527f6e657720737570706c79206d757374206265206774652063757272656e7420736044820152647570706c7960d81b6064820152608401610bc7565b600f54821115611adf5760405162461bcd60e51b815260206004820152602d60248201527f6e657720737570706c792063616e206e6f74206265206772656174657220746860448201526c616e206d617820737570706c7960981b6064820152608401610bc7565b600e8290556040518281527fd9668906ecf9bdfc721f8b2fed112d5117ad87e6776c838ca1a38b138e1dd00d90602001611468565b60006001600160e01b03198216637965db0b60e01b1480610a2e5750610a2e826123c8565b6110cd81336123ed565b600e5460085410611b8b5760405162461bcd60e51b81526020600482015260126024820152711b585e081cdd5c1c1b1e481c995858da195960721b6044820152606401610bc7565b6000611b9660085490565b611ba1906001613578565b9050611bad8282612451565b610fbd816000600160405180602001604052806000815250611ebd565b6000818152600260205260409020546001600160a01b03166110cd5760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610bc7565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611c5e826111e4565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600080611ca3836111e4565b9050806001600160a01b0316846001600160a01b03161480611cea57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b80611d0e5750836001600160a01b0316611d0384610b2b565b6001600160a01b0316145b949350505050565b826001600160a01b0316611d29826111e4565b6001600160a01b031614611d8d5760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b6064820152608401610bc7565b6001600160a01b038216611def5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610bc7565b611dfa83838361246b565b611e05600082611c29565b6001600160a01b0383166000908152600360205260408120805460019290611e2e908490613590565b90915550506001600160a01b0382166000908152600360205260408120805460019290611e5c908490613578565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b611ec684611bca565b611ed08484612476565b6000848152601060205260409020805483919060ff19166001836003811115611efb57611efb6133b0565b02179055506001826003811115611f1457611f146133b0565b14611f2357611f2384826124e8565b83836003811115611f3657611f366133b0565b836003811115611f4857611f486133b0565b6040517f467cbb837e651135f2aa9f6a8d143fe5c5e397de36cff3fd4c7fe6106527a5a090600090a450505050565b6000611f8c836001600160a01b0384166125bf565b9392505050565b6000611f8c836001600160a01b0384166125cb565b6000611d0e846001600160a01b0385168461263b565b611fc8828261151c565b610fbd576000828152600a602090815260408083206001600160a01b03851684529091529020805460ff191660011790556120003390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b61204e828261151c565b15610fbd576000828152600a602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6120b481611b43565b3460005b6120c2601561238c565b811015612151576000806120d7601584612397565b90925090506000816120eb61271034613602565b6120f59190613616565b90506121018186613590565b6040519095506001600160a01b0384169082156108fc029083906000818181858888f1935050505015801561213a573d6000803e3d6000fd5b505050508080612149906134d4565b9150506120b8565b506014546040516001600160a01b039091169082156108fc029083906000818181858888f19350505050158015610c68573d6000803e3d6000fd5b816001600160a01b0316836001600160a01b031614156121ee5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610bc7565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b612266848484611d16565b61227284848484612658565b610a935760405162461bcd60e51b8152600401610bc790613635565b6060816122b25750506040805180820190915260018152600360fc1b602082015290565b8160005b81156122dc57806122c6816134d4565b91506122d59050600a83613602565b91506122b6565b60008167ffffffffffffffff8111156122f7576122f761311d565b6040519080825280601f01601f191660200182016040528015612321576020820181803683370190505b5090505b8415611d0e57612336600183613590565b9150612343600a86613687565b61234e906030613578565b60f81b818381518110612363576123636135a7565b60200101906001600160f81b031916908160001a905350612385600a86613602565b9450612325565b6000610a2e82612765565b60008080806123a68686612770565b9097909650945050505050565b6000611f8c836001600160a01b03841661279b565b60006001600160e01b0319821663780e9d6360e01b1480610a2e5750610a2e826127b8565b6123f7828261151c565b610fbd5761240f816001600160a01b03166014612808565b61241a836020612808565b60405160200161242b92919061369b565b60408051601f198184030181529082905262461bcd60e51b8252610bc79160040161308b565b610fbd8282604051806020016040528060008152506129a4565b610c688383836129d7565b806003811115612488576124886133b0565b60008381526010602052604090205460ff1660038111156124ab576124ab6133b0565b14610fbd5760405162461bcd60e51b815260206004820152600d60248201526c696e76616c696420737461746560981b6044820152606401610bc7565b6000828152600260205260409020546001600160a01b03166125635760405162461bcd60e51b815260206004820152602e60248201527f45524337323155524953746f726167653a2055524920736574206f66206e6f6e60448201526d32bc34b9ba32b73a103a37b5b2b760911b6064820152608401610bc7565b6000828152600b60209081526040909120825161258292840190612f1f565b50817fe63ff1ee191e6fc902b7b47aa9ccf80bd883ec287a6d18db9961e5c5ec6b80f0826040516125b3919061308b565b60405180910390a25050565b6000611f8c8383612a8f565b6000818152600283016020526040812054801515806125ef57506125ef84846125bf565b611f8c5760405162461bcd60e51b815260206004820152601e60248201527f456e756d657261626c654d61703a206e6f6e6578697374656e74206b657900006044820152606401610bc7565b60008281526002840160205260408120829055611d0e8484612aa7565b60006001600160a01b0384163b1561275a57604051630a85bd0160e11b81526001600160a01b0385169063150b7a029061269c903390899088908890600401613710565b602060405180830381600087803b1580156126b657600080fd5b505af19250505080156126e6575060408051601f3d908101601f191682019092526126e39181019061374d565b60015b612740573d808015612714576040519150601f19603f3d011682016040523d82523d6000602084013e612719565b606091505b5080516127385760405162461bcd60e51b8152600401610bc790613635565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611d0e565b506001949350505050565b6000610a2e82612ab3565b6000808061277e8585612abd565b600081815260029690960160205260409095205494959350505050565b60008181526002830160205260408120819055611f8c8383612ac9565b60006001600160e01b031982166380ac58cd60e01b14806127e957506001600160e01b03198216635b5e139f60e01b145b80610a2e57506301ffc9a760e01b6001600160e01b0319831614610a2e565b60606000612817836002613616565b612822906002613578565b67ffffffffffffffff81111561283a5761283a61311d565b6040519080825280601f01601f191660200182016040528015612864576020820181803683370190505b509050600360fc1b8160008151811061287f5761287f6135a7565b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106128ae576128ae6135a7565b60200101906001600160f81b031916908160001a90535060006128d2846002613616565b6128dd906001613578565b90505b6001811115612955576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110612911576129116135a7565b1a60f81b828281518110612927576129276135a7565b60200101906001600160f81b031916908160001a90535060049490941c9361294e8161376a565b90506128e0565b508315611f8c5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610bc7565b6129ae8383612ad5565b6129bb6000848484612658565b610c685760405162461bcd60e51b8152600401610bc790613635565b6001600160a01b038316612a3257612a2d81600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b612a55565b816001600160a01b0316836001600160a01b031614612a5557612a558382612c23565b6001600160a01b038216612a6c57610c6881612cc0565b826001600160a01b0316826001600160a01b031614610c6857610c688282612d6f565b60008181526001830160205260408120541515611f8c565b6000611f8c8383612db3565b6000610a2e825490565b6000611f8c8383612e02565b6000611f8c8383612e2c565b6001600160a01b038216612b2b5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610bc7565b6000818152600260205260409020546001600160a01b031615612b905760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610bc7565b612b9c6000838361246b565b6001600160a01b0382166000908152600360205260408120805460019290612bc5908490613578565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b60006001612c3084611244565b612c3a9190613590565b600083815260076020526040902054909150808214612c8d576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b600854600090612cd290600190613590565b60008381526009602052604081205460088054939450909284908110612cfa57612cfa6135a7565b906000526020600020015490508060088381548110612d1b57612d1b6135a7565b6000918252602080832090910192909255828152600990915260408082208490558582528120556008805480612d5357612d53613781565b6001900381819060005260206000200160009055905550505050565b6000612d7a83611244565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6000818152600183016020526040812054612dfa57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610a2e565b506000610a2e565b6000826000018281548110612e1957612e196135a7565b9060005260206000200154905092915050565b60008181526001830160205260408120548015612f15576000612e50600183613590565b8554909150600090612e6490600190613590565b9050818114612ec9576000866000018281548110612e8457612e846135a7565b9060005260206000200154905080876000018481548110612ea757612ea76135a7565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080612eda57612eda613781565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610a2e565b6000915050610a2e565b828054612f2b906134ef565b90600052602060002090601f016020900481019282612f4d5760008555612f93565b82601f10612f6657805160ff1916838001178555612f93565b82800160010185558215612f93579182015b82811115612f93578251825591602001919060010190612f78565b50612f9f929150612fa3565b5090565b5b80821115612f9f5760008155600101612fa4565b6001600160e01b0319811681146110cd57600080fd5b600060208284031215612fe057600080fd5b8135611f8c81612fb8565b80356001600160a01b038116811461300257600080fd5b919050565b6000806040838503121561301a57600080fd5b8235915061302a60208401612feb565b90509250929050565b60005b8381101561304e578181015183820152602001613036565b83811115610a935750506000910152565b60008151808452613077816020860160208601613033565b601f01601f19169290920160200192915050565b602081526000611f8c602083018461305f565b6000602082840312156130b057600080fd5b5035919050565b600080604083850312156130ca57600080fd5b6130d383612feb565b946020939093013593505050565b6000806000606084860312156130f657600080fd5b6130ff84612feb565b925061310d60208501612feb565b9150604084013590509250925092565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561315c5761315c61311d565b604052919050565b600067ffffffffffffffff83111561317e5761317e61311d565b613191601f8401601f1916602001613133565b90508281528383830111156131a557600080fd5b828260208301376000602084830101529392505050565b600082601f8301126131cd57600080fd5b611f8c83833560208501613164565b600080604083850312156131ef57600080fd5b82359150602083013567ffffffffffffffff81111561320d57600080fd5b613219858286016131bc565b9150509250929050565b6000602080838503121561323657600080fd5b823567ffffffffffffffff8082111561324e57600080fd5b818501915085601f83011261326257600080fd5b8135818111156132745761327461311d565b8060051b9150613285848301613133565b818152918301840191848101908884111561329f57600080fd5b938501935b838510156132c4576132b585612feb565b825293850193908501906132a4565b98975050505050505050565b6000602082840312156132e257600080fd5b611f8c82612feb565b6000602082840312156132fd57600080fd5b813560048110611f8c57600080fd5b6020808252825182820181905260009190848201906040850190845b8181101561334457835183529284019291840191600101613328565b50909695505050505050565b8035801515811461300257600080fd5b60006020828403121561337257600080fd5b611f8c82613350565b60006020828403121561338d57600080fd5b813567ffffffffffffffff8111156133a457600080fd5b611d0e848285016131bc565b634e487b7160e01b600052602160045260246000fd5b60208101600483106133e857634e487b7160e01b600052602160045260246000fd5b91905290565b6000806040838503121561340157600080fd5b61340a83612feb565b915061302a60208401613350565b6000806000806080858703121561342e57600080fd5b61343785612feb565b935061344560208601612feb565b925060408501359150606085013567ffffffffffffffff81111561346857600080fd5b8501601f8101871361347957600080fd5b61348887823560208401613164565b91505092959194509250565b600080604083850312156134a757600080fd5b6134b083612feb565b915061302a60208401612feb565b634e487b7160e01b600052601160045260246000fd5b60006000198214156134e8576134e86134be565b5060010190565b600181811c9082168061350357607f821691505b6020821081141561352457634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252602e908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526d1c881b9bdc88185c1c1c9bdd995960921b606082015260800190565b6000821982111561358b5761358b6134be565b500190565b6000828210156135a2576135a26134be565b500390565b634e487b7160e01b600052603260045260246000fd5b600083516135cf818460208801613033565b8351908301906135e3818360208801613033565b01949350505050565b634e487b7160e01b600052601260045260246000fd5b600082613611576136116135ec565b500490565b6000816000190483118215151615613630576136306134be565b500290565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b600082613696576136966135ec565b500690565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516136d3816017850160208801613033565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351613704816028840160208801613033565b01602801949350505050565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906137439083018461305f565b9695505050505050565b60006020828403121561375f57600080fd5b8151611f8c81612fb8565b600081613779576137796134be565b506000190190565b634e487b7160e01b600052603160045260246000fdfea264697066735822122088575c52c99add2050efcbce964ef8e9be4ff0d4bea1b4fe80ec87d9c8048b6964736f6c63430008090033
Published Contract:
// SPDX-License-Identifier: MIT // Sources flattened with hardhat v2.12.2 https://hardhat.org // File @openzeppelin/contracts/access/IAccessControl.sol@v4.7.3 // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev Emitted when `newAdminRole` is set as ``role``9s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role9s admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``9s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``9s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function9s * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; } // File @openzeppelin/contracts/utils/Context.sol@v4.7.3 // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // File @openzeppelin/contracts/utils/Strings.sol@v4.7.3 // OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ 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); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } } // File @openzeppelin/contracts/utils/introspection/IERC165.sol@v4.7.3 // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File @openzeppelin/contracts/utils/introspection/ERC165.sol@v4.7.3 // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // File @openzeppelin/contracts/access/AccessControl.sol@v4.7.3 // OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol) pragma solidity ^0.8.0; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn9t allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role9s admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role9s admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``9s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``9s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function9s * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn9t perform any * checks on the calling account. * * May emit a {RoleGranted} event. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``9s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } } // File @openzeppelin/contracts/utils/Address.sol@v4.7.3 // OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn9t rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity9s `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn9t, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File @openzeppelin/contracts/token/ERC721/IERC721.sol@v4.7.3 // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``9s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); } // File @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol@v4.7.3 // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // File @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol@v4.7.3 // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File @openzeppelin/contracts/token/ERC721/ERC721.sol@v4.7.3 // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: address zero is not a valid owner"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: invalid token ID"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { _requireMinted(tokenId); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overridden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not token owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { _requireMinted(tokenId); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner nor approved"); _safeTransfer(from, to, tokenId, data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { address owner = ERC721.ownerOf(tokenId); return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits an {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Reverts if the `tokenId` has not been minted yet. */ function _requireMinted(uint256 tokenId) internal view virtual { require(_exists(tokenId), "ERC721: invalid token ID"); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { /// @solidity memory-safe-assembly assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``9s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``9s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // File @openzeppelin/contracts/utils/structs/EnumerableSet.sol@v4.7.3 // OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol) pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an array of EnumerableSet. * ==== */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the 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; if (lastIndex != toDeleteIndex) { 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] = valueIndex; // Replace lastValue9s index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { return _values(set._inner); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } } // File @openzeppelin/contracts/utils/structs/EnumerableMap.sol@v4.7.3 // OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableMap.sol) pragma solidity ^0.8.0; /** * @dev Library for managing an enumerable variant of Solidity9s * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`] * type. * * Maps have the following properties: * * - Entries are added, removed, and checked for existence in constant time * (O(1)). * - Entries are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableMap for EnumerableMap.UintToAddressMap; * * // Declare a set state variable * EnumerableMap.UintToAddressMap private myMap; * } * ``` * * The following map types are supported: * * - `uint256 -> address` (`UintToAddressMap`) since v3.0.0 * - `address -> uint256` (`AddressToUintMap`) since v4.6.0 * - `bytes32 -> bytes32` (`Bytes32ToBytes32`) since v4.6.0 * - `uint256 -> uint256` (`UintToUintMap`) since v4.7.0 * - `bytes32 -> uint256` (`Bytes32ToUintMap`) since v4.7.0 * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableMap, you can either remove all elements one by one or create a fresh instance using an array of EnumerableMap. * ==== */ library EnumerableMap { using EnumerableSet for EnumerableSet.Bytes32Set; // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Map type with // bytes32 keys and values. // The Map implementation uses private functions, and user-facing // implementations (such as Uint256ToAddressMap) are just wrappers around // the underlying Map. // This means that we can only create new EnumerableMaps for types that fit // in bytes32. struct Bytes32ToBytes32Map { // Storage of keys EnumerableSet.Bytes32Set _keys; mapping(bytes32 => bytes32) _values; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set( Bytes32ToBytes32Map storage map, bytes32 key, bytes32 value ) internal returns (bool) { map._values[key] = value; return map._keys.add(key); } /** * @dev Removes a key-value pair from a map. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(Bytes32ToBytes32Map storage map, bytes32 key) internal returns (bool) { delete map._values[key]; return map._keys.remove(key); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool) { return map._keys.contains(key); } /** * @dev Returns the number of key-value pairs in the map. O(1). */ function length(Bytes32ToBytes32Map storage map) internal view returns (uint256) { return map._keys.length(); } /** * @dev Returns the key-value pair stored at position `index` in the map. O(1). * * Note that there are no guarantees on the ordering of entries inside the * array, and it may change when more entries are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32ToBytes32Map storage map, uint256 index) internal view returns (bytes32, bytes32) { bytes32 key = map._keys.at(index); return (key, map._values[key]); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function tryGet(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool, bytes32) { bytes32 value = map._values[key]; if (value == bytes32(0)) { return (contains(map, key), bytes32(0)); } else { return (true, value); } } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bytes32) { bytes32 value = map._values[key]; require(value != 0 || contains(map, key), "EnumerableMap: nonexistent key"); return value; } /** * @dev Same as {_get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {_tryGet}. */ function get( Bytes32ToBytes32Map storage map, bytes32 key, string memory errorMessage ) internal view returns (bytes32) { bytes32 value = map._values[key]; require(value != 0 || contains(map, key), errorMessage); return value; } // UintToUintMap struct UintToUintMap { Bytes32ToBytes32Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set( UintToUintMap storage map, uint256 key, uint256 value ) internal returns (bool) { return set(map._inner, bytes32(key), bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(UintToUintMap storage map, uint256 key) internal returns (bool) { return remove(map._inner, bytes32(key)); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(UintToUintMap storage map, uint256 key) internal view returns (bool) { return contains(map._inner, bytes32(key)); } /** * @dev Returns the number of elements in the map. O(1). */ function length(UintToUintMap storage map) internal view returns (uint256) { return length(map._inner); } /** * @dev Returns the element stored at position `index` in the set. O(1). * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintToUintMap storage map, uint256 index) internal view returns (uint256, uint256) { (bytes32 key, bytes32 value) = at(map._inner, index); return (uint256(key), uint256(value)); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function tryGet(UintToUintMap storage map, uint256 key) internal view returns (bool, uint256) { (bool success, bytes32 value) = tryGet(map._inner, bytes32(key)); return (success, uint256(value)); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(UintToUintMap storage map, uint256 key) internal view returns (uint256) { return uint256(get(map._inner, bytes32(key))); } /** * @dev Same as {get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryGet}. */ function get( UintToUintMap storage map, uint256 key, string memory errorMessage ) internal view returns (uint256) { return uint256(get(map._inner, bytes32(key), errorMessage)); } // UintToAddressMap struct UintToAddressMap { Bytes32ToBytes32Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set( UintToAddressMap storage map, uint256 key, address value ) internal returns (bool) { return set(map._inner, bytes32(key), bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) { return remove(map._inner, bytes32(key)); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) { return contains(map._inner, bytes32(key)); } /** * @dev Returns the number of elements in the map. O(1). */ function length(UintToAddressMap storage map) internal view returns (uint256) { return length(map._inner); } /** * @dev Returns the element stored at position `index` in the set. O(1). * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) { (bytes32 key, bytes32 value) = at(map._inner, index); return (uint256(key), address(uint160(uint256(value)))); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. * * _Available since v3.4._ */ function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) { (bool success, bytes32 value) = tryGet(map._inner, bytes32(key)); return (success, address(uint160(uint256(value)))); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(UintToAddressMap storage map, uint256 key) internal view returns (address) { return address(uint160(uint256(get(map._inner, bytes32(key))))); } /** * @dev Same as {get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryGet}. */ function get( UintToAddressMap storage map, uint256 key, string memory errorMessage ) internal view returns (address) { return address(uint160(uint256(get(map._inner, bytes32(key), errorMessage)))); } // AddressToUintMap struct AddressToUintMap { Bytes32ToBytes32Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set( AddressToUintMap storage map, address key, uint256 value ) internal returns (bool) { return set(map._inner, bytes32(uint256(uint160(key))), bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(AddressToUintMap storage map, address key) internal returns (bool) { return remove(map._inner, bytes32(uint256(uint160(key)))); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(AddressToUintMap storage map, address key) internal view returns (bool) { return contains(map._inner, bytes32(uint256(uint160(key)))); } /** * @dev Returns the number of elements in the map. O(1). */ function length(AddressToUintMap storage map) internal view returns (uint256) { return length(map._inner); } /** * @dev Returns the element stored at position `index` in the set. O(1). * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressToUintMap storage map, uint256 index) internal view returns (address, uint256) { (bytes32 key, bytes32 value) = at(map._inner, index); return (address(uint160(uint256(key))), uint256(value)); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function tryGet(AddressToUintMap storage map, address key) internal view returns (bool, uint256) { (bool success, bytes32 value) = tryGet(map._inner, bytes32(uint256(uint160(key)))); return (success, uint256(value)); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(AddressToUintMap storage map, address key) internal view returns (uint256) { return uint256(get(map._inner, bytes32(uint256(uint160(key))))); } /** * @dev Same as {get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryGet}. */ function get( AddressToUintMap storage map, address key, string memory errorMessage ) internal view returns (uint256) { return uint256(get(map._inner, bytes32(uint256(uint160(key))), errorMessage)); } // Bytes32ToUintMap struct Bytes32ToUintMap { Bytes32ToBytes32Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set( Bytes32ToUintMap storage map, bytes32 key, uint256 value ) internal returns (bool) { return set(map._inner, key, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(Bytes32ToUintMap storage map, bytes32 key) internal returns (bool) { return remove(map._inner, key); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(Bytes32ToUintMap storage map, bytes32 key) internal view returns (bool) { return contains(map._inner, key); } /** * @dev Returns the number of elements in the map. O(1). */ function length(Bytes32ToUintMap storage map) internal view returns (uint256) { return length(map._inner); } /** * @dev Returns the element stored at position `index` in the set. O(1). * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32ToUintMap storage map, uint256 index) internal view returns (bytes32, uint256) { (bytes32 key, bytes32 value) = at(map._inner, index); return (key, uint256(value)); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function tryGet(Bytes32ToUintMap storage map, bytes32 key) internal view returns (bool, uint256) { (bool success, bytes32 value) = tryGet(map._inner, key); return (success, uint256(value)); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(Bytes32ToUintMap storage map, bytes32 key) internal view returns (uint256) { return uint256(get(map._inner, key)); } /** * @dev Same as {get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryGet}. */ function get( Bytes32ToUintMap storage map, bytes32 key, string memory errorMessage ) internal view returns (uint256) { return uint256(get(map._inner, key, errorMessage)); } } // File @openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol@v4.7.3 // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``9s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // File @openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol@v4.7.3 // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol) pragma solidity ^0.8.0; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``9s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``9s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension9s ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension9s token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension9s ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from9s tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token9s index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension9s token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 9if9 statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token9s index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // File contracts/TraderPunks.sol pragma solidity ^0.8.4; contract TraderPunks is ERC721, ERC721Enumerable, AccessControl { using EnumerableMap for EnumerableMap.AddressToUintMap; using Strings for uint256; mapping(uint256 => string) private _tokenURIs; enum TokenState { NULL, MINTED, MATERIALIZED, SIGNED } event TokenURIChange(uint256 indexed tokenId, string uri); /** Emitted when the state of a token is changed */ event TokenStateChanged( TokenState indexed to, TokenState indexed from, uint256 indexed tokenId ); /** Emitted when the current supply limit of NFTs is changed */ event NFTSupplyChanged(uint256 supply); /** Emitted when the price of the NFT changes */ event PriceChanged(uint256 price); /** Emmited when the sale activates of deactivates */ event SaleActiveChanged(bool isActive); /** Emmitted when the fee splits are changed */ event FeeSplitChanged(address indexed receiver, uint256 feeBasisPoints); bytes32 public constant MATERIALIZE_TOKEN_ROLE = keccak256("MATERIALIZE_TOKEN_ROLE"); bytes32 public constant SIGN_TOKEN_ROLE = keccak256("SIGN_TOKEN_ROLE"); bytes32 public constant RESERVE_NFT_ROLE = keccak256("RESERVE_NFT_ROLE"); bytes32 public constant SET_NFT_PRICE_ROLE = keccak256("SET_NFT_PRICE_ROLE"); bytes32 public constant SET_ACTIVE_ROLE = keccak256("SET_ACTIVE_ROLE"); bytes32 public constant SET_SUPPLY_ROLE = keccak256("SET_SUPPLY_ROLE"); bytes32 public constant SET_FEE_SPLIT_ROLE = keccak256("SET_FEE_SPLIT_ROLE"); bytes32 public constant SET_BASE_URI_ROLE = keccak256("SET_BASE_URI_ROLE"); bool public saleIsActive; uint256 public nftPrice; uint256 public currentMaxNFTSupply; uint256 public maxNFTSupply; mapping(uint256 => TokenState) internal _tokenIdToState; string internal _mintedBaseURI; string internal _materializedBaseURI; string internal _signedBaseURI; address internal _defaultFundsAddress; EnumerableMap.AddressToUintMap internal _feeSplits; /** @param mintedBaseURI The base token URI to use once a token is minted. @param materializedBaseURI The base token URI to use once a token is materialized. @param signedBaseURI The base token URI to use once a token is signed. @param maxSupply The maximum supply of NFTs that can ever exist @param currentSupply The current allowed supply of NFTs, must be lte maxSupply @param active Whether or not the sale is active @param price The initial price of an NFT */ constructor( address superUser, address defaultFundsAddress, string memory mintedBaseURI, string memory materializedBaseURI, string memory signedBaseURI, uint256 maxSupply, uint256 currentSupply, bool active, uint256 price ) ERC721("TraderPunks", "TPUNK$") { // TODO Change this back before deploying to PROD require(currentSupply <= maxSupply, "current supply must be lte max supply"); _grantRole(DEFAULT_ADMIN_ROLE, superUser); _grantRole(MATERIALIZE_TOKEN_ROLE, superUser); _grantRole(SIGN_TOKEN_ROLE, superUser); _grantRole(SET_NFT_PRICE_ROLE, superUser); _grantRole(SET_ACTIVE_ROLE, superUser); _grantRole(SET_SUPPLY_ROLE, superUser); _grantRole(SET_FEE_SPLIT_ROLE, superUser); _grantRole(SET_BASE_URI_ROLE, superUser); _grantRole(RESERVE_NFT_ROLE, superUser); maxNFTSupply = maxSupply; currentMaxNFTSupply = currentSupply; saleIsActive = active; nftPrice = price; _defaultFundsAddress = defaultFundsAddress; _mintedBaseURI = mintedBaseURI; _materializedBaseURI = materializedBaseURI; _signedBaseURI = signedBaseURI; } /** @dev for OpenTheta compatibility */ function MAX_NFT_SUPPLY() public view returns (uint256) { return currentMaxNFTSupply; } function getNFTPrice() public view returns (uint256) { return nftPrice; } function setNFTPrice(uint256 price) external onlyRole(SET_NFT_PRICE_ROLE) { nftPrice = price; emit PriceChanged(price); } function setSaleActive(bool isActive) external onlyRole(SET_ACTIVE_ROLE) { saleIsActive = isActive; emit SaleActiveChanged(isActive); } function setNFTSupply(uint256 supply) external onlyRole(SET_SUPPLY_ROLE) { require( supply >= totalSupply(), "new supply must be gte current supply" ); require( supply <= maxNFTSupply, "new supply can not be greater than max supply" ); currentMaxNFTSupply = supply; emit NFTSupplyChanged(supply); } function setMintedBaseURI(string memory uri) external onlyRole(SET_BASE_URI_ROLE) { _mintedBaseURI = uri; // TODO Should we emit an event? } function setDefaultFundsAddress(address receiver) external onlyRole(SET_FEE_SPLIT_ROLE) { _defaultFundsAddress = receiver; } /** @notice Split minting fees with another address @notice Set basisPoints to 0 to remove fee split @param receiver the address to send the fee split to @param basisPoints the amount of the fee split in basis points */ function setFeeSplit(address receiver, uint256 basisPoints) external onlyRole(SET_FEE_SPLIT_ROLE) { uint256 totalFeeSplit = 0; for (uint256 i = 0; i < _feeSplits.length(); i++) { (address feeReceiver, uint256 bp) = _feeSplits.at(i); if (feeReceiver == receiver) continue; totalFeeSplit += bp; } require( totalFeeSplit + basisPoints <= 10000, "sum of fee splits may not exceed 100%" ); if (basisPoints == 0) { _feeSplits.remove(receiver); } else { _feeSplits.set(receiver, basisPoints); } emit FeeSplitChanged(receiver, basisPoints); } /** @notice Allows recipient of fee split to transfer their fee split to another address @param newReceiver the address to transfer to full fee split to */ function transferFullFeeSplit(address newReceiver) public { require( _feeSplits.contains(msg.sender), "you do not receive a fee split" ); transferFeeSplit(newReceiver, _feeSplits.get(msg.sender)); } /** @notice Allows the recipient to transfer part of their fee split to another address @param newReceiver the address to transfer to full fee split to @param basisPoints the amount of the fee split to transfer. Example if sender has feeSplit of 3000 (30%) then to transfer half of their fee split they would set basisPoints to 1500 */ function transferFeeSplit(address newReceiver, uint256 basisPoints) public { require( _feeSplits.contains(msg.sender), "you do not receive a fee split" ); require( basisPoints <= _feeSplits.get(msg.sender), "you cannot transfer a larger fee split than what you have" ); uint256 feeBP = basisPoints; if (_feeSplits.contains(newReceiver)) { feeBP += _feeSplits.get(newReceiver); } uint256 newFeeBP = _feeSplits.get(msg.sender) - basisPoints; _feeSplits.set(msg.sender, newFeeBP); _feeSplits.set(newReceiver, feeBP); emit FeeSplitChanged(msg.sender, newFeeBP); emit FeeSplitChanged(newReceiver, feeBP); } /** @notice allows owner to mint nfts without paying @param n the number of nfts to mint @param to the address to send the minted nfts to */ function reserve(uint256 n, address to) external onlyRole(RESERVE_NFT_ROLE) { for (uint256 i = 0; i < n && totalSupply() < currentMaxNFTSupply; i++) { _safeMintAndStateTransition(to); } } /** @notice allows owner to mint nfts to specific addresses without paying @param to the list of addresses to send nfts to. Each address will receive 1 nft */ function reserveToAddresses(address[] memory to) external onlyRole(RESERVE_NFT_ROLE) { for ( uint256 i = 0; i < to.length && totalSupply() < currentMaxNFTSupply; i++ ) { _safeMintAndStateTransition(to[i]); } } function safeMint(address to) public payable { require(saleIsActive, "sale is not active"); require(msg.value == nftPrice, "incorrect funds"); _safeMintTransitionAndFeeSplit(to); } /** @notice transition the state of the token to MATERIALIZED and set the token URI @param tokenId the id of the token to transition @param uri the new token uri to set */ function materializeToken(uint256 tokenId, string memory uri) public onlyRole(MATERIALIZE_TOKEN_ROLE) { _transitionState( tokenId, TokenState.MINTED, TokenState.MATERIALIZED, uri ); } /** @notice transition the state of the token to SIGNED and set the token URI @param tokenId the id of the token to sign @param uri the new token uri to set */ function signToken(uint256 tokenId, string memory uri) public onlyRole(SIGN_TOKEN_ROLE) { _transitionState( tokenId, TokenState.MATERIALIZED, TokenState.SIGNED, uri ); } function tokenIdsByState(TokenState state) public view returns (uint[] memory) { uint nTokensInState = 0; for (uint tokenId = 1; tokenId <= totalSupply(); tokenId++) { if (_tokenIdToState[tokenId] == state) { nTokensInState++; } } uint[] memory tokenIds = new uint[](nTokensInState); uint idx = 0; for (uint tokenId = 1; tokenId <= totalSupply(); tokenId++) { if (_tokenIdToState[tokenId] == state) { tokenIds[idx++] = tokenId; } } return tokenIds; } /** @dev returns TokenState.NULL (0) if token has not been minted. */ function tokenState(uint256 tokenId) public view returns (TokenState) { return _tokenIdToState[tokenId]; } function tokenURI(uint256 tokenId) public view override returns (string memory) { _requireMinted(tokenId); string memory _tokenURI = _tokenURIs[tokenId]; string memory base; TokenState state = _tokenIdToState[tokenId]; if (state == TokenState.SIGNED) { base = _signedBaseURI; } else if (state == TokenState.MATERIALIZED) { base = _materializedBaseURI; } else { base = _mintedBaseURI; _tokenURI = tokenId.toString(); } return string(abi.encodePacked(base, _tokenURI)); } function _safeMintTransitionAndFeeSplit(address to) internal { _safeMintAndStateTransition(to); uint256 rest = msg.value; for (uint256 i = 0; i < _feeSplits.length(); i++) { (address feeReceiver, uint256 feeBP) = _feeSplits.at(i); uint256 payout = (msg.value / 10000) * feeBP; rest -= payout; payable(feeReceiver).transfer(payout); } payable(_defaultFundsAddress).transfer(rest); } function _safeMintAndStateTransition(address to) internal { require(totalSupply() < currentMaxNFTSupply, "max supply reached"); uint256 tokenId = totalSupply() + 1; // Start at ids at 1 not 0 _safeMint(to, tokenId); _transitionState(tokenId, TokenState.NULL, TokenState.MINTED, ""); } /** * @dev Sets `_tokenURI` as the tokenURI of `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal { require(_exists(tokenId), "ERC721URIStorage: URI set of nonexistent token"); _tokenURIs[tokenId] = _tokenURI; emit TokenURIChange(tokenId, _tokenURI); } function _transitionState( uint256 tokenId, TokenState from, TokenState to, string memory uri ) internal { _requireMinted(tokenId); _requireState(tokenId, from); _tokenIdToState[tokenId] = to; if (to != TokenState.MINTED) _setTokenURI(tokenId, uri); emit TokenStateChanged(to, from, tokenId); } function _requireState(uint256 tokenId, TokenState state) internal view { require(_tokenIdToState[tokenId] == state, "invalid state"); } // The following functions are overrides required by Solidity. function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } function _burn(uint256 tokenId) internal override { super._burn(tokenId); if (bytes(_tokenURIs[tokenId]).length != 0) { delete _tokenURIs[tokenId]; } } function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable, AccessControl) returns (bool) { return super.supportsInterface(interfaceId); } }
Contract ABI:
[{"inputs":[{"internalType":"address","name":"superUser","type":"address"},{"internalType":"address","name":"defaultFundsAddress","type":"address"},{"internalType":"string","name":"mintedBaseURI","type":"string"},{"internalType":"string","name":"materializedBaseURI","type":"string"},{"internalType":"string","name":"signedBaseURI","type":"string"},{"internalType":"uint256","name":"maxSupply","type":"uint256"},{"internalType":"uint256","name":"currentSupply","type":"uint256"},{"internalType":"bool","name":"active","type":"bool"},{"internalType":"uint256","name":"price","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"feeBasisPoints","type":"uint256"}],"name":"FeeSplitChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"supply","type":"uint256"}],"name":"NFTSupplyChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"}],"name":"PriceChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"isActive","type":"bool"}],"name":"SaleActiveChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"enum TraderPunks.TokenState","name":"to","type":"uint8"},{"indexed":true,"internalType":"enum TraderPunks.TokenState","name":"from","type":"uint8"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"TokenStateChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"string","name":"uri","type":"string"}],"name":"TokenURIChange","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":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MATERIALIZE_TOKEN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_NFT_SUPPLY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"RESERVE_NFT_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SET_ACTIVE_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SET_BASE_URI_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SET_FEE_SPLIT_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SET_NFT_PRICE_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SET_SUPPLY_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SIGN_TOKEN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"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":"currentMaxNFTSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNFTPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"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":"uint256","name":"tokenId","type":"uint256"},{"internalType":"string","name":"uri","type":"string"}],"name":"materializeToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"maxNFTSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nftPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"n","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"name":"reserve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"to","type":"address[]"}],"name":"reserveToAddresses","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"safeMint","outputs":[],"stateMutability":"payable","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":[],"name":"saleIsActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"setDefaultFundsAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"basisPoints","type":"uint256"}],"name":"setFeeSplit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"uri","type":"string"}],"name":"setMintedBaseURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"price","type":"uint256"}],"name":"setNFTPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"supply","type":"uint256"}],"name":"setNFTSupply","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"isActive","type":"bool"}],"name":"setSaleActive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"string","name":"uri","type":"string"}],"name":"signToken","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":"enum TraderPunks.TokenState","name":"state","type":"uint8"}],"name":"tokenIdsByState","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":"tokenState","outputs":[{"internalType":"enum TraderPunks.TokenState","name":"","type":"uint8"}],"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":"newReceiver","type":"address"},{"internalType":"uint256","name":"basisPoints","type":"uint256"}],"name":"transferFeeSplit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newReceiver","type":"address"}],"name":"transferFullFeeSplit","outputs":[],"stateMutability":"nonpayable","type":"function"}]