Address Contract Verified
Address
0x0e498afce58dE8651B983F136256fA3b8d9703bc
Balance
0 ETH
Nonce
1
Code Size
9509 bytes
Creator
0xf0B595d1...35Ea at tx 0x990e7bfd...1e6917
Indexed Transactions
0
Contract Bytecode
9509 bytes
0x608060405234801561001057600080fd5b506004361061027f5760003560e01c80635025d1dd1161015c578063a457c2d7116100ce578063d539139311610087578063d539139314610545578063d547741f1461054d578063d8fbe99414610560578063dcdd8a0414610573578063dd62ed3e14610586578063f44637ba146105995761027f565b8063a457c2d7146104d3578063a9059cbb146104e6578063aa271e1a146104f9578063c1d34b891461050c578063cae9ca511461051f578063d505accf146105325761027f565b80637ecebe00116101205780637ecebe001461047757806391d148541461048a57806395d89b411461049d578063983b2d56146104a55780639dc29fac146104b8578063a217fddf146104cb5761027f565b80635025d1dd14610423578063704802751461043657806370a082311461044957806375829def1461045c57806375b238fc1461046f5761027f565b80632f2ff15d116101f55780633644e515116101b95780633644e515146103bc57806336568abe146103c457806339509351146103d75780634000aea0146103ea57806340c10f19146103fd5780634334614a146104105761027f565b80632f2ff15d146103665780633092afd51461037957806330adf81f1461038c578063313ce567146103945780633177029f146103a95761027f565b80631785f53c116102475780631785f53c146102fd57806318160ddd1461031057806323b872dd14610325578063248a9ca31461033857806324d7806c1461034b578063282c51f31461035e5761027f565b806301ffc9a71461028457806302846858146102ad57806306fdde03146102c2578063095ea7b3146102d75780631296ee62146102ea575b600080fd5b610297610292366004611be3565b6105ac565b6040516102a49190611d44565b60405180910390f35b6102c06102bb366004611916565b6105bf565b005b6102ca610608565b6040516102a49190611daa565b6102976102e5366004611b2b565b61069a565b6102976102f8366004611b2b565b6106b7565b6102c061030b366004611916565b6106da565b610318610717565b6040516102a49190611d4f565b610297610333366004611962565b61071d565b610318610346366004611ba9565b6107ad565b610297610359366004611916565b6107c2565b6103186107dc565b6102c0610374366004611bc1565b6107ee565b6102c0610387366004611916565b610817565b610318610854565b61039c610878565b6040516102a49190612358565b6102976103b7366004611b2b565b61087d565b610318610899565b6102c06103d2366004611bc1565b61089f565b6102976103e5366004611b2b565b6108e5565b6102976103f8366004611b54565b610939565b61029761040b366004611b2b565b61097f565b61029761041e366004611916565b6109b0565b610297610431366004611a4f565b6109ca565b6102c0610444366004611916565b610a49565b610318610457366004611916565b610a86565b6102c061046a366004611916565b610aa1565b610318610b45565b610318610485366004611916565b610b57565b610297610498366004611bc1565b610b69565b6102ca610b94565b6102c06104b3366004611916565b610ba3565b6102976104c6366004611b2b565b610be0565b610318610c11565b6102976104e1366004611b2b565b610c16565b6102976104f4366004611b2b565b610c85565b610297610507366004611916565b610c99565b61029761051a36600461199d565b610cb3565b61029761052d366004611b54565b610cf1565b6102c0610540366004611ac2565b610d25565b610318610e73565b6102c061055b366004611bc1565b610e85565b61029761056e366004611962565b610ea4565b610318610581366004611a03565b610ec1565b610318610594366004611930565b610f4c565b6102c06105a7366004611916565b610f77565b60006105b782610fb4565b90505b919050565b6105c8336107c2565b6105ed5760405162461bcd60e51b81526004016105e490611f24565b60405180910390fd5b6106056000805160206124d083398151915282610e85565b50565b606060038054610617906123f7565b80601f0160208091040260200160405190810160405280929190818152602001828054610643906123f7565b80156106905780601f1061066557610100808354040283529160200191610690565b820191906000526020600020905b81548152906001019060200180831161067357829003601f168201915b5050505050905090565b60006106ae6106a7610fd9565b8484610fdd565b50600192915050565b60006106d3838360405180602001604052806000815250610939565b9392505050565b6106e3336107c2565b6106ff5760405162461bcd60e51b81526004016105e490611f24565b6106056000805160206124b08339815191528261089f565b60025490565b600061072a848484611091565b6001600160a01b03841660009081526001602052604081208161074b610fd9565b6001600160a01b03166001600160a01b031681526020019081526020016000205490508281101561078e5760405162461bcd60e51b81526004016105e49061212f565b6107a28561079a610fd9565b858403610fdd565b506001949350505050565b60009081526005602052604090206001015490565b60006105b76000805160206124b083398151915283610b69565b6000805160206124d083398151915281565b6107f7826107ad565b61080881610803610fd9565b6111bb565b610812838361121f565b505050565b610820336107c2565b61083c5760405162461bcd60e51b81526004016105e490611f24565b61060560008051602061249083398151915282610e85565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b601290565b60006106d3838360405180602001604052806000815250610cf1565b60065481565b6108a7610fd9565b6001600160a01b0316816001600160a01b0316146108d75760405162461bcd60e51b81526004016105e4906122d2565b6108e182826112a6565b5050565b60006106ae6108f2610fd9565b848460016000610900610fd9565b6001600160a01b03908116825260208083019390935260409182016000908120918b16815292529020546109349190612366565b610fdd565b60006109458484610c85565b50610959610951610fd9565b85858561132b565b6109755760405162461bcd60e51b81526004016105e4906120b9565b5060019392505050565b600061098a33610c99565b6109a65760405162461bcd60e51b81526004016105e490612241565b6106ae83836113f6565b60006105b76000805160206124d083398151915283610b69565b600060016109db8a8a8a8a8a610ec1565b838686604051600081526020016040526040516109fb9493929190611d8c565b6020604051602081039080840390855afa158015610a1d573d6000803e3d6000fd5b505050602060405103516001600160a01b0316896001600160a01b031614905098975050505050505050565b610a52336107c2565b610a6e5760405162461bcd60e51b81526004016105e490611f24565b6106056000805160206124b0833981519152826107ee565b6001600160a01b031660009081526020819052604090205490565b610aaa336107c2565b610ac65760405162461bcd60e51b81526004016105e490611f24565b6001600160a01b038116610aec5760405162461bcd60e51b81526004016105e490611f9d565b336001600160a01b0382161415610b155760405162461bcd60e51b81526004016105e4906120ff565b610b2d6000805160206124b0833981519152826107ee565b6106056000805160206124b08339815191523361089f565b6000805160206124b083398151915281565b60076020526000908152604090205481565b60009182526005602090815260408084206001600160a01b0393909316845291905290205460ff1690565b606060048054610617906123f7565b610bac336107c2565b610bc85760405162461bcd60e51b81526004016105e490611f24565b610605600080516020612490833981519152826107ee565b6000610beb336109b0565b610c075760405162461bcd60e51b81526004016105e49061201a565b6106ae83836114be565b600081565b60008060016000610c25610fd9565b6001600160a01b0390811682526020808301939093526040918201600090812091881681529252902054905082811015610c715760405162461bcd60e51b81526004016105e49061228d565b610975610c7c610fd9565b85858403610fdd565b60006106ae610c92610fd9565b8484611091565b60006105b760008051602061249083398151915283610b69565b6000610cc085858561071d565b50610ccd8585858561132b565b6107a25760405162461bcd60e51b81526004016105e4906120b9565b949350505050565b6000610cfd848461069a565b50610d098484846115af565b6109755760405162461bcd60e51b81526004016105e490611edf565b42841015610d455760405162461bcd60e51b81526004016105e490612091565b6001600160a01b03871660009081526007602052604081208054610d7e918a918a918a918a9187610d7583612432565b91905055610ec1565b9050866001600160a01b0316886001600160a01b03161415610db25760405162461bcd60e51b81526004016105e490611f66565b600060018286868660405160008152602001604052604051610dd79493929190611d8c565b6020604051602081039080840390855afa158015610df9573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116610e2c5760405162461bcd60e51b81526004016105e490612066565b886001600160a01b0316816001600160a01b031614610e5d5760405162461bcd60e51b81526004016105e490611e77565b610e68898989610fdd565b505050505050505050565b60008051602061249083398151915281565b610e8e826107ad565b610e9a81610803610fd9565b61081283836112a6565b6000610ce984848460405180602001604052806000815250610cb3565b60006006547f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c960001b8787878688604051602001610f0496959493929190611d58565b60405160208183030381529060405280519060200120604051602001610f2b929190611c47565b60405160208183030381529060405280519060200120905095945050505050565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b610f80336107c2565b610f9c5760405162461bcd60e51b81526004016105e490611f24565b6106056000805160206124d0833981519152826107ee565b60006001600160e01b03198216637965db0b60e01b14806105b757506105b782611677565b3390565b6001600160a01b0383166110035760405162461bcd60e51b81526004016105e4906121fd565b6001600160a01b0382166110295760405162461bcd60e51b81526004016105e490611e9d565b6001600160a01b0380841660008181526001602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590611084908590611d4f565b60405180910390a3505050565b6001600160a01b0383166110b75760405162461bcd60e51b81526004016105e4906121b8565b6001600160a01b0382166110dd5760405162461bcd60e51b81526004016105e490611df2565b6110e8838383610812565b6001600160a01b038316600090815260208190526040902054818110156111215760405162461bcd60e51b81526004016105e490611fd4565b6001600160a01b03808516600090815260208190526040808220858503905591851681529081208054849290611158908490612366565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516111a29190611d4f565b60405180910390a36111b5848484610812565b50505050565b6111c58282610b69565b6108e1576111dd816001600160a01b0316601461169c565b6111e883602061169c565b6040516020016111f9929190611c62565b60408051601f198184030181529082905262461bcd60e51b82526105e491600401611daa565b6112298282610b69565b6108e15760008281526005602090815260408083206001600160a01b03851684529091529020805460ff19166001179055611262610fd9565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6112b08282610b69565b156108e15760008281526005602090815260408083206001600160a01b03851684529091529020805460ff191690556112e7610fd9565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b600061133f846001600160a01b031661184e565b61134b57506000610ce9565b6000846001600160a01b03166388a7ca5c611364610fd9565b8887876040518563ffffffff1660e01b81526004016113869493929190611cd7565b602060405180830381600087803b1580156113a057600080fd5b505af11580156113b4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113d89190611bff565b6001600160e01b031916632229f29760e21b14915050949350505050565b6001600160a01b03821661141c5760405162461bcd60e51b81526004016105e490612321565b61142860008383610812565b806002600082825461143a9190612366565b90915550506001600160a01b03821660009081526020819052604081208054839290611467908490612366565b90915550506040516001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906114aa908590611d4f565b60405180910390a36108e160008383610812565b6001600160a01b0382166114e45760405162461bcd60e51b81526004016105e490612177565b6114f082600083610812565b6001600160a01b038216600090815260208190526040902054818110156115295760405162461bcd60e51b81526004016105e490611e35565b6001600160a01b038316600090815260208190526040812083830390556002805484929061155890849061239d565b90915550506040516000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9061159b908690611d4f565b60405180910390a361081283600084610812565b60006115c3846001600160a01b031661184e565b6115cf575060006106d3565b6000846001600160a01b0316637b04a2d06115e8610fd9565b86866040518463ffffffff1660e01b815260040161160893929190611d14565b602060405180830381600087803b15801561162257600080fd5b505af1158015611636573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061165a9190611bff565b6001600160e01b0319166307b04a2d60e41b149150509392505050565b60006001600160e01b0319821663b0202a1160e01b14806105b757506105b782611854565b606060006116ab83600261237e565b6116b6906002612366565b67ffffffffffffffff8111156116dc57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015611706576020820181803683370190505b509050600360fc1b8160008151811061172f57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061176c57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600061179084600261237e565b61179b906001612366565b90505b600181111561182f576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106117dd57634e487b7160e01b600052603260045260246000fd5b1a60f81b82828151811061180157634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c93611828816123e0565b905061179e565b5083156106d35760405162461bcd60e51b81526004016105e490611dbd565b3b151590565b6001600160e01b031981166301ffc9a760e01b14919050565b80356001600160a01b03811681146105ba57600080fd5b600082601f830112611894578081fd5b813567ffffffffffffffff808211156118af576118af612463565b604051601f8301601f1916810160200182811182821017156118d3576118d3612463565b6040528281528483016020018610156118ea578384fd5b82602086016020830137918201602001929092529392505050565b803560ff811681146105ba57600080fd5b600060208284031215611927578081fd5b6106d38261186d565b60008060408385031215611942578081fd5b61194b8361186d565b91506119596020840161186d565b90509250929050565b600080600060608486031215611976578081fd5b61197f8461186d565b925061198d6020850161186d565b9150604084013590509250925092565b600080600080608085870312156119b2578081fd5b6119bb8561186d565b93506119c96020860161186d565b925060408501359150606085013567ffffffffffffffff8111156119eb578182fd5b6119f787828801611884565b91505092959194509250565b600080600080600060a08688031215611a1a578081fd5b611a238661186d565b9450611a316020870161186d565b94979496505050506040830135926060810135926080909101359150565b600080600080600080600080610100898b031215611a6b578283fd5b611a748961186d565b9750611a8260208a0161186d565b965060408901359550606089013594506080890135935060a0890135925060c08901359150611ab360e08a01611905565b90509295985092959890939650565b600080600080600080600060e0888a031215611adc578283fd5b611ae58861186d565b9650611af36020890161186d565b95506040880135945060608801359350611b0f60808901611905565b925060a0880135915060c0880135905092959891949750929550565b60008060408385031215611b3d578182fd5b611b468361186d565b946020939093013593505050565b600080600060608486031215611b68578283fd5b611b718461186d565b925060208401359150604084013567ffffffffffffffff811115611b93578182fd5b611b9f86828701611884565b9150509250925092565b600060208284031215611bba578081fd5b5035919050565b60008060408385031215611bd3578182fd5b823591506119596020840161186d565b600060208284031215611bf4578081fd5b81356106d381612479565b600060208284031215611c10578081fd5b81516106d381612479565b60008151808452611c338160208601602086016123b4565b601f01601f19169290920160200192915050565b61190160f01b81526002810192909252602282015260420190565b60007f416363657373436f6e74726f6c3a206163636f756e742000000000000000000082528351611c9a8160178501602088016123b4565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351611ccb8160288401602088016123b4565b01602801949350505050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090611d0a90830184611c1b565b9695505050505050565b600060018060a01b038516825283602083015260606040830152611d3b6060830184611c1b565b95945050505050565b901515815260200190565b90815260200190565b9586526001600160a01b0394851660208701529290931660408501526060840152608083019190915260a082015260c00190565b93845260ff9290921660208401526040830152606082015260800190565b6000602082526106d36020830184611c1b565b6020808252818101527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604082015260600190565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b60208082526022908201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604082015261636560f01b606082015260800190565b6020808252600c908201526b155b985d5d1a1bdc9a5e995960a21b604082015260600190565b60208082526022908201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604082015261737360f01b606082015260800190565b60208082526025908201527f455243313336333a205f636865636b416e6443616c6c417070726f7665207265604082015264766572747360d81b606082015260800190565b60208082526022908201527f41636365737369626c653a2043616c6c6572206973206e6f7420616e2061646d60408201526134b760f11b606082015260800190565b60208082526019908201527f617070726f76616c20746f2063757272656e74206f776e657200000000000000604082015260600190565b60208082526018908201527f41636365737369626c653a207a65726f20616464726573730000000000000000604082015260600190565b60208082526026908201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604082015265616c616e636560d01b606082015260800190565b6020808252602c908201527f41636365737369626c65506c7573436f6d6d6f6e3a2043616c6c65722069732060408201526b3737ba103090313ab93732b960a11b606082015260800190565b602080825260119082015270496e76616c6964207369676e617475726560781b604082015260600190565b6020808252600e908201526d1c195c9b5a5d081156141254915160921b604082015260600190565b60208082526026908201527f455243313336333a205f636865636b416e6443616c6c5472616e73666572207260408201526565766572747360d01b606082015260800190565b60208082526016908201527520b1b1b2b9b9b4b136329d1039b0b6b29030b236b4b760511b604082015260600190565b60208082526028908201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616040820152676c6c6f77616e636560c01b606082015260800190565b60208082526021908201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736040820152607360f81b606082015260800190565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526024908201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646040820152637265737360e01b606082015260800190565b6020808252602c908201527f41636365737369626c65506c7573436f6d6d6f6e3a2043616c6c65722069732060408201526b3737ba10309036b4b73a32b960a11b606082015260800190565b60208082526025908201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604082015264207a65726f60d81b606082015260800190565b6020808252602f908201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560408201526e103937b632b9903337b91039b2b63360891b606082015260800190565b6020808252601f908201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604082015260600190565b60ff91909116815260200190565b600082198211156123795761237961244d565b500190565b60008160001904831182151516156123985761239861244d565b500290565b6000828210156123af576123af61244d565b500390565b60005b838110156123cf5781810151838201526020016123b7565b838111156111b55750506000910152565b6000816123ef576123ef61244d565b506000190190565b60028104600182168061240b57607f821691505b6020821081141561242c57634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156124465761244661244d565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b03198116811461060557600080fdfef0887ba65ee2024ea881d91b74c2450ef19e1557f03bed3ea9f16b037cbe2dc9df8b4c520ffe197c5343c6f5aec59570151ef9a492f2c624fd45ddde6135ec429667e80708b6eeeb0053fa0cca44e028ff548e2a9f029edfeac87c118b08b7c8a2646970667358221220b5b4c4c783a5bf661219f850002501dc8768c29897152e3d99238ed45700beb364736f6c63430008000033
Verified Source Code Full Match
Compiler: v0.8.0+commit.c7dfd78e
EVM: istanbul
Optimization: Yes (200 runs)
DOC.sol 172 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "erc-payable-token/contracts/token/ERC1363/ERC1363.sol";
import "../common/AccessiblePlusCommon.sol";
contract DOC is ERC1363, AccessiblePlusCommon {
bytes32 public DOMAIN_SEPARATOR;
mapping(address => uint256) public nonces;
/// @dev Value is equal to keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
bytes32 public constant PERMIT_TYPEHASH =
0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
constructor(
string memory _name,
string memory _symbol,
uint256 initialSupply,
address _owner
) ERC20(_name, _symbol) {
_mint(_owner, initialSupply);
uint256 chainId;
assembly {
chainId := chainid()
}
DOMAIN_SEPARATOR = keccak256(
abi.encode(
// keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)')
0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f,
keccak256(bytes(_name)),
keccak256(bytes(_symbol)),
chainId,
address(this)
)
);
_setRoleAdmin(ADMIN_ROLE, ADMIN_ROLE);
_setRoleAdmin(BURNER_ROLE, ADMIN_ROLE);
_setRoleAdmin(MINTER_ROLE, ADMIN_ROLE);
_setupRole(ADMIN_ROLE, _owner);
_setupRole(BURNER_ROLE, _owner);
_setupRole(MINTER_ROLE, _owner);
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC1363, AccessControl) returns (bool) {
return super.supportsInterface(interfaceId);
}
function mint(address account, uint256 amount)
external
onlyMinter
returns (bool)
{
_mint(account,amount);
return true;
}
function burn(address account, uint256 amount)
external
onlyBurner
returns (bool)
{
_burn(account,amount);
return true;
}
/// @dev Authorizes the owner's token to be used by the spender as much as the value.
/// @dev The signature must have the owner's signature.
/// @param owner the token's owner
/// @param spender the account that spend owner's token
/// @param value the amount to be approve to spend
/// @param deadline the deadline that valid the owner's signature
/// @param v the owner's signature - v
/// @param r the owner's signature - r
/// @param s the owner's signature - s
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external {
require(deadline >= block.timestamp, "permit EXPIRED");
bytes32 digest =
hashPermit(owner, spender, value, deadline, nonces[owner]++);
require(owner != spender, "approval to current owner");
// if (Address.isContract(owner)) {
// require(IERC1271(owner).isValidSignature(digest, abi.encodePacked(r, s, v)) == 0x1626ba7e, 'Unauthorized');
// } else {
address recoveredAddress = ecrecover(digest, v, r, s);
require(recoveredAddress != address(0), "Invalid signature");
require(recoveredAddress == owner, "Unauthorized");
// }
_approve(owner, spender, value);
}
/// @dev verify the signature
/// @param owner the token's owner
/// @param spender the account that spend owner's token
/// @param value the amount to be approve to spend
/// @param deadline the deadline that valid the owner's signature
/// @param _nounce the _nounce
/// @param sigR the owner's signature - r
/// @param sigS the owner's signature - s
/// @param sigV the owner's signature - v
function verify(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint256 _nounce,
bytes32 sigR,
bytes32 sigS,
uint8 sigV
) external view returns (bool) {
return
owner ==
ecrecover(
hashPermit(owner, spender, value, deadline, _nounce),
sigV,
sigR,
sigS
);
}
/// @dev the hash of Permit
/// @param owner the token's owner
/// @param spender the account that spend owner's token
/// @param value the amount to be approve to spend
/// @param deadline the deadline that valid the owner's signature
/// @param _nounce the _nounce
function hashPermit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint256 _nounce
) public view returns (bytes32) {
return
keccak256(
abi.encodePacked(
"\x19\x01",
DOMAIN_SEPARATOR,
keccak256(
abi.encode(
PERMIT_TYPEHASH,
owner,
spender,
value,
_nounce,
deadline
)
)
)
);
}
}
AccessRoleCommon.sol 8 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract AccessRoleCommon {
bytes32 public constant ADMIN_ROLE = keccak256("ADMIN");
bytes32 public constant MINTER_ROLE = keccak256("MINTER");
bytes32 public constant BURNER_ROLE = keccak256("BURNER");
}
AccessibleCommon.sol 39 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/access/AccessControl.sol";
import "./AccessRoleCommon.sol";
contract AccessibleCommon is AccessRoleCommon, AccessControl {
modifier onlyOwner() {
require(isAdmin(msg.sender), "Accessible: Caller is not an admin");
_;
}
/// @dev add admin
/// @param account address to add
function addAdmin(address account) public virtual onlyOwner {
grantRole(ADMIN_ROLE, account);
}
/// @dev remove admin
/// @param account address to remove
function removeAdmin(address account) public virtual onlyOwner {
renounceRole(ADMIN_ROLE, account);
}
/// @dev transfer admin
/// @param newAdmin new admin address
function transferAdmin(address newAdmin) external virtual onlyOwner {
require(newAdmin != address(0), "Accessible: zero address");
require(msg.sender != newAdmin, "Accessible: same admin");
grantRole(ADMIN_ROLE, newAdmin);
renounceRole(ADMIN_ROLE, msg.sender);
}
/// @dev whether admin
/// @param account address to check
function isAdmin(address account) public view virtual returns (bool) {
return hasRole(ADMIN_ROLE, account);
}
}
Address.sol 216 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
Context.sol 23 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
Strings.sol 66 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
AccessiblePlusCommon.sol 45 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./AccessibleCommon.sol";
contract AccessiblePlusCommon is AccessibleCommon {
modifier onlyMinter() {
require(
isMinter(msg.sender),
"AccessiblePlusCommon: Caller is not a minter"
);
_;
}
modifier onlyBurner() {
require(
isBurner(msg.sender),
"AccessiblePlusCommon: Caller is not a burner"
);
_;
}
function isMinter(address account) public view virtual returns (bool) {
return hasRole(MINTER_ROLE, account);
}
function isBurner(address account) public view virtual returns (bool) {
return hasRole(BURNER_ROLE, account);
}
function addMinter(address account) public virtual onlyOwner {
grantRole(MINTER_ROLE, account);
}
function addBurner(address account) public virtual onlyOwner {
grantRole(BURNER_ROLE, account);
}
function removeMinter(address account) public virtual onlyOwner {
revokeRole(MINTER_ROLE, account);
}
function removeBurner(address account) public virtual onlyOwner {
revokeRole(BURNER_ROLE, account);
}
}
ERC20.sol 355 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The default value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overridden;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
unchecked {
_approve(sender, _msgSender(), currentAllowance - amount);
}
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
}
return true;
}
/**
* @dev Moves `amount` of tokens from `sender` to `recipient`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[sender] = senderBalance - amount;
}
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
_afterTokenTransfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
}
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
}
IERC20.sol 81 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
AccessControl.sol 210 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it.
*/
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
mapping(bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with a standardized message including the required role.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*
* _Available since v4.1._
*/
modifier onlyRole(bytes32 role) {
_checkRole(role, _msgSender());
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view override returns (bool) {
return _roles[role].members[account];
}
/**
* @dev Revert with a standard message if `account` is missing `role`.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*/
function _checkRole(bytes32 role, address account) internal view {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
Strings.toHexString(uint160(account), 20),
" is missing role ",
Strings.toHexString(uint256(role), 32)
)
)
);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view override returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) public virtual override {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
function _grantRole(bytes32 role, address account) private {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
function _revokeRole(bytes32 role, address account) private {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
}
IAccessControl.sol 87 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControl {
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*
* _Available since v3.1._
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {AccessControl-_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) external;
}
ERC1363.sol 157 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import "./IERC1363.sol";
import "./IERC1363Receiver.sol";
import "./IERC1363Spender.sol";
/**
* @title ERC1363
* @author Vittorio Minacori (https://github.com/vittominacori)
* @dev Implementation of an ERC1363 interface
*/
abstract contract ERC1363 is ERC20, IERC1363, ERC165 {
using Address for address;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return interfaceId == type(IERC1363).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Transfer tokens to a specified address and then execute a callback on recipient.
* @param recipient The address to transfer to.
* @param amount The amount to be transferred.
* @return A boolean that indicates if the operation was successful.
*/
function transferAndCall(address recipient, uint256 amount) public virtual override returns (bool) {
return transferAndCall(recipient, amount, "");
}
/**
* @dev Transfer tokens to a specified address and then execute a callback on recipient.
* @param recipient The address to transfer to
* @param amount The amount to be transferred
* @param data Additional data with no specified format
* @return A boolean that indicates if the operation was successful.
*/
function transferAndCall(
address recipient,
uint256 amount,
bytes memory data
) public virtual override returns (bool) {
transfer(recipient, amount);
require(_checkAndCallTransfer(_msgSender(), recipient, amount, data), "ERC1363: _checkAndCallTransfer reverts");
return true;
}
/**
* @dev Transfer tokens from one address to another and then execute a callback on recipient.
* @param sender The address which you want to send tokens from
* @param recipient The address which you want to transfer to
* @param amount The amount of tokens to be transferred
* @return A boolean that indicates if the operation was successful.
*/
function transferFromAndCall(
address sender,
address recipient,
uint256 amount
) public virtual override returns (bool) {
return transferFromAndCall(sender, recipient, amount, "");
}
/**
* @dev Transfer tokens from one address to another and then execute a callback on recipient.
* @param sender The address which you want to send tokens from
* @param recipient The address which you want to transfer to
* @param amount The amount of tokens to be transferred
* @param data Additional data with no specified format
* @return A boolean that indicates if the operation was successful.
*/
function transferFromAndCall(
address sender,
address recipient,
uint256 amount,
bytes memory data
) public virtual override returns (bool) {
transferFrom(sender, recipient, amount);
require(_checkAndCallTransfer(sender, recipient, amount, data), "ERC1363: _checkAndCallTransfer reverts");
return true;
}
/**
* @dev Approve spender to transfer tokens and then execute a callback on recipient.
* @param spender The address allowed to transfer to
* @param amount The amount allowed to be transferred
* @return A boolean that indicates if the operation was successful.
*/
function approveAndCall(address spender, uint256 amount) public virtual override returns (bool) {
return approveAndCall(spender, amount, "");
}
/**
* @dev Approve spender to transfer tokens and then execute a callback on recipient.
* @param spender The address allowed to transfer to.
* @param amount The amount allowed to be transferred.
* @param data Additional data with no specified format.
* @return A boolean that indicates if the operation was successful.
*/
function approveAndCall(
address spender,
uint256 amount,
bytes memory data
) public virtual override returns (bool) {
approve(spender, amount);
require(_checkAndCallApprove(spender, amount, data), "ERC1363: _checkAndCallApprove reverts");
return true;
}
/**
* @dev Internal function to invoke `onTransferReceived` on a target address
* The call is not executed if the target address is not a contract
* @param sender address Representing the previous owner of the given token value
* @param recipient address Target address that will receive the tokens
* @param amount uint256 The amount mount of tokens to be transferred
* @param data bytes Optional data to send along with the call
* @return whether the call correctly returned the expected magic value
*/
function _checkAndCallTransfer(
address sender,
address recipient,
uint256 amount,
bytes memory data
) internal virtual returns (bool) {
if (!recipient.isContract()) {
return false;
}
bytes4 retval = IERC1363Receiver(recipient).onTransferReceived(_msgSender(), sender, amount, data);
return (retval == IERC1363Receiver(recipient).onTransferReceived.selector);
}
/**
* @dev Internal function to invoke `onApprovalReceived` on a target address
* The call is not executed if the target address is not a contract
* @param spender address The address which will spend the funds
* @param amount uint256 The amount of tokens to be spent
* @param data bytes Optional data to send along with the call
* @return whether the call correctly returned the expected magic value
*/
function _checkAndCallApprove(
address spender,
uint256 amount,
bytes memory data
) internal virtual returns (bool) {
if (!spender.isContract()) {
return false;
}
bytes4 retval = IERC1363Spender(spender).onApprovalReceived(_msgSender(), amount, data);
return (retval == IERC1363Spender(spender).onApprovalReceived.selector);
}
}
ERC165.sol 28 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
IERC1363.sol 92 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
/**
* @title IERC1363 Interface
* @author Vittorio Minacori (https://github.com/vittominacori)
* @dev Interface for a Payable Token contract as defined in
* https://eips.ethereum.org/EIPS/eip-1363
*/
interface IERC1363 is IERC20, IERC165 {
/**
* @notice Transfer tokens from `msg.sender` to another address and then call `onTransferReceived` on receiver
* @param recipient address The address which you want to transfer to
* @param amount uint256 The amount of tokens to be transferred
* @return true unless throwing
*/
function transferAndCall(address recipient, uint256 amount) external returns (bool);
/**
* @notice Transfer tokens from `msg.sender` to another address and then call `onTransferReceived` on receiver
* @param recipient address The address which you want to transfer to
* @param amount uint256 The amount of tokens to be transferred
* @param data bytes Additional data with no specified format, sent in call to `recipient`
* @return true unless throwing
*/
function transferAndCall(
address recipient,
uint256 amount,
bytes calldata data
) external returns (bool);
/**
* @notice Transfer tokens from one address to another and then call `onTransferReceived` on receiver
* @param sender address The address which you want to send tokens from
* @param recipient address The address which you want to transfer to
* @param amount uint256 The amount of tokens to be transferred
* @return true unless throwing
*/
function transferFromAndCall(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @notice Transfer tokens from one address to another and then call `onTransferReceived` on receiver
* @param sender address The address which you want to send tokens from
* @param recipient address The address which you want to transfer to
* @param amount uint256 The amount of tokens to be transferred
* @param data bytes Additional data with no specified format, sent in call to `recipient`
* @return true unless throwing
*/
function transferFromAndCall(
address sender,
address recipient,
uint256 amount,
bytes calldata data
) external returns (bool);
/**
* @notice Approve the passed address to spend the specified amount of tokens on behalf of msg.sender
* and then call `onApprovalReceived` on spender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param spender address The address which will spend the funds
* @param amount uint256 The amount of tokens to be spent
*/
function approveAndCall(address spender, uint256 amount) external returns (bool);
/**
* @notice Approve the passed address to spend the specified amount of tokens on behalf of msg.sender
* and then call `onApprovalReceived` on spender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param spender address The address which will spend the funds
* @param amount uint256 The amount of tokens to be spent
* @param data bytes Additional data with no specified format, sent in call to `spender`
*/
function approveAndCall(
address spender,
uint256 amount,
bytes calldata data
) external returns (bool);
}
IERC165.sol 24 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
IERC1363Spender.sol 30 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @title IERC1363Spender Interface
* @author Vittorio Minacori (https://github.com/vittominacori)
* @dev Interface for any contract that wants to support approveAndCall
* from ERC1363 token contracts as defined in
* https://eips.ethereum.org/EIPS/eip-1363
*/
interface IERC1363Spender {
/**
* @notice Handle the approval of ERC1363 tokens
* @dev Any ERC1363 smart contract calls this function on the recipient
* after an `approve`. This function MAY throw to revert and reject the
* approval. Return of other than the magic value MUST result in the
* transaction being reverted.
* Note: the token contract address is always the message sender.
* @param sender address The address which called `approveAndCall` function
* @param amount uint256 The amount of tokens to be spent
* @param data bytes Additional data with no specified format
* @return `bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))` unless throwing
*/
function onApprovalReceived(
address sender,
uint256 amount,
bytes calldata data
) external returns (bytes4);
}
IERC1363Receiver.sol 32 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @title IERC1363Receiver Interface
* @author Vittorio Minacori (https://github.com/vittominacori)
* @dev Interface for any contract that wants to support transferAndCall or transferFromAndCall
* from ERC1363 token contracts as defined in
* https://eips.ethereum.org/EIPS/eip-1363
*/
interface IERC1363Receiver {
/**
* @notice Handle the receipt of ERC1363 tokens
* @dev Any ERC1363 smart contract calls this function on the recipient
* after a `transfer` or a `transferFrom`. This function MAY throw to revert and reject the
* transfer. Return of other than the magic value MUST result in the
* transaction being reverted.
* Note: the token contract address is always the message sender.
* @param operator address The address which called `transferAndCall` or `transferFromAndCall` function
* @param sender address The address which are token transferred from
* @param amount uint256 The amount of tokens transferred
* @param data bytes Additional data with no specified format
* @return `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))` unless throwing
*/
function onTransferReceived(
address operator,
address sender,
uint256 amount,
bytes calldata data
) external returns (bytes4);
}
IERC20Metadata.sol 27 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
Read Contract
ADMIN_ROLE 0x75b238fc → bytes32
BURNER_ROLE 0x282c51f3 → bytes32
DEFAULT_ADMIN_ROLE 0xa217fddf → bytes32
DOMAIN_SEPARATOR 0x3644e515 → bytes32
MINTER_ROLE 0xd5391393 → bytes32
PERMIT_TYPEHASH 0x30adf81f → bytes32
allowance 0xdd62ed3e → uint256
balanceOf 0x70a08231 → uint256
decimals 0x313ce567 → uint8
getRoleAdmin 0x248a9ca3 → bytes32
hasRole 0x91d14854 → bool
hashPermit 0xdcdd8a04 → bytes32
isAdmin 0x24d7806c → bool
isBurner 0x4334614a → bool
isMinter 0xaa271e1a → bool
name 0x06fdde03 → string
nonces 0x7ecebe00 → uint256
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
totalSupply 0x18160ddd → uint256
verify 0x5025d1dd → bool
Write Contract 24 functions
These functions modify contract state and require a wallet transaction to execute.
addAdmin 0x70480275
address account
addBurner 0xf44637ba
address account
addMinter 0x983b2d56
address account
approve 0x095ea7b3
address spender
uint256 amount
returns: bool
approveAndCall 0x3177029f
address spender
uint256 amount
returns: bool
approveAndCall 0xcae9ca51
address spender
uint256 amount
bytes data
returns: bool
burn 0x9dc29fac
address account
uint256 amount
returns: bool
decreaseAllowance 0xa457c2d7
address spender
uint256 subtractedValue
returns: bool
grantRole 0x2f2ff15d
bytes32 role
address account
increaseAllowance 0x39509351
address spender
uint256 addedValue
returns: bool
mint 0x40c10f19
address account
uint256 amount
returns: bool
permit 0xd505accf
address owner
address spender
uint256 value
uint256 deadline
uint8 v
bytes32 r
bytes32 s
removeAdmin 0x1785f53c
address account
removeBurner 0x02846858
address account
removeMinter 0x3092afd5
address account
renounceRole 0x36568abe
bytes32 role
address account
revokeRole 0xd547741f
bytes32 role
address account
transfer 0xa9059cbb
address recipient
uint256 amount
returns: bool
transferAdmin 0x75829def
address newAdmin
transferAndCall 0x1296ee62
address recipient
uint256 amount
returns: bool
transferAndCall 0x4000aea0
address recipient
uint256 amount
bytes data
returns: bool
transferFrom 0x23b872dd
address sender
address recipient
uint256 amount
returns: bool
transferFromAndCall 0xc1d34b89
address sender
address recipient
uint256 amount
bytes data
returns: bool
transferFromAndCall 0xd8fbe994
address sender
address recipient
uint256 amount
returns: bool
Recent Transactions
No transactions found for this address