Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0x7Bb5DbF0d4F31d4a0feC294E0662c00521DD915C
Balance 0 ETH
Nonce 1
Code Size 10915 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

10915 bytes
0x608060405234801561000f575f80fd5b5060043610610148575f3560e01c80638da5cb5b116100bf578063bdb6955a11610079578063bdb6955a14610330578063c4d4073b14610343578063c6dba62414610364578063ce3aef9814610397578063e9aab685146103aa578063f2fde38b146103bd575f80fd5b80638da5cb5b1461025a5780639345feac1461027e578063956e958a14610291578063966beda9146102b7578063b31985c2146102ca578063bb7c93fa1461031d575f80fd5b806324f7374c1161011057806324f7374c146101e95780633d086286146102115780634be0110c146102195780635d5fd04d1461022c57806363df70141461023f578063715018a614610252575f80fd5b806301ffc9a71461014c57806313154b7e14610185578063156d2c2d1461019a578063168e4d83146101ad57806317753f88146101d4575b5f80fd5b61017061015a36600461218b565b6001600160e01b0319166307f5828d60e41b1490565b60405190151581526020015b60405180910390f35b610198610193366004612293565b6103d0565b005b6101986101a83660046122e4565b6103f5565b6101c06101bb3660046122ff565b6104c2565b60405161017c989796959493929190612359565b6101dc610823565b60405161017c91906123e1565b6101fc6101f73660046123f3565b6108b3565b60405161017c99989796959493929190612413565b6101dc610c39565b6101986102273660046124d9565b610cc5565b61019861023a366004612525565b610fa6565b61019861024d3660046122ff565b611126565b610198611381565b5f546001600160a01b03165b6040516001600160a01b03909116815260200161017c565b600154610266906001600160a01b031681565b6102a461029f3660046122ff565b6113bc565b60405161017c9796959493929190612553565b6101986102c53660046122e4565b611616565b6102fd6102d83660046122ff565b60066020525f9081526040902080546001909101546001600160a01b03918216911682565b604080516001600160a01b0393841681529290911660208301520161017c565b61019861032b3660046125d7565b611698565b600254610266906001600160a01b031681565b6103566103513660046123f3565b6119b0565b60405161017c92919061268c565b6102fd6103723660046122e4565b60076020525f9081526040902080546001909101546001600160a01b03918216911682565b6101986103a53660046126ad565b611a5c565b6101dc6103b83660046123f3565b611e0a565b6101986103cb3660046122e4565b611f07565b5f546001600160a01b031633146103e5575f80fd5b60086103f1828261283a565b5050565b6001600160a01b038181165f908152600760205260409020600101541633146104655760405162461bcd60e51b815260206004820152601860248201527f4e6f7420617574686f72697a656420746f207265766f6b65000000000000000060448201526064015b60405180910390fd5b6001600160a01b0381165f8181526007602052604080822080546001600160a01b031990811682556001909101805490911690555133917f9707cdba5b9bc019fd0657ac3b54ba7c7a8bf5be354b01b2b74083c185dd44dc91a350565b5f818152600460209081526040808320815160e081018352815460ff90811615158252600183015494820194909452600282015490931615159183019190915260038101805484938493606093849384938493849389938386019190610527906127b6565b80601f0160208091040260200160405190810160405280929190818152602001828054610553906127b6565b801561059e5780601f106105755761010080835404028352916020019161059e565b820191905f5260205f20905b81548152906001019060200180831161058157829003601f168201915b505050505081526020016004820180546105b7906127b6565b80601f01602080910402602001604051908101604052809291908181526020018280546105e3906127b6565b801561062e5780601f106106055761010080835404028352916020019161062e565b820191905f5260205f20905b81548152906001019060200180831161061157829003601f168201915b50505050508152602001600582018054610647906127b6565b80601f0160208091040260200160405190810160405280929190818152602001828054610673906127b6565b80156106be5780601f10610695576101008083540402835291602001916106be565b820191905f5260205f20905b8154815290600101906020018083116106a157829003601f168201915b505050505081526020016006820180546106d7906127b6565b80601f0160208091040260200160405190810160405280929190818152602001828054610703906127b6565b801561074e5780601f106107255761010080835404028352916020019161074e565b820191905f5260205f20905b81548152906001019060200180831161073157829003601f168201915b5050505050815250509050805f015181602001518260400151836060015184608001518560a001518660c001516008808054610789906127b6565b80601f01602080910402602001604051908101604052809291908181526020018280546107b5906127b6565b80156108005780601f106107d757610100808354040283529160200191610800565b820191905f5260205f20905b8154815290600101906020018083116107e357829003601f168201915b505050505090509850985098509850985098509850985050919395975091939597565b606060088054610832906127b6565b80601f016020809104026020016040519081016040528092919081815260200182805461085e906127b6565b80156108a95780601f10610880576101008083540402835291602001916108a9565b820191905f5260205f20905b81548152906001019060200180831161088c57829003601f168201915b5050505050905090565b5f828152600460209081526040808320815160e081018352815460ff90811615158252600183015494820194909452600282015490931615159183019190915260038101805484938493606093849384938493849384938a9392918386019161091b906127b6565b80601f0160208091040260200160405190810160405280929190818152602001828054610947906127b6565b80156109925780601f1061096957610100808354040283529160200191610992565b820191905f5260205f20905b81548152906001019060200180831161097557829003601f168201915b505050505081526020016004820180546109ab906127b6565b80601f01602080910402602001604051908101604052809291908181526020018280546109d7906127b6565b8015610a225780601f106109f957610100808354040283529160200191610a22565b820191905f5260205f20905b815481529060010190602001808311610a0557829003601f168201915b50505050508152602001600582018054610a3b906127b6565b80601f0160208091040260200160405190810160405280929190818152602001828054610a67906127b6565b8015610ab25780601f10610a8957610100808354040283529160200191610ab2565b820191905f5260205f20905b815481529060010190602001808311610a9557829003601f168201915b50505050508152602001600682018054610acb906127b6565b80601f0160208091040260200160405190810160405280929190818152602001828054610af7906127b6565b8015610b425780601f10610b1957610100808354040283529160200191610b42565b820191905f5260205f20905b815481529060010190602001808311610b2557829003601f168201915b50505050508152505090505f60035f8e81526020019081526020015f20549050815f01519a50816020015199508160400151985081606001519750816080015196508160a0015195508160c00151945060088054610b9f906127b6565b80601f0160208091040260200160405190810160405280929190818152602001828054610bcb906127b6565b8015610c165780601f10610bed57610100808354040283529160200191610c16565b820191905f5260205f20905b815481529060010190602001808311610bf957829003601f168201915b50505050509350610c288d8d83611f52565b925050509295985092959850929598565b60088054610c46906127b6565b80601f0160208091040260200160405190810160405280929190818152602001828054610c72906127b6565b8015610cbd5780601f10610c9457610100808354040283529160200191610cbd565b820191905f5260205f20905b815481529060010190602001808311610ca057829003601f168201915b505050505081565b6001546040516331a9108f60e11b81526004810185905284916001600160a01b0316905f908290636352211e90602401602060405180830381865afa158015610d10573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d3491906128fa565b90506001600160a01b038116331480610d6a57506002546001600160a01b038281169116148015610d6a5750610d6a83336120cc565b15610dc4576040805180820182528581525f8881526003602090815283822054818401528982526005815283822089835290529190912081518190610daf908261283a565b50602082015181600101559050505050610fa0565b335f81815260076020908152604091829020825180840190935280546001600160a01b03908116808552600190920154169183019190915290919003610eab575f826001600160a01b031682602001516001600160a01b03161480610e4a57506002546001600160a01b038481169116148015610e4a5750610e4a8583602001516120cc565b90508015610ea9576040805180820182528781525f8a81526003602090815283822054818401528b8252600581528382208b835290529190912081518190610e92908261283a565b506020820151816001015590505050505050610fa0565b505b5f848152600660209081526040808320815180830190925280546001600160a01b03908116835260019091015416918101829052919033148015610f2d5750836001600160a01b0316825f01516001600160a01b03161480610f2d57506002546001600160a01b038581169116148015610f2d5750610f2d86835f01516120cc565b905080610f4c5760405162461bcd60e51b815260040161045c90612915565b6040805180820182528881525f8b81526003602090815283822054818401528c8252600581528382208c835290529190912081518190610f8c908261283a565b506020820151816001015590505050505050505b50505050565b6001546040516331a9108f60e11b81526004810184905283916001600160a01b0316905f908290636352211e90602401602060405180830381865afa158015610ff1573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061101591906128fa565b6002549091505f906001600160a01b03808416911614801561103c575061103c84336120cc565b90506001600160a01b0382163314806110525750805b61109e5760405162461bcd60e51b815260206004820152601d60248201527f43616c6c6572206973206e6f74206f776e6572206f72207374616b6572000000604482015260640161045c565b604080518082018252338082526001600160a01b0388811660208085018281525f8d81526006909252868220955186549085166001600160a01b03199182161787559051600190960180549690941695169490941790915592518993927fdfe4038b7a47a54e9cb9a74936e28ebea8370918b17bb83cab7225cfc1e1e5c591a4505050505050565b6001546040516331a9108f60e11b81526004810183905282916001600160a01b0316905f908290636352211e90602401602060405180830381865afa158015611171573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061119591906128fa565b90506001600160a01b0381163314806111cb57506002546001600160a01b0382811691161480156111cb57506111cb83336120cc565b156111f9575f8481526003602052604081208054600192906111ee908490612951565b909155505050505050565b335f81815260076020908152604091829020825180840190935280546001600160a01b039081168085526001909201541691830191909152909190036112b4575f826001600160a01b031682602001516001600160a01b0316148061127f57506002546001600160a01b03848116911614801561127f575061127f8583602001516120cc565b905080156112b2575f8681526003602052604081208054600192906112a5908490612951565b9091555050505050505050565b505b5f848152600660209081526040808320815180830190925280546001600160a01b039081168352600190910154169181018290529190331480156113365750836001600160a01b0316825f01516001600160a01b0316148061133657506002546001600160a01b038581169116148015611336575061133686835f01516120cc565b9050806113555760405162461bcd60e51b815260040161045c90612915565b5f878152600360205260408120805460019290611373908490612951565b909155505050505050505050565b5f546001600160a01b031633146113ab576040516330cd747160e01b815260040160405180910390fd5b5f80546001600160a01b0319169055565b60046020525f9081526040902080546001820154600283015460038401805460ff94851695939490921692916113f1906127b6565b80601f016020809104026020016040519081016040528092919081815260200182805461141d906127b6565b80156114685780601f1061143f57610100808354040283529160200191611468565b820191905f5260205f20905b81548152906001019060200180831161144b57829003601f168201915b50505050509080600401805461147d906127b6565b80601f01602080910402602001604051908101604052809291908181526020018280546114a9906127b6565b80156114f45780601f106114cb576101008083540402835291602001916114f4565b820191905f5260205f20905b8154815290600101906020018083116114d757829003601f168201915b505050505090806005018054611509906127b6565b80601f0160208091040260200160405190810160405280929190818152602001828054611535906127b6565b80156115805780601f1061155757610100808354040283529160200191611580565b820191905f5260205f20905b81548152906001019060200180831161156357829003601f168201915b505050505090806006018054611595906127b6565b80601f01602080910402602001604051908101604052809291908181526020018280546115c1906127b6565b801561160c5780601f106115e35761010080835404028352916020019161160c565b820191905f5260205f20905b8154815290600101906020018083116115ef57829003601f168201915b5050505050905087565b6040805180820182526001600160a01b038084168083523360208085018281525f8481526007909252868220955186549086166001600160a01b031991821617875590516001909601805496909516951694909417909255925190917f209d7c70c1ab2adc07afcfbbaab11b6392ea49508eaef7028b6faf9a20d2234591a350565b6001546040516331a9108f60e11b81526004810189905288916001600160a01b0316905f908290636352211e90602401602060405180830381865afa1580156116e3573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061170791906128fa565b90506001600160a01b03811633148061173d57506002546001600160a01b03828116911614801561173d575061173d83336120cc565b156117a8575f8a8152600460205260409020805460ff199081168b1515178255600182018a905560028201805490911689151517905560038101611781888261283a565b5060048101611790878261283a565b506005810161179f868261283a565b505050506119a6565b335f81815260076020908152604091829020825180840190935280546001600160a01b039081168085526001909201541691830191909152909190036118a0575f826001600160a01b031682602001516001600160a01b0316148061182e57506002546001600160a01b03848116911614801561182e575061182e8583602001516120cc565b9050801561189e575f8c8152600460205260409020805460ff199081168d1515178255600182018c90556002820180549091168b1515179055600381016118758a8261283a565b5060048101611884898261283a565b5060058101611893888261283a565b5050505050506119a6565b505b5f848152600660209081526040808320815180830190925280546001600160a01b039081168352600190910154169181018290529190331480156119225750836001600160a01b0316825f01516001600160a01b0316148061192257506002546001600160a01b038581169116148015611922575061192286835f01516120cc565b9050806119415760405162461bcd60e51b815260040161045c90612915565b5f8d8152600460205260409020805460ff199081168e1515178255600182018d90556002820180549091168c1515179055600381016119808b8261283a565b506004810161198f8a8261283a565b506005810161199e898261283a565b505050505050505b5050505050505050565b600560209081525f92835260408084209091529082529020805481906119d5906127b6565b80601f0160208091040260200160405190810160405280929190818152602001828054611a01906127b6565b8015611a4c5780601f10611a2357610100808354040283529160200191611a4c565b820191905f5260205f20905b815481529060010190602001808311611a2f57829003601f168201915b5050505050908060010154905082565b6001546040516331a9108f60e11b81526004810184905283916001600160a01b0316905f908290636352211e90602401602060405180830381865afa158015611aa7573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611acb91906128fa565b90506001600160a01b038116331480611b0157506002546001600160a01b038281169116148015611b015750611b0183336120cc565b15611ba0575f858152600460209081526040918290208651815490151560ff19918216178255918701516001820155918601516002830180549115159190921617905560608501516003820190611b58908261283a565b5060808501516004820190611b6d908261283a565b5060a08501516005820190611b82908261283a565b5060c08501516006820190611b97908261283a565b50505050505050565b335f81815260076020908152604091829020825180840190935280546001600160a01b03908116808552600190920154169183019190915290919003611ccc575f826001600160a01b031682602001516001600160a01b03161480611c2657506002546001600160a01b038481169116148015611c265750611c268583602001516120cc565b90508015611cca575f878152600460209081526040918290208851815490151560ff19918216178255918901516001820155918801516002830180549115159190921617905560608701516003820190611c80908261283a565b5060808701516004820190611c95908261283a565b5060a08701516005820190611caa908261283a565b5060c08701516006820190611cbf908261283a565b505050505050505050565b505b5f848152600660209081526040808320815180830190925280546001600160a01b03908116835260019091015416918101829052919033148015611d4e5750836001600160a01b0316825f01516001600160a01b03161480611d4e57506002546001600160a01b038581169116148015611d4e5750611d4e86835f01516120cc565b905080611d6d5760405162461bcd60e51b815260040161045c90612915565b5f888152600460209081526040918290208951815490151560ff19918216178255918a01516001820155918901516002830180549115159190921617905560608801516003820190611dbf908261283a565b5060808801516004820190611dd4908261283a565b5060a08801516005820190611de9908261283a565b5060c08801516006820190611dfe908261283a565b50505050505050505050565b5f8281526005602090815260408083208484529091528082208151808301909252805460609392919082908290611e40906127b6565b80601f0160208091040260200160405190810160405280929190818152602001828054611e6c906127b6565b8015611eb75780601f10611e8e57610100808354040283529160200191611eb7565b820191905f5260205f20905b815481529060010190602001808311611e9a57829003601f168201915b50505050508152602001600182015481525050905060035f8581526020019081526020015f2054816020015103611ef057519050611f01565b505060408051602081019091525f81525b92915050565b5f546001600160a01b03163314611f31576040516330cd747160e01b815260040160405180910390fd5b5f80546001600160a01b0319166001600160a01b0392909216919091179055565b60605f8367ffffffffffffffff811115611f6e57611f6e6121b9565b604051908082528060200260200182016040528015611f97578160200160208202803683370190505b5090505f805b858111612033575f87815260056020908152604080832084845290915290206001015485148015611ff057505f87815260056020908152604080832084845290915281208054611fec906127b6565b9050115b15612021578083838151811061200857612008612964565b60209081029190910101528161201d81612978565b9250505b8061202b81612978565b915050611f9d565b508067ffffffffffffffff81111561204d5761204d6121b9565b604051908082528060200260200182016040528015612076578160200160208202803683370190505b5092505f5b818110156120c25782818151811061209557612095612964565b60200260200101518482815181106120af576120af612964565b602090810291909101015260010161207b565b5050509392505050565b6002546040516363c28db160e01b81526001600160a01b0383811660048301525f921690829082906363c28db1906024015f60405180830381865afa158015612117573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f1916820160405261213e9190810190612a0d565b5090505f5b8151811015612180578582828151811061215f5761215f612964565b6020026020010151036121785760019350505050611f01565b600101612143565b505f95945050505050565b5f6020828403121561219b575f80fd5b81356001600160e01b0319811681146121b2575f80fd5b9392505050565b634e487b7160e01b5f52604160045260245ffd5b60405160e0810167ffffffffffffffff811182821017156121f0576121f06121b9565b60405290565b604051601f8201601f1916810167ffffffffffffffff8111828210171561221f5761221f6121b9565b604052919050565b5f82601f830112612236575f80fd5b813567ffffffffffffffff811115612250576122506121b9565b612263601f8201601f19166020016121f6565b818152846020838601011115612277575f80fd5b816020850160208301375f918101602001919091529392505050565b5f602082840312156122a3575f80fd5b813567ffffffffffffffff8111156122b9575f80fd5b6122c584828501612227565b949350505050565b6001600160a01b03811681146122e1575f80fd5b50565b5f602082840312156122f4575f80fd5b81356121b2816122cd565b5f6020828403121561230f575f80fd5b5035919050565b5f81518084525f5b8181101561233a5760208185018101518683018201520161231e565b505f602082860101526020601f19601f83011685010191505092915050565b5f6101008a15158352896020840152881515604084015280606084015261238281840189612316565b905082810360808401526123968188612316565b905082810360a08401526123aa8187612316565b905082810360c08401526123be8186612316565b905082810360e08401526123d28185612316565b9b9a5050505050505050505050565b602081525f6121b26020830184612316565b5f8060408385031215612404575f80fd5b50508035926020909101359150565b5f6101208b1515835260208b60208501528a1515604085015281606085015261243e8285018b612316565b91508382036080850152612452828a612316565b915083820360a08501526124668289612316565b915083820360c085015261247a8288612316565b915083820360e085015261248e8287612316565b848103610100860152855180825260208088019450909101905f5b818110156124c5578451835293830193918301916001016124a9565b50909e9d5050505050505050505050505050565b5f805f606084860312156124eb575f80fd5b8335925060208401359150604084013567ffffffffffffffff81111561250f575f80fd5b61251b86828701612227565b9150509250925092565b5f8060408385031215612536575f80fd5b823591506020830135612548816122cd565b809150509250929050565b8715158152866020820152851515604082015260e060608201525f61257b60e0830187612316565b828103608084015261258d8187612316565b905082810360a08401526125a18186612316565b905082810360c08401526125b58185612316565b9a9950505050505050505050565b803580151581146125d2575f80fd5b919050565b5f805f805f805f60e0888a0312156125ed575f80fd5b873596506125fd602089016125c3565b955060408801359450612612606089016125c3565b9350608088013567ffffffffffffffff8082111561262e575f80fd5b61263a8b838c01612227565b945060a08a013591508082111561264f575f80fd5b61265b8b838c01612227565b935060c08a0135915080821115612670575f80fd5b5061267d8a828b01612227565b91505092959891949750929550565b604081525f61269e6040830185612316565b90508260208301529392505050565b5f80604083850312156126be575f80fd5b82359150602083013567ffffffffffffffff808211156126dc575f80fd5b9084019060e082870312156126ef575f80fd5b6126f76121cd565b612700836125c3565b815260208301356020820152612718604084016125c3565b604082015260608301358281111561272e575f80fd5b61273a88828601612227565b606083015250608083013582811115612751575f80fd5b61275d88828601612227565b60808301525060a083013582811115612774575f80fd5b61278088828601612227565b60a08301525060c083013582811115612797575f80fd5b6127a388828601612227565b60c0830152508093505050509250929050565b600181811c908216806127ca57607f821691505b6020821081036127e857634e487b7160e01b5f52602260045260245ffd5b50919050565b601f82111561283557805f5260205f20601f840160051c810160208510156128135750805b601f840160051c820191505b81811015612832575f815560010161281f565b50505b505050565b815167ffffffffffffffff811115612854576128546121b9565b6128688161286284546127b6565b846127ee565b602080601f83116001811461289b575f84156128845750858301515b5f19600386901b1c1916600185901b1785556128f2565b5f85815260208120601f198616915b828110156128c9578886015182559484019460019091019084016128aa565b50858210156128e657878501515f19600388901b60f8161c191681555b505060018460011b0185555b505050505050565b5f6020828403121561290a575f80fd5b81516121b2816122cd565b6020808252600e908201526d139bdd08185d5d1a1bdc9a5e995960921b604082015260600190565b634e487b7160e01b5f52601160045260245ffd5b80820180821115611f0157611f0161293d565b634e487b7160e01b5f52603260045260245ffd5b5f600182016129895761298961293d565b5060010190565b5f82601f83011261299f575f80fd5b8151602067ffffffffffffffff8211156129bb576129bb6121b9565b8160051b6129ca8282016121f6565b92835284810182019282810190878511156129e3575f80fd5b83870192505b84831015612a02578251825291830191908301906129e9565b979650505050505050565b5f8060408385031215612a1e575f80fd5b825167ffffffffffffffff80821115612a35575f80fd5b612a4186838701612990565b93506020850151915080821115612a56575f80fd5b50612a6385828601612990565b915050925092905056fea264697066735822122057637e3468e97560534a45d2093cee9c31dfc3d02fd63ff197e814b7e50e037c64736f6c63430008180033

Verified Source Code Partial Match

Compiler: v0.8.24+commit.e11b9ed9 EVM: shanghai Optimization: Yes (200 runs)
Ownable.sol 48 lines
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.10;

error NotOwner();

// https://github.com/m1guelpf/erc721-drop/blob/main/src/LilOwnable.sol
abstract contract Ownable {
    address internal _owner;

    event OwnershipTransferred(
        address indexed previousOwner,
        address indexed newOwner
    );

    modifier onlyOwner() {
        require(_owner == msg.sender);
        _;
    }

    constructor() {
        _owner = msg.sender;
    }

    function owner() external view returns (address) {
        return _owner;
    }

    function transferOwnership(address _newOwner) external {
        if (msg.sender != _owner) revert NotOwner();

        _owner = _newOwner;
    }

    function renounceOwnership() public {
        if (msg.sender != _owner) revert NotOwner();

        _owner = address(0);
    }

    function supportsInterface(bytes4 interfaceId)
        public
        pure
        virtual
        returns (bool)
    {
        return interfaceId == 0x7f5828d0; // ERC165 Interface ID for ERC173
    }
}
DungeonConfig.sol 339 lines
// SPDX-License-Identifier: MIT
//
// DungeonConfig by DungeonMaster/@DungeonSpawner

pragma solidity ^0.8.0;

import "./Ownable.sol";

interface IDungeon {
    function ownerOf(uint256 tokenId) external view returns (address owner);
}

interface IDungeonRewards {
    function getStakedTokens(
        address owner
    )
        external
        view
        returns (uint256[] memory dungeons, uint256[] memory avatars);
}

contract DungeonConfig is Ownable {
    /*///////////////////////////////////////////////////////////////
                                 EVENTS
    //////////////////////////////////////////////////////////////*/
    event AssignPerms(
        address indexed from,
        address indexed to,
        uint256 indexed tokenId
    );
    event AssignGlobalPerms(address indexed from, address indexed to);
    event RevokeGlobalPerms(address indexed from, address indexed to);

    /*///////////////////////////////////////////////////////////////
                          METADATA STORAGE/LOGIC
    //////////////////////////////////////////////////////////////*/
    address public dungeonAddress;
    address public dungeonRewardsAddress;

    struct Permission {
        address grantedBy; // The address that granted the permission
        address grantedTo; // The address that received the permission
    }
    struct GlobalPermission {
        address grantedTo;
        address grantedBy;
    }

    struct FloorData {
        string txId; // transaction ID for the floor data
        uint256 version; // current version of the floor data (every resetAllFloors increments the version #, outdating previous entries)
    }

    struct DungeonData {
        bool locked;
        uint256 trialTimeout;
        bool randomizeLayout; // randomize layout indicates each floor after floor 1 has a random layout/environment
        string passwordHash; // DungeonMaster notes: not really secure, of course, since it's publically available, but the best we have
        string ownersMessage;
        string gameMode; // space theme, 3d, leaderboard, etc... and if starts with https:, NFT will redirect to url after loading up (use for streaming via rumble, etc)
        string tilesetOverride; // override tileset with this txid/url allowing owners further customization
    }

    // Mapping that tells us which version of the dungeon data we're dealing with 
    // (reseting all floors increments the version # -- saves us gas from having to clear all the existing dungeon floor data)
    mapping(uint256 => uint256) private tokenVersions;

    mapping(uint256 => DungeonData) public dungeons;
    // Mapping from tokenId to a mapping of floorNumber to FloorData
    mapping(uint256 => mapping(uint256 => FloorData)) public dungeonFloors;

    mapping(uint256 => Permission) public tokenPermissions;
    // Mapping to store global permissions
    mapping(address => GlobalPermission) public globalPermissions;

    string public BASE_CODE_TXID = ""; // base code txid

    constructor(address _dungeonAddress, address _dungeonRewardsAddress) {
        dungeonAddress = _dungeonAddress;
        dungeonRewardsAddress = _dungeonRewardsAddress;
    }

    modifier onlyOwnerOrStaker(uint256 tokenId) {
        IDungeon dungeon = IDungeon(dungeonAddress);
        address owner = dungeon.ownerOf(tokenId);
        bool isStaker = owner == dungeonRewardsAddress &&
            isTokenStakedByAddress(tokenId, msg.sender);

        require(
            owner == msg.sender || isStaker,
            "Caller is not owner or staker"
        );
        _;
    }

    function isTokenStakedByAddress(
        uint256 tokenId,
        address addressToCheck
    ) private view returns (bool) {
        IDungeonRewards rewards = IDungeonRewards(dungeonRewardsAddress);
        (uint256[] memory stakedDungeons, ) = rewards.getStakedTokens(
            addressToCheck
        );
        for (uint i = 0; i < stakedDungeons.length; i++) {
            if (stakedDungeons[i] == tokenId) {
                return true;
            }
        }
        return false;
    }

    modifier isPermitted(uint256 tokenId) {
        IDungeon dungeon = IDungeon(dungeonAddress);
        address owner = dungeon.ownerOf(tokenId);

        // First, check if msg.sender is the owner. If true, no further checks needed.
        if (
            owner == msg.sender ||
            (owner == dungeonRewardsAddress &&
                isTokenStakedByAddress(tokenId, msg.sender))
        ) {
            _;
            return;
        }

        // Global Permissions Check
        GlobalPermission memory globalPerm = globalPermissions[msg.sender];
        if (globalPerm.grantedTo == msg.sender) {
            bool isGlobalGrantorOwnerOrStaker = globalPerm.grantedBy == owner ||
                (owner == dungeonRewardsAddress &&
                    isTokenStakedByAddress(tokenId, globalPerm.grantedBy));

            if (isGlobalGrantorOwnerOrStaker) {
                _;
                return;
            }
        }

        // Only proceed to check permissions if the sender is not the owner or a staker.
        Permission memory permission = tokenPermissions[tokenId];
        bool hasValidPermission = permission.grantedTo == msg.sender &&
            (permission.grantedBy == owner ||
                (owner == dungeonRewardsAddress &&
                    isTokenStakedByAddress(tokenId, permission.grantedBy)));

        require(hasValidPermission, "Not authorized");

        _;
    }

    function writeDungeonConfig(
        uint256 tokenId,
        DungeonData memory configData
    ) public isPermitted(tokenId) {
        DungeonData storage dungeon = dungeons[tokenId];
        dungeon.locked = configData.locked;
        dungeon.trialTimeout = configData.trialTimeout;
        dungeon.randomizeLayout = configData.randomizeLayout;
        dungeon.passwordHash = configData.passwordHash;
        dungeon.ownersMessage = configData.ownersMessage;
        dungeon.gameMode = configData.gameMode;
        dungeon.tilesetOverride = configData.tilesetOverride;
    }

    // same as above, but without tilesetOverride - costs about half the gas
    function writeDungeonConfig(
        uint256 tokenId,
        bool locked,
        uint256 trialTimeout,
        bool randomizeLayout,
        string memory passwordHash,
        string memory ownersMessage,
        string memory gameMode
    ) public isPermitted(tokenId) {
        DungeonData storage dungeon = dungeons[tokenId];
        dungeon.locked = locked;
        dungeon.trialTimeout = trialTimeout;
        dungeon.randomizeLayout = randomizeLayout;
        dungeon.passwordHash = passwordHash;
        dungeon.ownersMessage = ownersMessage;
        dungeon.gameMode = gameMode;
    }

    function readDungeonConfig(
        uint256 tokenId
    )
        public
        view
        returns (
            bool locked,
            uint256 trialTimeout,
            bool randomizeLayout,
            string memory passwordHash,
            string memory ownersMessage,
            string memory gameMode,
            string memory tilesetOverride,
            string memory codeTxId
        )
    {
        DungeonData memory dungeon = dungeons[tokenId];

        // could directly assing the fields from the dungeon struct to construct the return values as per the
        // 2nd version of this function, but it's just as gas efficient to wrap it in a return like this
        return (
            dungeon.locked,
            dungeon.trialTimeout,
            dungeon.randomizeLayout,
            dungeon.passwordHash,
            dungeon.ownersMessage,
            dungeon.gameMode,
            dungeon.tilesetOverride,
            BASE_CODE_TXID
        );
    }

    // read Dungeon Config with custom floors
    function readDungeonConfig(
        uint256 tokenId, uint256 maxFloorNumber
    )
        public
        view
        returns (
            bool locked,
            uint256 trialTimeout,
            bool randomizeLayout,
            string memory passwordHash,
            string memory ownersMessage,
            string memory gameMode,
            string memory tilesetOverride,
            string memory codeTxId,
            uint256[] memory customFloors
        )
    {
        DungeonData memory dungeon = dungeons[tokenId];
        uint256 currentVersion = tokenVersions[tokenId];

        // Directly use the fields from the dungeon struct to construct the return values
        locked = dungeon.locked;
        trialTimeout = dungeon.trialTimeout;
        randomizeLayout = dungeon.randomizeLayout;
        passwordHash = dungeon.passwordHash;
        ownersMessage = dungeon.ownersMessage;
        gameMode = dungeon.gameMode;
        tilesetOverride = dungeon.tilesetOverride;
        codeTxId = BASE_CODE_TXID;

        // Use the helper function to get customFloors - do it this way to avoid CompilerError: Stack too deep
        customFloors = getCustomFloors(tokenId, maxFloorNumber, currentVersion);
    }

    // collect customFloors data
    function getCustomFloors(uint256 tokenId, uint256 maxFloorNumber, uint256 currentVersion)
        internal
        view
        returns (uint256[] memory customFloors)
    {
        uint256[] memory tempFloors = new uint256[](maxFloorNumber);
        uint256 count = 0;

        for (uint256 floor = 0; floor <= maxFloorNumber; floor++) {
            if (dungeonFloors[tokenId][floor].version == currentVersion &&
                bytes(dungeonFloors[tokenId][floor].txId).length > 0) {
                tempFloors[count] = floor;
                count++;
            }
        }

        customFloors = new uint256[](count);
        for (uint256 i = 0; i < count; i++) {
            customFloors[i] = tempFloors[i];
        }
    }

    function writeFloorData(
        uint256 tokenId,
        uint256 floorNumber,
        string memory txId
    ) public isPermitted(tokenId) {
        // Store the transaction ID for the specific floor
        dungeonFloors[tokenId][floorNumber] = FloorData(txId, tokenVersions[tokenId]);
    }

    function readFloorData(
        uint256 tokenId,
        uint256 floorNumber
    ) public view returns (string memory) {
         FloorData memory floorData = dungeonFloors[tokenId][floorNumber];
        // Return the transaction ID for the specific floor
        if(floorData.version == tokenVersions[tokenId]) {
            return floorData.txId;
        } else {
            return ""; // Indicates no data for the current version
        }        
    }

    function resetAllFloors(uint256 tokenId) public isPermitted(tokenId) { 
        tokenVersions[tokenId] += 1; // Increment the version to "reset" the data
    }

    function assignPermission(
        uint256 tokenId,
        address to
    ) public onlyOwnerOrStaker(tokenId) {
        tokenPermissions[tokenId] = Permission(msg.sender, to);

        emit AssignPerms(msg.sender, to, tokenId);
    }

    // Assign global permission
    function assignGlobalPermission(address to) public {
        globalPermissions[to] = GlobalPermission({
            grantedTo: to,
            grantedBy: msg.sender
        });

        emit AssignGlobalPerms(msg.sender, to);
    }

    // Optional: Function to revoke global permission
    function revokeGlobalPermission(address to) public {
        require(
            globalPermissions[to].grantedBy == msg.sender,
            "Not authorized to revoke"
        );
        delete globalPermissions[to];
        emit RevokeGlobalPerms(msg.sender, to);
    }

    // set the ethscription txid of the base codebase
    function setBaseCodeTxid(string memory baseCodeTxid) public onlyOwner {
        BASE_CODE_TXID = baseCodeTxid;
    }

    // read the ethscription txid of the base codebase
    function getBaseCodeTxid() public view returns (string memory) {
        return BASE_CODE_TXID;
    }

}

Read Contract

BASE_CODE_TXID 0x3d086286 → string
dungeonAddress 0x9345feac → address
dungeonFloors 0xc4d4073b → string, uint256
dungeonRewardsAddress 0xbdb6955a → address
dungeons 0x956e958a → bool, uint256, bool, string, string, string, string
getBaseCodeTxid 0x17753f88 → string
globalPermissions 0xc6dba624 → address, address
owner 0x8da5cb5b → address
readDungeonConfig 0x168e4d83 → bool, uint256, bool, string, string, string, string, string
readDungeonConfig 0x24f7374c → bool, uint256, bool, string, string, string, string, string, uint256[]
readFloorData 0xe9aab685 → string
supportsInterface 0x01ffc9a7 → bool
tokenPermissions 0xb31985c2 → address, address

Write Contract 10 functions

These functions modify contract state and require a wallet transaction to execute.

assignGlobalPermission 0x966beda9
address to
assignPermission 0x5d5fd04d
uint256 tokenId
address to
renounceOwnership 0x715018a6
No parameters
resetAllFloors 0x63df7014
uint256 tokenId
revokeGlobalPermission 0x156d2c2d
address to
setBaseCodeTxid 0x13154b7e
string baseCodeTxid
transferOwnership 0xf2fde38b
address _newOwner
writeDungeonConfig 0xbb7c93fa
uint256 tokenId
bool locked
uint256 trialTimeout
bool randomizeLayout
string passwordHash
string ownersMessage
string gameMode
writeDungeonConfig 0x497aecdb
uint256 tokenId
tuple configData
writeFloorData 0x4be0110c
uint256 tokenId
uint256 floorNumber
string txId

Recent Transactions

No transactions found for this address