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:
0x6d3578e6dbd215787178f147af97891134b5de43
Name:
TraderPunk FRIENDS: Golden 10-day Access
Symbol:
TPF_GOLD
Total Supply:
79
Decimal:
Compiler Version:
v0.8.9
Published Contract:
Send Transactions
TNT-20 Transactions
TNT-721 Transactions
Contract
Contract ByteCode:
0x60806040526004361061025c5760003560e01c80636352211e11610144578063b88d4fde116100b6578063cd87d7661161007a578063cd87d76614610745578063d539139314610765578063d547741f14610799578063d9548e53146107b9578063e985e9c5146107d9578063f846c01f1461082257600080fd5b8063b88d4fde146106a4578063b8aa7360146106c4578063c5b70f69146106f2578063c87b56dd14610712578063c96906ca1461073257600080fd5b8063806c79f311610108578063806c79f3146105f857806391d148541461061a57806395d89b411461063a5780639e34070f1461064f578063a217fddf1461066f578063a22cb4651461068457600080fd5b80636352211e146105625780636833f2001461058257806370a08231146105a25780637e7e1007146105c25780637ecad79b146105e257600080fd5b80632cac44ca116101dd5780633b608af2116101a15780633b608af21461048e57806340d097c3146104cd57806342842e0e146104ed57806349cb89c11461050d5780634bc77a921461052d5780634f6ccce71461054257600080fd5b80632cac44ca146103ee5780632f2ff15d1461040e5780632f745c591461042e57806331809dcf1461044e57806336568abe1461046e57600080fd5b80630bade415116102245780630bade4151461035457806318160ddd1461036957806323b872dd1461037e578063248a9ca31461039e578063249e7c12146103ce57600080fd5b806301ffc9a71461026157806306fdde0314610296578063081812fc146102b857806308740a3b146102f0578063095ea7b314610332575b600080fd5b34801561026d57600080fd5b5061028161027c366004612a61565b610848565b60405190151581526020015b60405180910390f35b3480156102a257600080fd5b506102ab610859565b60405161028d9190612ad6565b3480156102c457600080fd5b506102d86102d3366004612ae9565b6108eb565b6040516001600160a01b03909116815260200161028d565b3480156102fc57600080fd5b506103247fec5aad7bdface20c35bc02d6d2d5760df981277427368525d634f4e2603ea19281565b60405190815260200161028d565b34801561033e57600080fd5b5061035261034d366004612b1e565b610912565b005b34801561036057600080fd5b506102d8610a2d565b34801561037557600080fd5b50600854610324565b34801561038a57600080fd5b50610352610399366004612b48565b610a58565b3480156103aa57600080fd5b506103246103b9366004612ae9565b6000908152600a602052604090206001015490565b3480156103da57600080fd5b506103526103e9366004612bcb565b610a89565b3480156103fa57600080fd5b50610352610409366004612b1e565b610af3565b34801561041a57600080fd5b50610352610429366004612c78565b610ca5565b34801561043a57600080fd5b50610324610449366004612b1e565b610cca565b34801561045a57600080fd5b50610281610469366004612ae9565b610d60565b34801561047a57600080fd5b50610352610489366004612c78565b610d9c565b34801561049a57600080fd5b506104ae6104a9366004612ae9565b610e1a565b604080516001600160a01b03909316835260208301919091520161028d565b3480156104d957600080fd5b506103526104e8366004612ca4565b610e9e565b3480156104f957600080fd5b50610352610508366004612b48565b610eda565b34801561051957600080fd5b50610352610528366004612ca4565b610ef5565b34801561053957600080fd5b50610324610f5e565b34801561054e57600080fd5b5061032461055d366004612ae9565b611015565b34801561056e57600080fd5b506102d861057d366004612ae9565b6110a8565b34801561058e57600080fd5b5061032461059d366004612ae9565b6110dd565b3480156105ae57600080fd5b506103246105bd366004612ca4565b611182565b3480156105ce57600080fd5b506103526105dd366004612ae9565b611208565b3480156105ee57600080fd5b50610324600c5481565b34801561060457600080fd5b506103246000805160206130e783398151915281565b34801561062657600080fd5b50610281610635366004612c78565b6113a8565b34801561064657600080fd5b506102ab6113d3565b34801561065b57600080fd5b5061028161066a366004612ae9565b6113e2565b34801561067b57600080fd5b50610324600081565b34801561069057600080fd5b5061035261069f366004612cbf565b61141f565b3480156106b057600080fd5b506103526106bf366004612cfb565b61142a565b3480156106d057600080fd5b50600b546106df9061ffff1681565b60405161ffff909116815260200161028d565b3480156106fe57600080fd5b5061035261070d366004612ca4565b611462565b34801561071e57600080fd5b506102ab61072d366004612ae9565b61149d565b610352610740366004612ae9565b611582565b34801561075157600080fd5b50610352610760366004612b1e565b61190b565b34801561077157600080fd5b506103247f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a681565b3480156107a557600080fd5b506103526107b4366004612c78565b611a55565b3480156107c557600080fd5b506102816107d4366004612ae9565b611a7a565b3480156107e557600080fd5b506102816107f4366004612dbb565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561082e57600080fd5b50600b546102d8906201000090046001600160a01b031681565b600061085382611ad5565b92915050565b60606000805461086890612de5565b80601f016020809104026020016040519081016040528092919081815260200182805461089490612de5565b80156108e15780601f106108b6576101008083540402835291602001916108e1565b820191906000526020600020905b8154815290600101906020018083116108c457829003601f168201915b5050505050905090565b60006108f682611afa565b506000908152600460205260409020546001600160a01b031690565b600061091d826110a8565b9050806001600160a01b0316836001600160a01b031614156109905760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b336001600160a01b03821614806109ac57506109ac81336107f4565b610a1e5760405162461bcd60e51b815260206004820152603e60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206e6f7220617070726f76656420666f7220616c6c00006064820152608401610987565b610a288383611b1f565b505050565b60006000805160206130e7833981519152610a4781611b8d565b50506011546001600160a01b031690565b610a623382611b97565b610a7e5760405162461bcd60e51b815260040161098790612e20565b610a28838383611c16565b7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6610ab381611b8d565b60005b8251811015610a2857610ae1838281518110610ad457610ad4612e6e565b6020026020010151610e9e565b80610aeb81612e9a565b915050610ab6565b610afe601433611dbd565b610b4a5760405162461bcd60e51b815260206004820152601e60248201527f796f7520646f206e6f7420726563656976652061206665652073706c697400006044820152606401610987565b610b55601433611dd9565b811115610bca5760405162461bcd60e51b815260206004820152603960248201527f796f752063616e6e6f74207472616e736665722061206c61726765722066656560448201527f2073706c6974207468616e207768617420796f752068617665000000000000006064820152608401610987565b80610bd6601484611dbd565b15610bf357610be6601484611dd9565b610bf09082612eb5565b90505b600082610c01601433611dd9565b610c0b9190612ecd565b9050610c1960143383611dee565b50610c2660148584611dee565b5060405181815233907f55b44f0aab9d06b43c6f493c1625172db5b86542b6fdd665ebd4e98729db21cd9060200160405180910390a2836001600160a01b03167f55b44f0aab9d06b43c6f493c1625172db5b86542b6fdd665ebd4e98729db21cd83604051610c9791815260200190565b60405180910390a250505050565b6000828152600a6020526040902060010154610cc081611b8d565b610a288383611e04565b6000610cd583611182565b8210610d375760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610987565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b6000610d6b82611e8a565b610d875760405162461bcd60e51b815260040161098790612ee4565b50600090815260126020526040902054151590565b6001600160a01b0381163314610e0c5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610987565b610e168282611ea7565b5050565b6000806000805160206130e7833981519152610e3581611b8d565b6000610e416014611f0e565b9050808510610e885760405162461bcd60e51b8152602060048201526013602482015272696e646578206f7574206f6620626f756e647360681b6044820152606401610987565b610e93601486611f19565b935093505050915091565b7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6610ec881611b8d565b610e1682610ed560085490565b611f35565b610a288383836040518060200160405280600081525061142a565b610f00601433611dbd565b610f4c5760405162461bcd60e51b815260206004820152601e60248201527f796f7520646f206e6f7420726563656976652061206665652073706c697400006044820152606401610987565b610f5b81610409601433611dd9565b50565b600b546000906001600160a01b03620100008204169061271090610f869061ffff1682612f1b565b61ffff16826001600160a01b031663fb107a4f6040518163ffffffff1660e01b815260040160206040518083038186803b158015610fc357600080fd5b505afa158015610fd7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ffb9190612f3e565b6110059190612f57565b61100f9190612f76565b91505090565b600061102060085490565b82106110835760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610987565b6008828154811061109657611096612e6e565b90600052602060002001549050919050565b6000818152600260205260408120546001600160a01b0316806108535760405162461bcd60e51b815260040161098790612ee4565b60006110e882611e8a565b6111045760405162461bcd60e51b815260040161098790612ee4565b61110d82610d60565b6111595760405162461bcd60e51b815260206004820152601860248201527f546f6b656e206e6f7420796574206163746976617465642e00000000000000006044820152606401610987565b600c546111699062015180612f57565b6000838152601260205260409020546108539190612eb5565b60006001600160a01b0382166111ec5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b6064820152608401610987565b506001600160a01b031660009081526003602052604090205490565b7fec5aad7bdface20c35bc02d6d2d5760df981277427368525d634f4e2603ea19261123281611b8d565b61123b82611e8a565b6112575760405162461bcd60e51b815260040161098790612ee4565b61126082611a7a565b156112985760405162461bcd60e51b815260206004820152600860248201526722bc3834b932b21760c11b6044820152606401610987565b6112a1826113e2565b156112e15760405162461bcd60e51b815260206004820152601060248201526f20b63932b0b23c9031b630b4b6b2b21760811b6044820152606401610987565b6112ea82610d60565b1561132c5760405162461bcd60e51b815260206004820152601260248201527120b63932b0b23c9030b1ba34bb30ba32b21760711b6044820152606401610987565b6000828152601260205260408082204290555183917f6c3b144b728c763da6f9b36f4252f7621560b1607f7bbbeab1c6db8a5341f10991a2817fe63ff1ee191e6fc902b7b47aa9ccf80bd883ec287a6d18db9961e5c5ec6b80f061138f8461149d565b60405161139c9190612ad6565b60405180910390a25050565b6000918252600a602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60606001805461086890612de5565b60006113ed82611e8a565b6114095760405162461bcd60e51b815260040161098790612ee4565b5060009081526013602052604090205460ff1690565b610e16338383611f4f565b6114343383611b97565b6114505760405162461bcd60e51b815260040161098790612e20565b61145c8484848461201e565b50505050565b6000805160206130e783398151915261147a81611b8d565b50601180546001600160a01b0319166001600160a01b0392909216919091179055565b60606114a8826113e2565b1561153f57600f80546114ba90612de5565b80601f01602080910402602001604051908101604052809291908181526020018280546114e690612de5565b80156115335780601f1061150857610100808354040283529160200191611533565b820191906000526020600020905b81548152906001019060200180831161151657829003601f168201915b50505050509050919050565b61154882611a7a565b1561155a57601080546114ba90612de5565b61156382610d60565b1561157557600e80546114ba90612de5565b600d80546114ba90612de5565b3361158c826110a8565b6001600160a01b0316146115e25760405162461bcd60e51b815260206004820152601a60248201527f596f7520646f206e6f74206f776e207468697320746f6b656e2e0000000000006044820152606401610987565b6115eb816113e2565b156116435760405162461bcd60e51b815260206004820152602260248201527f446973636f756e742068617320616c7265616479206265656e20636c61696d65604482015261321760f11b6064820152608401610987565b61164c81611a7a565b156116915760405162461bcd60e51b81526020600482015260156024820152742234b9b1b7bab73a103430b99032bc3834b932b21760591b6044820152606401610987565b61169a81610d60565b6116e65760405162461bcd60e51b815260206004820152601860248201527f547269616c206e6f7420796574206163746976617465642e00000000000000006044820152606401610987565b6116ee610f5e565b34146117345760405162461bcd60e51b81526020600482015260156024820152742bb937b733903b30b63ab29037b3102a232aa2a61760591b6044820152606401610987565b600081815260136020526040908190208054600160ff199091168117909155600b5491516303339bcb60e01b81526004810191909152336024820152620100009091046001600160a01b03169081906303339bcb90604401600060405180830381600087803b1580156117a657600080fd5b505af11580156117ba573d6000803e3d6000fd5b5034925060009150505b6117ce6014611f0e565b81101561185d576000806117e3601484611f19565b909250905060006127106117f78334612f57565b6118019190612f76565b905061180d8186612ecd565b6040519095506001600160a01b0384169082156108fc029083906000818181858888f19350505050158015611846573d6000803e3d6000fd5b50505050808061185590612e9a565b9150506117c4565b506011546040516001600160a01b039091169082156108fc029083906000818181858888f19350505050158015611898573d6000803e3d6000fd5b50604051839033907f9bd5e6604ba26fc850adf2c18e610bd4f6d89691f7c05f785e06b1dfafef450c90600090a3827fe63ff1ee191e6fc902b7b47aa9ccf80bd883ec287a6d18db9961e5c5ec6b80f06118f18561149d565b6040516118fe9190612ad6565b60405180910390a2505050565b6000805160206130e783398151915261192381611b8d565b6000805b6119316014611f0e565b81101561198c57600080611946601484611f19565b91509150866001600160a01b0316826001600160a01b0316141561196b57505061197a565b6119758185612eb5565b935050505b8061198481612e9a565b915050611927565b5061271061199a8483612eb5565b11156119f65760405162461bcd60e51b815260206004820152602560248201527f73756d206f66206665652073706c697473206d6179206e6f7420657863656564604482015264203130302560d81b6064820152608401610987565b82611a0c57611a06601485612051565b50611a1a565b611a1860148585611dee565b505b836001600160a01b03167f55b44f0aab9d06b43c6f493c1625172db5b86542b6fdd665ebd4e98729db21cd84604051610c9791815260200190565b6000828152600a6020526040902060010154611a7081611b8d565b610a288383611ea7565b6000611a8582611e8a565b611aa15760405162461bcd60e51b815260040161098790612ee4565b611aaa82610d60565b8015611abc5750611aba826113e2565b155b80156108535750611acc826110dd565b42101592915050565b60006001600160e01b03198216637965db0b60e01b1480610853575061085382612066565b611b0381611e8a565b610f5b5760405162461bcd60e51b815260040161098790612ee4565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611b54826110a8565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b610f5b813361208b565b600080611ba3836110a8565b9050806001600160a01b0316846001600160a01b03161480611bea57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b80611c0e5750836001600160a01b0316611c03846108eb565b6001600160a01b0316145b949350505050565b826001600160a01b0316611c29826110a8565b6001600160a01b031614611c8d5760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b6064820152608401610987565b6001600160a01b038216611cef5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610987565b611cfa8383836120ef565b611d05600082611b1f565b6001600160a01b0383166000908152600360205260408120805460019290611d2e908490612ecd565b90915550506001600160a01b0382166000908152600360205260408120805460019290611d5c908490612eb5565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6000611dd2836001600160a01b0384166120fa565b9392505050565b6000611dd2836001600160a01b038416612106565b6000611c0e846001600160a01b03851684612176565b611e0e82826113a8565b610e16576000828152600a602090815260408083206001600160a01b03851684529091529020805460ff19166001179055611e463390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000908152600260205260409020546001600160a01b0316151590565b611eb182826113a8565b15610e16576000828152600a602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600061085382612193565b6000808080611f28868661219e565b9097909650945050505050565b610e168282604051806020016040528060008152506121c9565b816001600160a01b0316836001600160a01b03161415611fb15760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610987565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b612029848484611c16565b612035848484846121fc565b61145c5760405162461bcd60e51b815260040161098790612f98565b6000611dd2836001600160a01b038416612309565b60006001600160e01b0319821663780e9d6360e01b1480610853575061085382612326565b61209582826113a8565b610e16576120ad816001600160a01b03166014612376565b6120b8836020612376565b6040516020016120c9929190612fea565b60408051601f198184030181529082905262461bcd60e51b825261098791600401612ad6565b610a28838383612512565b6000611dd283836125ca565b60008181526002830160205260408120548015158061212a575061212a84846120fa565b611dd25760405162461bcd60e51b815260206004820152601e60248201527f456e756d657261626c654d61703a206e6f6e6578697374656e74206b657900006044820152606401610987565b60008281526002840160205260408120829055611c0e84846125e2565b6000610853826125ee565b600080806121ac85856125f8565b600081815260029690960160205260409095205494959350505050565b6121d38383612604565b6121e060008484846121fc565b610a285760405162461bcd60e51b815260040161098790612f98565b60006001600160a01b0384163b156122fe57604051630a85bd0160e11b81526001600160a01b0385169063150b7a029061224090339089908890889060040161305f565b602060405180830381600087803b15801561225a57600080fd5b505af192505050801561228a575060408051601f3d908101601f191682019092526122879181019061309c565b60015b6122e4573d8080156122b8576040519150601f19603f3d011682016040523d82523d6000602084013e6122bd565b606091505b5080516122dc5760405162461bcd60e51b815260040161098790612f98565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611c0e565b506001949350505050565b60008181526002830160205260408120819055611dd28383612743565b60006001600160e01b031982166380ac58cd60e01b148061235757506001600160e01b03198216635b5e139f60e01b145b8061085357506301ffc9a760e01b6001600160e01b0319831614610853565b60606000612385836002612f57565b612390906002612eb5565b67ffffffffffffffff8111156123a8576123a8612b84565b6040519080825280601f01601f1916602001820160405280156123d2576020820181803683370190505b509050600360fc1b816000815181106123ed576123ed612e6e565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061241c5761241c612e6e565b60200101906001600160f81b031916908160001a9053506000612440846002612f57565b61244b906001612eb5565b90505b60018111156124c3576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061247f5761247f612e6e565b1a60f81b82828151811061249557612495612e6e565b60200101906001600160f81b031916908160001a90535060049490941c936124bc816130b9565b905061244e565b508315611dd25760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610987565b6001600160a01b03831661256d5761256881600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b612590565b816001600160a01b0316836001600160a01b03161461259057612590838261274f565b6001600160a01b0382166125a757610a28816127ec565b826001600160a01b0316826001600160a01b031614610a2857610a28828261289b565b60008181526001830160205260408120541515611dd2565b6000611dd283836128df565b6000610853825490565b6000611dd2838361292e565b6001600160a01b03821661265a5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610987565b61266381611e8a565b156126b05760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610987565b6126bc600083836120ef565b6001600160a01b03821660009081526003602052604081208054600192906126e5908490612eb5565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6000611dd28383612958565b6000600161275c84611182565b6127669190612ecd565b6000838152600760205260409020549091508082146127b9576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b6008546000906127fe90600190612ecd565b6000838152600960205260408120546008805493945090928490811061282657612826612e6e565b90600052602060002001549050806008838154811061284757612847612e6e565b600091825260208083209091019290925582815260099091526040808220849055858252812055600880548061287f5761287f6130d0565b6001900381819060005260206000200160009055905550505050565b60006128a683611182565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b600081815260018301602052604081205461292657508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610853565b506000610853565b600082600001828154811061294557612945612e6e565b9060005260206000200154905092915050565b60008181526001830160205260408120548015612a4157600061297c600183612ecd565b855490915060009061299090600190612ecd565b90508181146129f55760008660000182815481106129b0576129b0612e6e565b90600052602060002001549050808760000184815481106129d3576129d3612e6e565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080612a0657612a066130d0565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610853565b6000915050610853565b6001600160e01b031981168114610f5b57600080fd5b600060208284031215612a7357600080fd5b8135611dd281612a4b565b60005b83811015612a99578181015183820152602001612a81565b8381111561145c5750506000910152565b60008151808452612ac2816020860160208601612a7e565b601f01601f19169290920160200192915050565b602081526000611dd26020830184612aaa565b600060208284031215612afb57600080fd5b5035919050565b80356001600160a01b0381168114612b1957600080fd5b919050565b60008060408385031215612b3157600080fd5b612b3a83612b02565b946020939093013593505050565b600080600060608486031215612b5d57600080fd5b612b6684612b02565b9250612b7460208501612b02565b9150604084013590509250925092565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715612bc357612bc3612b84565b604052919050565b60006020808385031215612bde57600080fd5b823567ffffffffffffffff80821115612bf657600080fd5b818501915085601f830112612c0a57600080fd5b813581811115612c1c57612c1c612b84565b8060051b9150612c2d848301612b9a565b8181529183018401918481019088841115612c4757600080fd5b938501935b83851015612c6c57612c5d85612b02565b82529385019390850190612c4c565b98975050505050505050565b60008060408385031215612c8b57600080fd5b82359150612c9b60208401612b02565b90509250929050565b600060208284031215612cb657600080fd5b611dd282612b02565b60008060408385031215612cd257600080fd5b612cdb83612b02565b915060208301358015158114612cf057600080fd5b809150509250929050565b60008060008060808587031215612d1157600080fd5b612d1a85612b02565b93506020612d29818701612b02565b935060408601359250606086013567ffffffffffffffff80821115612d4d57600080fd5b818801915088601f830112612d6157600080fd5b813581811115612d7357612d73612b84565b612d85601f8201601f19168501612b9a565b91508082528984828501011115612d9b57600080fd5b808484018584013760008482840101525080935050505092959194509250565b60008060408385031215612dce57600080fd5b612dd783612b02565b9150612c9b60208401612b02565b600181811c90821680612df957607f821691505b60208210811415612e1a57634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252602e908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526d1c881b9bdc88185c1c1c9bdd995960921b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600019821415612eae57612eae612e84565b5060010190565b60008219821115612ec857612ec8612e84565b500190565b600082821015612edf57612edf612e84565b500390565b60208082526018908201527f4552433732313a20696e76616c696420746f6b656e2049440000000000000000604082015260600190565b600061ffff83811690831681811015612f3657612f36612e84565b039392505050565b600060208284031215612f5057600080fd5b5051919050565b6000816000190483118215151615612f7157612f71612e84565b500290565b600082612f9357634e487b7160e01b600052601260045260246000fd5b500490565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351613022816017850160208801612a7e565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351613053816028840160208801612a7e565b01602801949350505050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061309290830184612aaa565b9695505050505050565b6000602082840312156130ae57600080fd5b8151611dd281612a4b565b6000816130c8576130c8612e84565b506000190190565b634e487b7160e01b600052603160045260246000fdfe6b1d205222639f45a1784c5e4e7f983edb11ec13b25b2a06b51d0a5b8fac24eda264697066735822122074c7e1ef60916782b5e73180e19ddc8310e47e58909f61619e744b22fcbe37a664736f6c63430008090033
Published Contract:
// Sources flattened with hardhat v2.12.2 https://hardhat.org // File @openzeppelin/contracts/access/IAccessControl.sol@v4.7.3 // SPDX-License-Identifier: MIT // 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``'s 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 role's 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``'s 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``'s 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 function's * 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 OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); 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 doesn't 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 role's 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 role's 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``'s 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``'s 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 function's * 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 doesn't 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``'s 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 shouldn't 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 Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (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 wasn't, 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``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * 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``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `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 value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; 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 lastValue's 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 Solidity's * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`] * type. * * Maps have the following properties: * * - Entries are added, removed, and checked for existence in constant time * (O(1)). * - Entries are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableMap for EnumerableMap.UintToAddressMap; * * // Declare a set state variable * EnumerableMap.UintToAddressMap private myMap; * } * ``` * * 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``'s 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``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `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 extension's 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 extension's 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 extension's 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 from's 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 token's 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 extension's 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 'if' 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 token's 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); } } // File @openzeppelin/contracts/utils/cryptography/ECDSA.sol@v4.7.3 // OpenZeppelin Contracts (last updated v4.7.3) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } else if (error == RecoverError.InvalidSignatureV) { revert("ECDSA: invalid signature 'v' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. /// @solidity memory-safe-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address, RecoverError) { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } if (v != 27 && v != 28) { return (address(0), RecoverError.InvalidSignatureV); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message: 32", hash)); } /** * @dev Returns an Ethereum Signed Message, created from `s`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message: ", Strings.toString(s.length), s)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } } // File contracts/TraderPunksTrial.sol pragma solidity ^0.8.4; contract TraderPunksTrial is ERC721, ERC721Enumerable, AccessControl { using EnumerableMap for EnumerableMap.AddressToUintMap; using ECDSA for bytes32; /** @notice Stores the URIs to be used for each state */ struct URIsByState { string minted; string activated; string claimed; string expired; } event FeeSplitChanged(address indexed receiver, uint256 feeBasisPoints); /** @notice NOT EMITTED FOR TOKEN EXPIRY */ event TokenURIChange(uint256 indexed tokenId, string uri); event TrialActivated(uint256 indexed tokenId); event DiscountClaimed(address indexed by, uint256 indexed tokenId); /** @notice Allows the user to mint tokens. */ bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); /** @notice Allows the user to activate tokens (used by PunkBot to activate trial) */ bytes32 public constant ACTIVATOR_ROLE = keccak256("ACTIVATOR_ROLE"); /** @notice Allows the user to manage fee splits for all users. */ bytes32 public constant SET_FEE_SPLIT_ROLE = keccak256("SET_FEE_SPLIT_ROLE"); /** @notice The discount in basis points. 25% off -> 2500 */ uint16 public discountBasisPoints; /** @notice The address of the token that will be minted when claiming the discount. */ address public traderPunksContractAddress; /** @notice How long the discount is available for (in days) after the token is activated. */ uint public validityPeriodDays; URIsByState internal _uris; address internal _defaultFundsAddress; mapping(uint256 => uint) _activations; mapping(uint256 => bool) _claimed; EnumerableMap.AddressToUintMap internal _feeSplits; /** @param name The name of the NFT (ERC721) @param symbol The name of the symbol (ERC721) @param uris The token URI for each state @param owner The super user of the contract @param minters The list of addresses to be granted MINTER_ROLE @param activators The list of addresses to be granted ACTIVATOR_ROLE @param defaultFundsAddress The address to transfer remaining funds to after fee splits @param traderPunksContract The address of the NFT to mint when discount is claimed. This trial contract must be granted MINTER_ROLE on the delegate contract. @param discountBP The minting discount to be applied in basis points. 25% off -> 2500 @param validityPeriodDays_ The validity period of the discount after activation in days. */ constructor( string memory name, string memory symbol, URIsByState memory uris, address owner, address[] memory minters, address[] memory activators, address defaultFundsAddress, address traderPunksContract, uint16 discountBP, uint validityPeriodDays_ ) ERC721(name, symbol) { _grantRole(DEFAULT_ADMIN_ROLE, owner); _grantRole(MINTER_ROLE, owner); _grantRole(ACTIVATOR_ROLE, owner); _grantRole(SET_FEE_SPLIT_ROLE, owner); _uris = uris; discountBasisPoints = discountBP; traderPunksContractAddress = traderPunksContract; _defaultFundsAddress = defaultFundsAddress; validityPeriodDays = validityPeriodDays_; for (uint i = 0; i < minters.length; i++) { _grantRole(MINTER_ROLE, minters[i]); } for (uint i = 0; i < activators.length; i++) { _grantRole(ACTIVATOR_ROLE, activators[i]); } } /** @notice Set the address that remaining funds are transfered to. @param receiver The address to transfer funds to */ function setDefaultFundsAddress( address receiver ) external onlyRole(SET_FEE_SPLIT_ROLE) { _defaultFundsAddress = receiver; } /** @notice Returns the address that remaining funds are transfered to. */ function getDefaultFundsAddress() external view onlyRole(SET_FEE_SPLIT_ROLE) returns (address) { return _defaultFundsAddress; } /** @notice Used to list fee splits @param index The index in the list of fee splits */ function getFeeSplit( uint index ) external view onlyRole(SET_FEE_SPLIT_ROLE) returns (address, uint) { uint length = _feeSplits.length(); require(index < length, "index out of bounds"); return _feeSplits.at(index); } /** @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 Marks that the trial has been started by PunkBot @param tokenId the id of the token to activate */ function activateTrial(uint256 tokenId) external onlyRole(ACTIVATOR_ROLE) { require(_exists(tokenId), "ERC721: invalid token ID"); require(!isExpired(tokenId), "Expired."); require(!isClaimed(tokenId), "Already claimed."); require(!isActivated(tokenId), "Already activated."); _activations[tokenId] = block.timestamp; emit TrialActivated(tokenId); emit TokenURIChange(tokenId, tokenURI(tokenId)); } /** @notice Returns the expiry date of the discount, or reverts if token has not been activated. */ function getExpiryDate(uint256 tokenId) public view returns (uint) { require(_exists(tokenId), "ERC721: invalid token ID"); require(isActivated(tokenId), "Token not yet activated."); return _activations[tokenId] + (validityPeriodDays * (1 days)); } function isActivated(uint256 tokenId) public view returns (bool) { require(_exists(tokenId), "ERC721: invalid token ID"); return _activations[tokenId] > 0; } function isExpired(uint256 tokenId) public view returns (bool) { require(_exists(tokenId), "ERC721: invalid token ID"); return isActivated(tokenId) && !isClaimed(tokenId) && block.timestamp >= getExpiryDate(tokenId); } function isClaimed(uint256 tokenId) public view returns (bool) { require(_exists(tokenId), "ERC721: invalid token ID"); return _claimed[tokenId]; } /** @notice Claim the discount and mint a TraderPunk. */ function claimDiscount(uint256 tokenId) external payable { require(ownerOf(tokenId) == msg.sender, "You do not own this token."); require(!isClaimed(tokenId), "Discount has already been claimed."); require(!isExpired(tokenId), "Discount has expired."); require(isActivated(tokenId), "Trial not yet activated."); require( msg.value == getNFTPriceWithDiscount(), "Wrong value of TFUEL." ); _claimed[tokenId] = true; TraderPunks tpContract = TraderPunks(traderPunksContractAddress); tpContract.reserve(1, msg.sender); uint256 rest = msg.value; for (uint256 i = 0; i < _feeSplits.length(); i++) { (address feeReceiver, uint256 feeBP) = _feeSplits.at(i); uint256 payout = (msg.value * feeBP) / 10000; rest -= payout; payable(feeReceiver).transfer(payout); } payable(_defaultFundsAddress).transfer(rest); emit DiscountClaimed(msg.sender, tokenId); emit TokenURIChange(tokenId, tokenURI(tokenId)); } /** @notice Returns the discounted mint price */ function getNFTPriceWithDiscount() public view returns (uint256) { TraderPunks tpContract = TraderPunks(traderPunksContractAddress); return (tpContract.getNFTPrice() * (10_000 - discountBasisPoints)) / 10_000; } /** @notice Mint a TRIAL NFT (Not a TraderPunk!) */ function safeMint(address to) public onlyRole(MINTER_ROLE) { _safeMint(to, totalSupply()); } /** @notice Mint many trial NFTs. */ function safeMintMany(address[] memory to) public onlyRole(MINTER_ROLE) { for (uint256 i = 0; i < to.length; i++) { safeMint(to[i]); } } function tokenURI( uint256 tokenId ) public view override returns (string memory) { if (isClaimed(tokenId)) return _uris.claimed; if (isExpired(tokenId)) return _uris.expired; if (isActivated(tokenId)) return _uris.activated; return _uris.minted; } // 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 supportsInterface( bytes4 interfaceId ) public view override(ERC721, ERC721Enumerable, AccessControl) returns (bool) { return super.supportsInterface(interfaceId); } }
Contract ABI:
[{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"components":[{"internalType":"string","name":"minted","type":"string"},{"internalType":"string","name":"activated","type":"string"},{"internalType":"string","name":"claimed","type":"string"},{"internalType":"string","name":"expired","type":"string"}],"internalType":"struct TraderPunksTrial.URIsByState","name":"uris","type":"tuple"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"address[]","name":"minters","type":"address[]"},{"internalType":"address[]","name":"activators","type":"address[]"},{"internalType":"address","name":"defaultFundsAddress","type":"address"},{"internalType":"address","name":"traderPunksContract","type":"address"},{"internalType":"uint16","name":"discountBP","type":"uint16"},{"internalType":"uint256","name":"validityPeriodDays_","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":"by","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"DiscountClaimed","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":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":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"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"TrialActivated","type":"event"},{"inputs":[],"name":"ACTIVATOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINTER_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":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"activateTrial","outputs":[],"stateMutability":"nonpayable","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":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"claimDiscount","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"discountBasisPoints","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"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":"getDefaultFundsAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getExpiryDate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getFeeSplit","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNFTPriceWithDiscount","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":"uint256","name":"tokenId","type":"uint256"}],"name":"isActivated","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"}],"name":"isClaimed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"isExpired","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","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":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"to","type":"address[]"}],"name":"safeMintMany","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"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":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"traderPunksContractAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"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"},{"inputs":[],"name":"validityPeriodDays","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]