Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0xD8d21E5f6ee5C70c5Cdf993e86c3ED6e3D6aC0DE
Balance 0 ETH
Nonce 1
Code Size 9497 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

9497 bytes
0x6080604052600436106101a85760003560e01c80636c0360eb116100e85780636c0360eb1461048657806370a082311461049b5780637152e7fe146104bb57806385a50636146104db5780639149bdf2146104fb57806395d89b411461052b578063a133956914610540578063a22cb46514610553578063b88d4fde14610573578063c023484d14610593578063c49354fe146105b3578063c87b56dd146105d3578063dc2341c4146105f3578063dcb58f1714610613578063e086e5ec14610633578063e985e9c514610648578063f6ef2e6214610683578063f9195cb2146106a3576101f5565b806301ffc9a71461021957806306fdde031461024e578063081812fc14610270578063095ea7b3146102be57806318160ddd146102e05780631e9e6686146102ff5780632102e2881461031f578063227764781461033f57806323b872dd1461036c57806338da41e21461038c57806341200eba146103ac57806342842e0e146103c65780635bcea4d5146103e657806360f0df6b146103f95780636330bb4b146104265780636352211e14610446578063646abf1f14610466576101f5565b366101f557604051644b75646f7360d81b81526005015b60405190819003812090349033907f59e04c3f0d44b7caf6e8ef854b61d9a51cf1960d7a88ff6356cc5e946b4b583290600090a4005b6040517211985b1b189858dac81dd85cc818d85b1b1959606a1b81526013016101bf565b34801561022557600080fd5b50610239610234366004611cf0565b6106c1565b60405190151581526020015b60405180910390f35b34801561025a57600080fd5b50610263610713565b6040516102459190611d38565b34801561027c57600080fd5b506102a661028b366004611d6b565b6004602052600090815260409020546001600160a01b031681565b6040516001600160a01b039091168152602001610245565b3480156102ca57600080fd5b506102de6102d9366004611d9b565b6107a1565b005b3480156102ec57600080fd5b50610fb85b604051908152602001610245565b34801561030b57600080fd5b506102f161031a366004611d6b565b61086b565b34801561032b57600080fd5b506102de61033a366004611dc5565b6108a4565b34801561034b57600080fd5b5061035f61035a366004611d6b565b6108f1565b6040516102459190611e18565b34801561037857600080fd5b506102de610387366004611e26565b610937565b34801561039857600080fd5b506102f16103a7366004611d6b565b610950565b3480156103b857600080fd5b506611c37937e080006102f1565b3480156103d257600080fd5b506102de6103e1366004611e26565b6109de565b6102de6103f4366004611d6b565b610aae565b34801561040557600080fd5b50610419610414366004611e62565b610b31565b6040516102459190611e84565b34801561043257600080fd5b50610419610441366004611f00565b610caa565b34801561045257600080fd5b506102a6610461366004611d6b565b610e70565b34801561047257600080fd5b50610419610481366004611e62565b610eaa565b34801561049257600080fd5b50610263611009565b3480156104a757600080fd5b506102f16104b6366004611dc5565b611016565b3480156104c757600080fd5b506104196104d6366004611e62565b611079565b3480156104e757600080fd5b506102636104f6366004611d6b565b6111fc565b34801561050757600080fd5b5061051b610516366004611d6b565b6112ca565b6040516102459493929190611f33565b34801561053757600080fd5b50610263611307565b6102de61054e366004611f5d565b611314565b34801561055f57600080fd5b506102de61056e366004611f89565b61139b565b34801561057f57600080fd5b506102de61058e36600461200d565b611407565b34801561059f57600080fd5b506102de6105ae366004611e62565b6114cc565b3480156105bf57600080fd5b506102f16105ce366004611f5d565b6115a8565b3480156105df57600080fd5b506102636105ee366004611d6b565b6115f1565b3480156105ff57600080fd5b506102de61060e36600461207b565b611625565b34801561061f57600080fd5b506102de61062e366004612097565b611664565b34801561063f57600080fd5b506102de6116b0565b34801561065457600080fd5b506102396106633660046120f0565b600560209081526000928352604080842090915290825290205460ff1681565b34801561068f57600080fd5b506102de61069e36600461211a565b611728565b3480156106af57600080fd5b50600c546001600160a01b03166102a6565b60006301ffc9a760e01b6001600160e01b0319831614806106f257506380ac58cd60e01b6001600160e01b03198316145b8061070d5750635b5e139f60e01b6001600160e01b03198316145b92915050565b6000805461072090612165565b80601f016020809104026020016040519081016040528092919081815260200182805461074c90612165565b80156107995780601f1061076e57610100808354040283529160200191610799565b820191906000526020600020905b81548152906001019060200180831161077c57829003601f168201915b505050505081565b6000818152600260205260409020546001600160a01b0316338114806107ea57506001600160a01b038116600090815260056020908152604080832033845290915290205460ff165b61080f5760405162461bcd60e51b81526004016108069061219f565b60405180910390fd5b60008281526004602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b6000610fb882118061087d5750600182105b1561089b5760405163568edd5b60e11b815260040160405180910390fd5b61070d82611764565b600c546001600160a01b031633146108cf5760405163042b377160e41b815260040160405180910390fd5b600c80546001600160a01b0319166001600160a01b0392909216919091179055565b6000610fb88211806109035750600182105b156109215760405163568edd5b60e11b815260040160405180910390fd5b5060009081526007602052604090205460ff1690565b610942838383611790565b61094b81611900565b505050565b60008060005b60058110156109d757600081600481111561097357610973611de0565b600086815260096020526040812091925082600481111561099657610996611de0565b60048111156109a7576109a7611de0565b815260200190815260200160002054836109c191906121dd565b92505080806109cf906121f0565b915050610956565b5092915050565b6109e9838383610937565b6001600160a01b0382163b1580610a925750604051630a85bd0160e11b8082523360048301526001600160a01b03858116602484015260448301849052608060648401526000608484015290919084169063150b7a029060a4016020604051808303816000875af1158015610a62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a869190612209565b6001600160e01b031916145b61094b5760405162461bcd60e51b815260040161080690612226565b333214610ace57604051635d04968b60e11b815260040160405180910390fd5b6611c37937e08000341015610af6576040516312171d8360e31b815260040160405180910390fd5b610fb8811180610b065750600181105b15610b245760405163568edd5b60e11b815260040160405180910390fd5b610b2e338261192f565b50565b60606001831015610b555760405163568edd5b60e11b815260040160405180910390fd5b6000826001600160401b03811115610b6f57610b6f612250565b604051908082528060200260200182016040528015610ba857816020015b610b95611c57565b815260200190600190039081610b8d5790505b50905060005b83811015610ca2576000610bc282876121dd565b9050610fb88111610c8f57600081815260076020526040902054835160ff90911690849084908110610bf657610bf6612266565b6020026020010151604001906004811115610c1357610c13611de0565b90816004811115610c2657610c26611de0565b905250610c4d610c3683886121dd565b60008381526007602052604090205460ff166115a8565b838381518110610c5f57610c5f612266565b6020026020010151602001818152505080838381518110610c8257610c82612266565b6020908102919091010151525b5080610c9a816121f0565b915050610bae565b509392505050565b60606001831015610cce5760405163568edd5b60e11b815260040160405180910390fd5b6000826001600160401b03811115610ce857610ce8612250565b604051908082528060200260200182016040528015610d2157816020015b610d0e611c57565b815260200190600190039081610d065790505b5090506000805b84811015610e65576000610d3c82886121dd565b9050876004811115610d5057610d50611de0565b60008281526007602052604090205460ff166004811115610d7357610d73611de0565b148015610d9657506000818152600260205260409020546001600160a01b031615155b15610e525780848481518110610dae57610dae612266565b602090810291909101015152610dc481896115a8565b848481518110610dd657610dd6612266565b602090810291909101810151810191909152600082815260079091526040902054845160ff90911690859085908110610e1157610e11612266565b6020026020010151604001906004811115610e2e57610e2e611de0565b90816004811115610e4157610e41611de0565b90525082610e4e816121f0565b9350505b5080610e5d816121f0565b915050610d28565b509095945050505050565b6000818152600260205260409020546001600160a01b031680610ea55760405162461bcd60e51b81526004016108069061227c565b919050565b60606001831015610ece5760405163568edd5b60e11b815260040160405180910390fd5b6000826001600160401b03811115610ee857610ee8612250565b604051908082528060200260200182016040528015610f2157816020015b610f0e611c57565b815260200190600190039081610f065790505b5090506000805b84811015610fff576000610f3c82886121dd565b90506000808281526007602052604090205460ff166004811115610f6257610f62611de0565b148015610f9157506000818152600260205260409020546001600160a01b0316158015610f915750610fb88111155b15610fec5780848481518110610fa957610fa9612266565b602090810291909101015152610fbe81610950565b848481518110610fd057610fd0612266565b602090810291909101810151015282610fe8816121f0565b9350505b5080610ff7816121f0565b915050610f28565b5090949350505050565b600b805461072090612165565b60006001600160a01b03821661105d5760405162461bcd60e51b815260206004820152600c60248201526b5a45524f5f4144445245535360a01b6044820152606401610806565b506001600160a01b031660009081526003602052604090205490565b6060600183101561109d5760405163568edd5b60e11b815260040160405180910390fd5b6000826001600160401b038111156110b7576110b7612250565b6040519080825280602002602001820160405280156110f057816020015b6110dd611c57565b8152602001906001900390816110d55790505b50905060005b83811015610ca257600061110a82876121dd565b9050610fb881116111e9578083838151811061112857611128612266565b60209081029190910101515261113d81610950565b83838151811061114f5761114f612266565b602090810291909101810151810191909152600082815260079091526040902054835160ff9091169084908490811061118a5761118a612266565b60200260200101516040019060048111156111a7576111a7611de0565b908160048111156111ba576111ba611de0565b9052506111c681611764565b8383815181106111d8576111d8612266565b602002602001015160600181815250505b50806111f4816121f0565b9150506110f6565b6060610fb882118061120e5750600182105b1561122c5760405163568edd5b60e11b815260040160405180910390fd5b6000828152600860205260409020805461124590612165565b80601f016020809104026020016040519081016040528092919081815260200182805461127190612165565b80156112be5780601f10611293576101008083540402835291602001916112be565b820191906000526020600020905b8154815290600101906020018083116112a157829003601f168201915b50505050509050919050565b600a81815481106112da57600080fd5b600091825260209091206004909102018054600182015460028301546003909301549193509160ff169084565b6001805461072090612165565b610fb88211806113245750600182105b156113425760405163568edd5b60e11b815260040160405180910390fd5b6000828152600960205260408120349183600481111561136457611364611de0565b600481111561137557611375611de0565b8152602001908152602001600020600082825461139291906121dd565b90915550505050565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b611412858585610937565b6001600160a01b0384163b15806114a95750604051630a85bd0160e11b808252906001600160a01b0386169063150b7a029061145a9033908a908990899089906004016122a0565b6020604051808303816000875af1158015611479573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061149d9190612209565b6001600160e01b031916145b6114c55760405162461bcd60e51b815260040161080690612226565b5050505050565b6114d581610e70565b6001600160a01b03166114e783610e70565b6001600160a01b031614158061150e57503361150282610e70565b6001600160a01b031614155b1561152c576040516359dc379f60e01b815260040160405180910390fd5b600061153783611764565b9050600061154483611764565b905061154f83611900565b61155883611a04565b60008481526006602052604080822083815585835281832085905586835254905185928592917fbd78cb3f78f857ae04d955153aeee046a4fc2b2408fdcc35c845ebeb8596d50b9190a450505050565b6000828152600960205260408120818360048111156115c9576115c9611de0565b60048111156115da576115da611de0565b815260200190815260200160002054905092915050565b6060600b6115fe83611aa2565b60405160200161160f9291906122f4565b6040516020818303038152906040529050919050565b3361162f82610e70565b6001600160a01b031614611656576040516359dc379f60e01b815260040160405180910390fd5b6116608282611b34565b5050565b3361166e84610e70565b6001600160a01b031614611695576040516359dc379f60e01b815260040160405180910390fd5b61169f8484611b34565b6116aa828285611b68565b50505050565b600c5460405147916000916001600160a01b039091169083908381818185875af1925050503d8060008114611701576040519150601f19603f3d011682016040523d82523d6000602084013e611706565b606091505b5050905080611660576040516312171d8360e31b815260040160405180910390fd5b3361173282610e70565b6001600160a01b031614611759576040516359dc379f60e01b815260040160405180910390fd5b61094b838383611b68565b6000818152600660205260408120541561178c5760008281526006602052604090205461070d565b5090565b6000818152600260205260409020546001600160a01b038481169116146117e65760405162461bcd60e51b815260206004820152600a60248201526957524f4e475f46524f4d60b01b6044820152606401610806565b6001600160a01b03821661180c5760405162461bcd60e51b81526004016108069061238b565b336001600160a01b038416148061184657506001600160a01b038316600090815260056020908152604080832033845290915290205460ff165b8061186757506000818152600460205260409020546001600160a01b031633145b6118835760405162461bcd60e51b81526004016108069061219f565b6001600160a01b0380841660008181526003602090815260408083208054600019019055938616808352848320805460010190558583526002825284832080546001600160a01b03199081168317909155600490925284832080549092169091559251849392916000805160206124c483398151915291a4505050565b600081815260086020526040812061191791611c90565b6000908152600760205260409020805460ff19169055565b6001600160a01b0382166119555760405162461bcd60e51b81526004016108069061238b565b6000818152600260205260409020546001600160a01b0316156119ab5760405162461bcd60e51b815260206004820152600e60248201526d1053149150511657d3525395115160921b6044820152606401610806565b6001600160a01b038216600081815260036020908152604080832080546001019055848352600290915280822080546001600160a01b0319168417905551839291906000805160206124c4833981519152908290a45050565b6000818152600260205260409020546001600160a01b031680611a395760405162461bcd60e51b81526004016108069061227c565b6001600160a01b038116600081815260036020908152604080832080546000190190558583526002825280832080546001600160a01b031990811690915560049092528083208054909216909155518492906000805160206124c4833981519152908390a45050565b60606000611aaf83611b81565b60010190506000816001600160401b03811115611ace57611ace612250565b6040519080825280601f01601f191660200182016040528015611af8576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a8504945084611b0257509392505050565b6000818152600760205260409020805483919060ff19166001836004811115611b5f57611b5f611de0565b02179055505050565b60008181526008602052604090206116aa838583612404565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b8310611bc05772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6904ee2d6d415b85acef8160201b8310611bea576904ee2d6d415b85acef8160201b830492506020015b662386f26fc100008310611c0857662386f26fc10000830492506010015b6305f5e1008310611c20576305f5e100830492506008015b6127108310611c3457612710830492506004015b60648310611c46576064830492506002015b600a831061070d5760010192915050565b6040518060800160405280600081526020016000815260200160006004811115611c8357611c83611de0565b8152602001600081525090565b508054611c9c90612165565b6000825580601f10611cac575050565b601f016020900490600052602060002090810190610b2e91905b8082111561178c5760008155600101611cc6565b6001600160e01b031981168114610b2e57600080fd5b600060208284031215611d0257600080fd5b8135611d0d81611cda565b9392505050565b60005b83811015611d2f578181015183820152602001611d17565b50506000910152565b6020815260008251806020840152611d57816040850160208701611d14565b601f01601f19169190910160400192915050565b600060208284031215611d7d57600080fd5b5035919050565b80356001600160a01b0381168114610ea557600080fd5b60008060408385031215611dae57600080fd5b611db783611d84565b946020939093013593505050565b600060208284031215611dd757600080fd5b611d0d82611d84565b634e487b7160e01b600052602160045260246000fd5b60058110611e1457634e487b7160e01b600052602160045260246000fd5b9052565b6020810161070d8284611df6565b600080600060608486031215611e3b57600080fd5b611e4484611d84565b9250611e5260208501611d84565b9150604084013590509250925092565b60008060408385031215611e7557600080fd5b50508035926020909101359150565b602080825282518282018190526000919060409081850190868401855b82811015611ee457815180518552868101518786015285810151611ec787870182611df6565b506060908101519085015260809093019290850190600101611ea1565b5091979650505050505050565b803560058110610ea557600080fd5b600080600060608486031215611f1557600080fd5b611f1e84611ef1565b95602085013595506040909401359392505050565b8481526020810184905260808101611f4e6040830185611df6565b82606083015295945050505050565b60008060408385031215611f7057600080fd5b82359150611f8060208401611ef1565b90509250929050565b60008060408385031215611f9c57600080fd5b611fa583611d84565b915060208301358015158114611fba57600080fd5b809150509250929050565b60008083601f840112611fd757600080fd5b5081356001600160401b03811115611fee57600080fd5b60208301915083602082850101111561200657600080fd5b9250929050565b60008060008060006080868803121561202557600080fd5b61202e86611d84565b945061203c60208701611d84565b93506040860135925060608601356001600160401b0381111561205e57600080fd5b61206a88828901611fc5565b969995985093965092949392505050565b6000806040838503121561208e57600080fd5b611db783611ef1565b600080600080606085870312156120ad57600080fd5b6120b685611ef1565b93506020850135925060408501356001600160401b038111156120d857600080fd5b6120e487828801611fc5565b95989497509550505050565b6000806040838503121561210357600080fd5b61210c83611d84565b9150611f8060208401611d84565b60008060006040848603121561212f57600080fd5b83356001600160401b0381111561214557600080fd5b61215186828701611fc5565b909790965060209590950135949350505050565b600181811c9082168061217957607f821691505b60208210810361219957634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252600e908201526d1393d517d055551213d49256915160921b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b8082018082111561070d5761070d6121c7565b600060018201612202576122026121c7565b5060010190565b60006020828403121561221b57600080fd5b8151611d0d81611cda565b60208082526010908201526f155394d0519157d49150d2541251539560821b604082015260600190565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6020808252600a90820152691393d517d3525395115160b21b604082015260600190565b6001600160a01b038681168252851660208201526040810184905260806060820181905281018290526000828460a0840137600060a0848401015260a0601f19601f85011683010190509695505050505050565b600080845461230281612165565b6001828116801561231a576001811461232f5761235e565b60ff198416875282151583028701945061235e565b8860005260208060002060005b858110156123555781548a82015290840190820161233c565b50505082870194505b505050508351612372818360208801611d14565b64173539b7b760d91b9101908152600501949350505050565b6020808252601190820152701253959053125117d49150d25412515395607a1b604082015260600190565b601f82111561094b57600081815260208120601f850160051c810160208610156123dd5750805b601f850160051c820191505b818110156123fc578281556001016123e9565b505050505050565b6001600160401b0383111561241b5761241b612250565b61242f836124298354612165565b836123b6565b6000601f841160018114612463576000851561244b5750838201355b600019600387901b1c1916600186901b1783556114c5565b600083815260209020601f19861690835b828110156124945786850135825560209485019460019092019101612474565b50868210156124b15760001960f88860031b161c19848701351681555b505060018560011b018355505050505056feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220ce4d6a65a6c6ed9fa2103582cfb1c77cca216f10c3e41e3e30f6ec8723e132f964736f6c63430008140033

Verified Source Code Full Match

Compiler: v0.8.20+commit.a1b79de6 EVM: paris Optimization: Yes (28 runs)
BuildrBuild_v4.sol 351 lines
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;

import "../lib/solmate/src/tokens/ERC721.sol";
import "../lib/openzeppelin-contracts/contracts/utils/Strings.sol";

error FixTokenId();
error NotEOA();
error TransferFailed();
error NotTokenOwner();
error NotTheBuildr();

/// @title buildr contract
/// @author 2bb.dev
/// @notice this contract spawns buildrs
contract BuildrBuild is ERC721 {
    using Strings for uint256;

    enum Web3District {
        Nomads,
        ContentMaestros,
        Founders,
        Investors,
        Devs
    }

    struct Outputs {
        uint256 tokenId;
        uint256 balance;
        Web3District district;
        uint256 order;
    }

    mapping(uint256 => uint256) private map;
    mapping(uint256 => Web3District) private buildrDistrict;
    mapping(uint256 => string) private buildrInfo;
    mapping(uint256 => mapping(Web3District => uint256)) private buildrBalance;

    Outputs[] public outputs;

    string public baseURI;
    uint256 private constant TOTAL_SUPPLY = 4024;
    uint256 private constant INFRA_COST = 0.005 ether;
    address private buildr;

    event Received(
        address indexed caller,
        uint256 indexed amount,
        string indexed message
    );

    event MapChange(
        uint256 indexed mapToken1,
        uint256 indexed mapToken2,
        uint256 indexed token2
    );

    modifier onlyEOA() {
        if (msg.sender != tx.origin) {
            revert NotEOA();
        }
        _;
    }

    constructor(
        string memory _name,
        string memory _symbol,
        string memory _baseURI
    ) ERC721(_name, _symbol) {
        baseURI = _baseURI;
        buildr = msg.sender;
    }

    receive() external payable {
        emit Received(msg.sender, msg.value, "Kudos");
    }

    fallback() external payable {
        emit Received(msg.sender, msg.value, "Fallback was called");
    }

    function mintBuildr(uint256 _tokenId) external payable onlyEOA {
        if (msg.value < INFRA_COST) {
            revert TransferFailed();
        }
        if (_tokenId > TOTAL_SUPPLY || _tokenId < 1) {
            revert FixTokenId();
        }
        _mint(msg.sender, _tokenId);
    }

    /// @notice destination token is burned
    /// _token1 -> _token2 => _token2 is burned afterwards
    function mapChange(uint256 _token1, uint256 _token2) external {
        if (
            ownerOf(_token1) != ownerOf(_token2) ||
            ownerOf(_token2) != msg.sender
        ) {
            revert NotTokenOwner();
        }

        uint256 tmp_token1 = mapView(_token1);
        uint256 tmp_token2 = mapView(_token2);

        resetBuildrInfo(_token2);
        _burn(_token2);

        map[_token1] = tmp_token2;
        map[_token2] = tmp_token1;

        emit MapChange(map[_token1], map[_token2], _token2);
    }

    function fundBuildr(
        uint256 _tokenId,
        Web3District _district
    ) external payable {
        if (_tokenId > TOTAL_SUPPLY || _tokenId < 1) {
            revert FixTokenId();
        }
        buildrBalance[_tokenId][_district] += msg.value;
    }

    function withdrawETH() external {
        uint256 balance = address(this).balance;
        (bool transferTx /*memory data*/, ) = buildr.call{value: balance}("");
        if (!transferTx) {
            revert TransferFailed();
        }
    }

    function editAllDetails_v2(
        Web3District _district,
        uint256 _tokenId,
        string calldata _ipfsCID
    ) external {
        if (ownerOf(_tokenId) != msg.sender) {
            revert NotTokenOwner();
        }
        editDistrict(_district, _tokenId);
        editBuildrDetail(_ipfsCID, _tokenId);
    }

    function editBuildrDistrict(
        Web3District _district,
        uint256 _tokenId
    ) external {
        if (ownerOf(_tokenId) != msg.sender) {
            revert NotTokenOwner();
        }
        editDistrict(_district, _tokenId);
    }

    function editBuildrInfo(
        string calldata _ipfsCID,
        uint256 _tokenId
    ) external {
        if (ownerOf(_tokenId) != msg.sender) {
            revert NotTokenOwner();
        }
        editBuildrDetail(_ipfsCID, _tokenId);
    }

    function changeBuildr(address _buildr) external {
        if (msg.sender != buildr) {
            revert NotTheBuildr();
        }
        buildr = _buildr;
    }

    function transferFrom(
        address from,
        address to,
        uint256 id
    ) public override {
        super.transferFrom(from, to, id);
        resetBuildrInfo(id);
    }

    function tokenURI(
        uint256 tokenId
    ) public view override returns (string memory) {
        return string(abi.encodePacked(baseURI, tokenId.toString(), ".json"));
    }

    function getBuildrInfo(
        uint256 _tokenId
    ) public view returns (string memory) {
        if (_tokenId > TOTAL_SUPPLY || _tokenId < 1) {
            revert FixTokenId();
        }
        return buildrInfo[_tokenId];
    }

    function getInfraCosts() public pure returns (uint256) {
        return INFRA_COST;
    }

    function getTokenMap(uint256 _tokenId) public view returns (uint256) {
        if (_tokenId > TOTAL_SUPPLY || _tokenId < 1) {
            revert FixTokenId();
        }
        return mapView(_tokenId);
    }

    function getFullMap(
        uint256 _start,
        uint256 _limit
    ) public view returns (Outputs[] memory) {
        if (_start < 1) {
            revert FixTokenId();
        }
        Outputs[] memory mapOutput = new Outputs[](_limit);
        for (uint256 i = 0; i < _limit; i++) {
            uint256 id = _start + i;
            if (id <= 4024) {
                mapOutput[i].tokenId = id;
                mapOutput[i].balance = getBuildrTotalBalance(id);
                mapOutput[i].district = buildrDistrict[id];
                mapOutput[i].order = mapView(id);
            }
        }
        return mapOutput;
    }

    function getFullMap_v2(
        uint256 _start,
        uint256 _limit
    ) public view returns (Outputs[] memory) {
        if (_start < 1) {
            revert FixTokenId();
        }
        Outputs[] memory mapOutput = new Outputs[](_limit);
        for (uint256 i = 0; i < _limit; i++) {
            uint256 id = _start + i;
            if (id <= 4024) {
                mapOutput[i].district = buildrDistrict[id];
                mapOutput[i].balance = getBuildrDistrictBalance(
                    _start + i,
                    buildrDistrict[id]
                );
                mapOutput[i].tokenId = id;
            }
        }
        return mapOutput;
    }

    function getDistrictMap_v2(
        Web3District _district,
        uint256 _start,
        uint256 _limit
    ) public view returns (Outputs[] memory) {
        if (_start < 1) {
            revert FixTokenId();
        }
        Outputs[] memory mapOutput = new Outputs[](_limit);
        uint256 temp;
        for (uint256 i = 0; i < _limit; i++) {
            uint256 id = _start + i;
            if (
                (buildrDistrict[id] == _district) &&
                (_ownerOf[id] != address(0))
            ) {
                mapOutput[temp].tokenId = id;
                mapOutput[temp].balance = getBuildrDistrictBalance(
                    id,
                    _district
                );
                mapOutput[temp].district = buildrDistrict[id];
                temp++;
            }
        }
        return mapOutput;
    }

    function getUnassignedBuildrs(
        uint256 _start,
        uint256 _limit
    ) public view returns (Outputs[] memory) {
        if (_start < 1) {
            revert FixTokenId();
        }
        Outputs[] memory mapOutput = new Outputs[](_limit);
        uint256 temp;
        for (uint256 i = 0; i < _limit; i++) {
            uint256 id = _start + i;
            if (
                (buildrDistrict[id] == Web3District(0)) &&
                (_ownerOf[id] == address(0) && (id <= 4024))
            ) {
                mapOutput[temp].tokenId = id;
                mapOutput[temp].balance = getBuildrTotalBalance(id);
                temp++;
            }
        }
        return mapOutput;
    }

    function getDistrict(uint256 _tokenId) public view returns (Web3District) {
        if (_tokenId > TOTAL_SUPPLY || _tokenId < 1) {
            revert FixTokenId();
        }
        return buildrDistrict[_tokenId];
    }

    function getBuildrDistrictBalance(
        uint256 _tokenId,
        Web3District _district
    ) public view returns (uint256) {
        return buildrBalance[_tokenId][_district];
    }

    function getBuildrTotalBalance(
        uint256 _tokenId
    ) public view returns (uint256) {
        uint256 balance;
        for (uint256 i = 0; i < 5; i++) {
            Web3District district = Web3District(i);
            balance += buildrBalance[_tokenId][district];
        }
        return balance;
    }

    function totalSupply() public pure returns (uint256) {
        return TOTAL_SUPPLY;
    }

    function getBuildr() public view returns (address) {
        return buildr;
    }

    function resetBuildrInfo(uint256 _tokenId) private {
        delete buildrInfo[_tokenId];
        buildrDistrict[_tokenId] = Web3District.Nomads;
    }

    function editDistrict(Web3District _district, uint256 _tokenId) private {
        buildrDistrict[_tokenId] = _district;
    }

    function editBuildrDetail(
        string calldata _ipfsCID,
        uint256 _tokenId
    ) private {
        buildrInfo[_tokenId] = _ipfsCID;
    }

    function mapView(uint256 _tokenId) private view returns (uint256) {
        return map[_tokenId] == 0 ? _tokenId : map[_tokenId];
    }
}
ERC721.sol 231 lines
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;

/// @notice Modern, minimalist, and gas efficient ERC-721 implementation.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC721.sol)
abstract contract ERC721 {
    /*//////////////////////////////////////////////////////////////
                                 EVENTS
    //////////////////////////////////////////////////////////////*/

    event Transfer(address indexed from, address indexed to, uint256 indexed id);

    event Approval(address indexed owner, address indexed spender, uint256 indexed id);

    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /*//////////////////////////////////////////////////////////////
                         METADATA STORAGE/LOGIC
    //////////////////////////////////////////////////////////////*/

    string public name;

    string public symbol;

    function tokenURI(uint256 id) public view virtual returns (string memory);

    /*//////////////////////////////////////////////////////////////
                      ERC721 BALANCE/OWNER STORAGE
    //////////////////////////////////////////////////////////////*/

    mapping(uint256 => address) internal _ownerOf;

    mapping(address => uint256) internal _balanceOf;

    function ownerOf(uint256 id) public view virtual returns (address owner) {
        require((owner = _ownerOf[id]) != address(0), "NOT_MINTED");
    }

    function balanceOf(address owner) public view virtual returns (uint256) {
        require(owner != address(0), "ZERO_ADDRESS");

        return _balanceOf[owner];
    }

    /*//////////////////////////////////////////////////////////////
                         ERC721 APPROVAL STORAGE
    //////////////////////////////////////////////////////////////*/

    mapping(uint256 => address) public getApproved;

    mapping(address => mapping(address => bool)) public isApprovedForAll;

    /*//////////////////////////////////////////////////////////////
                               CONSTRUCTOR
    //////////////////////////////////////////////////////////////*/

    constructor(string memory _name, string memory _symbol) {
        name = _name;
        symbol = _symbol;
    }

    /*//////////////////////////////////////////////////////////////
                              ERC721 LOGIC
    //////////////////////////////////////////////////////////////*/

    function approve(address spender, uint256 id) public virtual {
        address owner = _ownerOf[id];

        require(msg.sender == owner || isApprovedForAll[owner][msg.sender], "NOT_AUTHORIZED");

        getApproved[id] = spender;

        emit Approval(owner, spender, id);
    }

    function setApprovalForAll(address operator, bool approved) public virtual {
        isApprovedForAll[msg.sender][operator] = approved;

        emit ApprovalForAll(msg.sender, operator, approved);
    }

    function transferFrom(
        address from,
        address to,
        uint256 id
    ) public virtual {
        require(from == _ownerOf[id], "WRONG_FROM");

        require(to != address(0), "INVALID_RECIPIENT");

        require(
            msg.sender == from || isApprovedForAll[from][msg.sender] || msg.sender == getApproved[id],
            "NOT_AUTHORIZED"
        );

        // Underflow of the sender's balance is impossible because we check for
        // ownership above and the recipient's balance can't realistically overflow.
        unchecked {
            _balanceOf[from]--;

            _balanceOf[to]++;
        }

        _ownerOf[id] = to;

        delete getApproved[id];

        emit Transfer(from, to, id);
    }

    function safeTransferFrom(
        address from,
        address to,
        uint256 id
    ) public virtual {
        transferFrom(from, to, id);

        require(
            to.code.length == 0 ||
                ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, "") ==
                ERC721TokenReceiver.onERC721Received.selector,
            "UNSAFE_RECIPIENT"
        );
    }

    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        bytes calldata data
    ) public virtual {
        transferFrom(from, to, id);

        require(
            to.code.length == 0 ||
                ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, data) ==
                ERC721TokenReceiver.onERC721Received.selector,
            "UNSAFE_RECIPIENT"
        );
    }

    /*//////////////////////////////////////////////////////////////
                              ERC165 LOGIC
    //////////////////////////////////////////////////////////////*/

    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
        return
            interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165
            interfaceId == 0x80ac58cd || // ERC165 Interface ID for ERC721
            interfaceId == 0x5b5e139f; // ERC165 Interface ID for ERC721Metadata
    }

    /*//////////////////////////////////////////////////////////////
                        INTERNAL MINT/BURN LOGIC
    //////////////////////////////////////////////////////////////*/

    function _mint(address to, uint256 id) internal virtual {
        require(to != address(0), "INVALID_RECIPIENT");

        require(_ownerOf[id] == address(0), "ALREADY_MINTED");

        // Counter overflow is incredibly unrealistic.
        unchecked {
            _balanceOf[to]++;
        }

        _ownerOf[id] = to;

        emit Transfer(address(0), to, id);
    }

    function _burn(uint256 id) internal virtual {
        address owner = _ownerOf[id];

        require(owner != address(0), "NOT_MINTED");

        // Ownership check above ensures no underflow.
        unchecked {
            _balanceOf[owner]--;
        }

        delete _ownerOf[id];

        delete getApproved[id];

        emit Transfer(owner, address(0), id);
    }

    /*//////////////////////////////////////////////////////////////
                        INTERNAL SAFE MINT LOGIC
    //////////////////////////////////////////////////////////////*/

    function _safeMint(address to, uint256 id) internal virtual {
        _mint(to, id);

        require(
            to.code.length == 0 ||
                ERC721TokenReceiver(to).onERC721Received(msg.sender, address(0), id, "") ==
                ERC721TokenReceiver.onERC721Received.selector,
            "UNSAFE_RECIPIENT"
        );
    }

    function _safeMint(
        address to,
        uint256 id,
        bytes memory data
    ) internal virtual {
        _mint(to, id);

        require(
            to.code.length == 0 ||
                ERC721TokenReceiver(to).onERC721Received(msg.sender, address(0), id, data) ==
                ERC721TokenReceiver.onERC721Received.selector,
            "UNSAFE_RECIPIENT"
        );
    }
}

/// @notice A generic interface for a contract which properly accepts ERC721 tokens.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC721.sol)
abstract contract ERC721TokenReceiver {
    function onERC721Received(
        address,
        address,
        uint256,
        bytes calldata
    ) external virtual returns (bytes4) {
        return ERC721TokenReceiver.onERC721Received.selector;
    }
}
Strings.sol 94 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol)

pragma solidity ^0.8.20;

import {Math} from "./math/Math.sol";
import {SignedMath} from "./math/SignedMath.sol";

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant HEX_DIGITS = "0123456789abcdef";
    uint8 private constant ADDRESS_LENGTH = 20;

    /**
     * @dev The `value` string doesn't fit in the specified `length`.
     */
    error StringsInsufficientHexLength(uint256 value, uint256 length);

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = Math.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `int256` to its ASCII `string` decimal representation.
     */
    function toStringSigned(int256 value) internal pure returns (string memory) {
        return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value)));
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, Math.log256(value) + 1);
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        uint256 localValue = value;
        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_DIGITS[localValue & 0xf];
            localValue >>= 4;
        }
        if (localValue != 0) {
            revert StringsInsufficientHexLength(value, length);
        }
        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);
    }

    /**
     * @dev Returns true if the two strings are equal.
     */
    function equal(string memory a, string memory b) internal pure returns (bool) {
        return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));
    }
}
Math.sol 415 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)

pragma solidity ^0.8.20;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    /**
     * @dev Muldiv operation overflow.
     */
    error MathOverflowedMulDiv();

    enum Rounding {
        Floor, // Toward negative infinity
        Ceil, // Toward positive infinity
        Trunc, // Toward zero
        Expand // Away from zero
    }

    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, with an overflow flag.
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds towards infinity instead
     * of rounding towards zero.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        if (b == 0) {
            // Guarantee the same behavior as in a regular Solidity division.
            return a / b;
        }

        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
     * denominator == 0.
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
     * Uniswap Labs also under MIT license.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0 = x * y; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            if (denominator <= prod1) {
                revert MathOverflowedMulDiv();
            }

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator.
            // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.

            uint256 twos = denominator & (0 - denominator);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
            // works in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
     * towards zero.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2 of a positive value rounded towards zero.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10 of a positive value rounded towards zero.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10 ** 64) {
                value /= 10 ** 64;
                result += 64;
            }
            if (value >= 10 ** 32) {
                value /= 10 ** 32;
                result += 32;
            }
            if (value >= 10 ** 16) {
                value /= 10 ** 16;
                result += 16;
            }
            if (value >= 10 ** 8) {
                value /= 10 ** 8;
                result += 8;
            }
            if (value >= 10 ** 4) {
                value /= 10 ** 4;
                result += 4;
            }
            if (value >= 10 ** 2) {
                value /= 10 ** 2;
                result += 2;
            }
            if (value >= 10 ** 1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256 of a positive value rounded towards zero.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 256, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);
        }
    }

    /**
     * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
     */
    function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
        return uint8(rounding) % 2 == 1;
    }
}
SignedMath.sol 43 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol)

pragma solidity ^0.8.20;

/**
 * @dev Standard signed math utilities missing in the Solidity language.
 */
library SignedMath {
    /**
     * @dev Returns the largest of two signed numbers.
     */
    function max(int256 a, int256 b) internal pure returns (int256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two signed numbers.
     */
    function min(int256 a, int256 b) internal pure returns (int256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two signed numbers without overflow.
     * The result is rounded towards zero.
     */
    function average(int256 a, int256 b) internal pure returns (int256) {
        // Formula from the book "Hacker's Delight"
        int256 x = (a & b) + ((a ^ b) >> 1);
        return x + (int256(uint256(x) >> 255) & (a ^ b));
    }

    /**
     * @dev Returns the absolute unsigned value of a signed value.
     */
    function abs(int256 n) internal pure returns (uint256) {
        unchecked {
            // must be unchecked in order to support `n = type(int256).min`
            return uint256(n >= 0 ? n : -n);
        }
    }
}

Read Contract

balanceOf 0x70a08231 → uint256
baseURI 0x6c0360eb → string
getApproved 0x081812fc → address
getBuildr 0xf9195cb2 → address
getBuildrDistrictBalance 0xc49354fe → uint256
getBuildrInfo 0x85a50636 → string
getBuildrTotalBalance 0x38da41e2 → uint256
getDistrict 0x22776478 → uint8
getDistrictMap_v2 0x6330bb4b → tuple[]
getFullMap 0x7152e7fe → tuple[]
getFullMap_v2 0x60f0df6b → tuple[]
getInfraCosts 0x41200eba → uint256
getTokenMap 0x1e9e6686 → uint256
getUnassignedBuildrs 0x646abf1f → tuple[]
isApprovedForAll 0xe985e9c5 → bool
name 0x06fdde03 → string
outputs 0x9149bdf2 → uint256, uint256, uint8, uint256
ownerOf 0x6352211e → address
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenURI 0xc87b56dd → string
totalSupply 0x18160ddd → uint256

Write Contract 13 functions

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

approve 0x095ea7b3
address spender
uint256 id
changeBuildr 0x2102e288
address _buildr
editAllDetails_v2 0xdcb58f17
uint8 _district
uint256 _tokenId
string _ipfsCID
editBuildrDistrict 0xdc2341c4
uint8 _district
uint256 _tokenId
editBuildrInfo 0xf6ef2e62
string _ipfsCID
uint256 _tokenId
fundBuildr 0xa1339569
uint256 _tokenId
uint8 _district
mapChange 0xc023484d
uint256 _token1
uint256 _token2
mintBuildr 0x5bcea4d5
uint256 _tokenId
safeTransferFrom 0x42842e0e
address from
address to
uint256 id
safeTransferFrom 0xb88d4fde
address from
address to
uint256 id
bytes data
setApprovalForAll 0xa22cb465
address operator
bool approved
transferFrom 0x23b872dd
address from
address to
uint256 id
withdrawETH 0xe086e5ec
No parameters

Recent Transactions

No transactions found for this address