Address Contract Verified
Address
0x321C2fE4446C7c963dc41Dd58879AF648838f98D
Balance
0 ETH
Nonce
1
Code Size
10149 bytes
Creator
0x294CB241...138e at tx 0x66fe8b59...53adc5
Indexed Transactions
1 (24,436,270 → 24,436,270)
Gas Used (indexed)
57,016
Contract Bytecode
10149 bytes
0x608060405234801561001057600080fd5b50600436106101cf5760003560e01c80636fcfff4511610104578063a9059cbb116100a2578063dd62ed3e11610071578063dd62ed3e146103a7578063e7a324dc146103ba578063f1127ed8146103c2578063fca3b5aa146103e3576101cf565b8063a9059cbb1461035b578063b4b5ea571461036e578063c3cda52014610381578063d505accf14610394576101cf565b8063782d6fe1116100de578063782d6fe11461030d5780637ecebe001461032d57806395d89b4114610340578063a457c2d714610348576101cf565b80636fcfff45146102df57806370a08231146102f257806376c71ca114610305576101cf565b806330b36cef1161017157806340c10f191161014b57806340c10f191461028f578063587cde1e146102a45780635c11d62f146102b75780635c19a95c146102cc576101cf565b806330b36cef1461025f578063313ce56714610267578063395093511461027c576101cf565b806318160ddd116101ad57806318160ddd1461022757806320606b701461023c57806323b872dd1461024457806330adf81f14610257576101cf565b806306fdde03146101d457806307546172146101f2578063095ea7b314610207575b600080fd5b6101dc6103f6565b6040516101e99190611ebe565b60405180910390f35b6101fa610419565b6040516101e99190611de2565b61021a610215366004611d09565b610428565b6040516101e99190611e10565b61022f61047a565b6040516101e99190611e1b565b61022f610480565b61021a610252366004611c65565b6104a4565b61022f6105eb565b61022f61060f565b61026f610615565b6040516101e99190612458565b61021a61028a366004611d09565b61061a565b6102a261029d366004611d09565b6106b1565b005b6101fa6102b2366004611c19565b6108f5565b6102bf610910565b6040516101e99190612428565b6102a26102da366004611c19565b610918565b6102bf6102ed366004611c19565b610925565b61022f610300366004611c19565b61093d565b61026f610965565b61032061031b366004611d09565b61096a565b6040516101e99190612466565b61022f61033b366004611c19565b610b78565b6101dc610b8a565b61021a610356366004611d09565b610ba9565b61021a610369366004611d09565b610c3b565b61032061037c366004611c19565b610c6d565b6102a261038f366004611d32565b610cde565b6102a26103a2366004611ca0565b610ee3565b61022f6103b5366004611c33565b6111e4565b61022f611218565b6103d56103d0366004611d89565b61123c565b6040516101e9929190612439565b6102a26103f1366004611c19565b611271565b60405180604001604052806007815260200166086e4f2e0e8caf60cb1b81525081565b6001546001600160a01b031681565b60008060001983141561043e5750600019610463565b6104608360405180606001604052806024815260200161257d60249139611304565b90505b61046e338583611333565b60019150505b92915050565b60005481565b7f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a86681565b6001600160a01b03831660009081526003602090815260408083203380855290835281842054825160608101909352602480845291936001600160601b039091169285926104fc928892919061257d90830139611304565b9050866001600160a01b0316836001600160a01b03161415801561052957506001600160601b0382811614155b156105d357600061055383836040518060600160405280603c81526020016124c4603c91396113fd565b6001600160a01b038981166000818152600360209081526040808320948a16808452949091529081902080546001600160601b0319166001600160601b0386161790555192935090917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906105c9908590612466565b60405180910390a3505b6105de87878361143c565b5060019695505050505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b60025481565b601281565b6000806000198314156106305750600019610655565b610652836040518060600160405280602e81526020016125a1602e9139611304565b90505b3360008181526003602090815260408083206001600160a01b038916845282529182902054825160608101909352603180845261046e949389936106ac936001600160601b03169288929161263d9083013961160b565b611333565b6001546001600160a01b031633146106e45760405162461bcd60e51b81526004016106db90612095565b60405180910390fd5b6002544210156107065760405162461bcd60e51b81526004016106db906122cf565b6001600160a01b03821661072c5760405162461bcd60e51b81526004016106db9061215c565b6001600160a01b0382163014156107555760405162461bcd60e51b81526004016106db9061210f565b610763426301e13380611647565b600281905550600061078d8260405180606001604052806021815260200161274f60219139611304565b90506107a96107a2600054600260ff166116a1565b60646116fa565b816001600160601b031611156107d15760405162461bcd60e51b81526004016106db90611fcf565b6108076107e9600054836001600160601b0316611647565b6040518060600160405280602681526020016126cf60269139611304565b6001600160601b0390811660009081556001600160a01b038516815260046020908152604091829020548251606081019093526024808452610859949190911692859290919061272b9083013961160b565b6001600160a01b03841660008181526004602052604080822080546001600160601b0319166001600160601b03959095169490941790935591519091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906108c3908590612466565b60405180910390a36001600160a01b038084166000908152600560205260408120546108f092168361173c565b505050565b6005602052600090815260409020546001600160a01b031681565b6301e1338081565b61092233826118ce565b50565b60076020526000908152604090205463ffffffff1681565b6001600160a01b0381166000908152600460205260409020546001600160601b03165b919050565b600281565b600043821061098b5760405162461bcd60e51b81526004016106db90611f52565b6001600160a01b03831660009081526007602052604090205463ffffffff16806109b9576000915050610474565b6001600160a01b038416600090815260066020908152604080832063ffffffff600019860181168552925290912054168310610a35576001600160a01b03841660009081526006602090815260408083206000199490940163ffffffff1683529290522054600160201b90046001600160601b03169050610474565b6001600160a01b038416600090815260066020908152604080832083805290915290205463ffffffff16831015610a70576000915050610474565b600060001982015b8163ffffffff168163ffffffff161115610b3357600282820363ffffffff16048103610aa2611bda565b506001600160a01b038716600090815260066020908152604080832063ffffffff858116855290835292819020815180830190925254928316808252600160201b9093046001600160601b03169181019190915290871415610b0e576020015194506104749350505050565b805163ffffffff16871115610b2557819350610b2c565b6001820392505b5050610a78565b506001600160a01b038516600090815260066020908152604080832063ffffffff909416835292905220546001600160601b03600160201b9091041691505092915050565b60086020526000908152604090205481565b60405180604001604052806003815260200162086a8b60eb1b81525081565b600080600019831415610bbf5750600019610be4565b610be1836040518060600160405280602e815260200161266e602e9139611304565b90505b3360008181526003602090815260408083206001600160a01b038916845282529182902054825160608101909352603680845261046e949389936106ac936001600160601b0316928892916126f5908301396113fd565b600080610c608360405180606001604052806025815260200161253560259139611304565b905061046e33858361143c565b6001600160a01b03811660009081526007602052604081205463ffffffff1680610c98576000610cd7565b6001600160a01b0383166000908152600660209081526040808320600019850163ffffffff168452909152902054600160201b90046001600160601b03165b9392505050565b604080518082019091526007815266086e4f2e0e8caf60cb1b60209091015260007f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a8667fad54f334581c65b3f180030ce9a224cad2b532970cc454be7d304652c4921dd8610d49611958565b30604051602001610d5d9493929190611e7c565b60405160208183030381529060405280519060200120905060007fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf888888604051602001610dae9493929190611e58565b60405160208183030381529060405280519060200120905060008282604051602001610ddb929190611dc7565b604051602081830303815290604052805190602001209050600060018288888860405160008152602001604052604051610e189493929190611ea0565b6020604051602081039080840390855afa158015610e3a573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116610e6d5760405162461bcd60e51b81526004016106db90612006565b6001600160a01b03811660009081526008602052604090208054600181019091558914610eac5760405162461bcd60e51b81526004016106db90611f11565b87421115610ecc5760405162461bcd60e51b81526004016106db9061228a565b610ed6818b6118ce565b505050505b505050505050565b6000600019861415610ef85750600019610f1d565b610f1a8660405180606001604052806023815260200161255a60239139611304565b90505b604080518082019091526007815266086e4f2e0e8caf60cb1b60209091015260007f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a8667fad54f334581c65b3f180030ce9a224cad2b532970cc454be7d304652c4921dd8610f88611958565b30604051602001610f9c9493929190611e7c565b60408051601f1981840301815282825280516020918201206001600160a01b038d16600090815260088352928320805460018101909155909450919261100e927f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9928e928e928e9290918e9101611e24565b6040516020818303038152906040528051906020012090506000828260405160200161103b929190611dc7565b6040516020818303038152906040528051906020012090506000600182898989604051600081526020016040526040516110789493929190611ea0565b6020604051602081039080840390855afa15801561109a573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166110cd5760405162461bcd60e51b81526004016106db90611f98565b8b6001600160a01b0316816001600160a01b0316146110fe5760405162461bcd60e51b81526004016106db90612207565b8842111561111e5760405162461bcd60e51b81526004016106db906120d8565b84600360008e6001600160a01b03166001600160a01b0316815260200190815260200160002060008d6001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a8154816001600160601b0302191690836001600160601b031602179055508a6001600160a01b03168c6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925876040516111ce9190612466565b60405180910390a3505050505050505050505050565b6001600160a01b0391821660009081526003602090815260408083209390941682529190915220546001600160601b031690565b7fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf81565b600660209081526000928352604080842090915290825290205463ffffffff811690600160201b90046001600160601b031682565b6001546001600160a01b0316331461129b5760405162461bcd60e51b81526004016106db90612311565b6001546040517f3b0007eb941cf645526cbb3a4fdaecda9d28ce4843167d9263b536a1f1edc0f6916112da916001600160a01b03909116908490611df6565b60405180910390a1600180546001600160a01b0319166001600160a01b0392909216919091179055565b600081600160601b841061132b5760405162461bcd60e51b81526004016106db9190611ebe565b509192915050565b6001600160a01b0383166113595760405162461bcd60e51b81526004016106db9061223e565b6001600160a01b03821661137f5760405162461bcd60e51b81526004016106db9061204b565b6001600160a01b038381166000818152600360209081526040808320948716808452949091529081902080546001600160601b0319166001600160601b038616179055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906113f0908590612466565b60405180910390a3505050565b6000836001600160601b0316836001600160601b0316111582906114345760405162461bcd60e51b81526004016106db9190611ebe565b505050900390565b6001600160a01b0383166114625760405162461bcd60e51b81526004016106db906123cb565b6001600160a01b0382166114885760405162461bcd60e51b81526004016106db906121aa565b6001600160a01b0382163014156114b15760405162461bcd60e51b81526004016106db9061236e565b6001600160a01b0383166000908152600460209081526040918290205482516060810190935260358084526114fc936001600160601b039092169285929190612500908301396113fd565b6001600160a01b03848116600090815260046020908152604080832080546001600160601b0319166001600160601b0396871617905592861682529082902054825160608101909352602f80845261156494919091169285929091906124959083013961160b565b6001600160a01b038381166000818152600460205260409081902080546001600160601b0319166001600160601b0395909516949094179093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906115d1908590612466565b60405180910390a36001600160a01b038084166000908152600560205260408082205485841683529120546108f09291821691168361173c565b6000838301826001600160601b03808716908316101561163e5760405162461bcd60e51b81526004016106db9190611ebe565b50949350505050565b600082820183811015610cd7576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6000826116b057506000610474565b828202828482816116bd57fe5b0414610cd75760405162461bcd60e51b815260040180806020018281038252602181526020018061261c6021913960400191505060405180910390fd5b6000610cd783836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061195c565b816001600160a01b0316836001600160a01b03161415801561176757506000816001600160601b0316115b156108f0576001600160a01b0383161561181f576001600160a01b03831660009081526007602052604081205463ffffffff1690816117a75760006117e6565b6001600160a01b0385166000908152600660209081526040808320600019860163ffffffff168452909152902054600160201b90046001600160601b03165b9050600061180d82856040518060600160405280602781526020016125cf602791396113fd565b905061181b868484846119fe565b5050505b6001600160a01b038216156108f0576001600160a01b03821660009081526007602052604081205463ffffffff16908161185a576000611899565b6001600160a01b0384166000908152600660209081526040808320600019860163ffffffff168452909152902054600160201b90046001600160601b03165b905060006118c082856040518060600160405280602681526020016125f66026913961160b565b9050610edb858484846119fe565b6001600160a01b03808316600081815260056020818152604080842080546004845282862054949093528787166001600160a01b031984168117909155905191909516946001600160601b039092169391928592917f3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f9190a461195282848361173c565b50505050565b4690565b600081836119e85760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156119ad578181015183820152602001611995565b50505050905090810190601f1680156119da5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385816119f457fe5b0495945050505050565b6000611a224360405180606001604052806033815260200161269c60339139611bb3565b905060008463ffffffff16118015611a6b57506001600160a01b038516600090815260066020908152604080832063ffffffff6000198901811685529252909120548282169116145b15611aca576001600160a01b0385166000908152600660209081526040808320600019880163ffffffff168452909152902080546fffffffffffffffffffffffff000000001916600160201b6001600160601b03851602179055611b69565b60408051808201825263ffffffff80841682526001600160601b0380861660208085019182526001600160a01b038b166000818152600683528781208c871682528352878120965187549451909516600160201b026fffffffffffffffffffffffff000000001995871663ffffffff19958616179590951694909417909555938252600790935292909220805460018801909316929091169190911790555b846001600160a01b03167fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a7248484604051611ba492919061247a565b60405180910390a25050505050565b600081600160201b841061132b5760405162461bcd60e51b81526004016106db9190611ebe565b604080518082019091526000808252602082015290565b80356001600160a01b038116811461096057600080fd5b803560ff8116811461096057600080fd5b600060208284031215611c2a578081fd5b610cd782611bf1565b60008060408385031215611c45578081fd5b611c4e83611bf1565b9150611c5c60208401611bf1565b90509250929050565b600080600060608486031215611c79578081fd5b611c8284611bf1565b9250611c9060208501611bf1565b9150604084013590509250925092565b600080600080600080600060e0888a031215611cba578283fd5b611cc388611bf1565b9650611cd160208901611bf1565b95506040880135945060608801359350611ced60808901611c08565b925060a0880135915060c0880135905092959891949750929550565b60008060408385031215611d1b578182fd5b611d2483611bf1565b946020939093013593505050565b60008060008060008060c08789031215611d4a578182fd5b611d5387611bf1565b95506020870135945060408701359350611d6f60608801611c08565b92506080870135915060a087013590509295509295509295565b60008060408385031215611d9b578182fd5b611da483611bf1565b9150602083013563ffffffff81168114611dbc578182fd5b809150509250929050565b61190160f01b81526002810192909252602282015260420190565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b901515815260200190565b90815260200190565b9586526001600160a01b0394851660208701529290931660408501526060840152608083019190915260a082015260c00190565b9384526001600160a01b039290921660208401526040830152606082015260800190565b938452602084019290925260408301526001600160a01b0316606082015260800190565b93845260ff9290921660208401526040830152606082015260800190565b6000602080835283518082850152825b81811015611eea57858101830151858201604001528201611ece565b81811115611efb5783604083870101525b50601f01601f1916929092016040019392505050565b60208082526021908201527f4374783a3a64656c656761746542795369673a20696e76616c6964206e6f6e636040820152606560f81b606082015260800190565b60208082526026908201527f4374783a3a6765745072696f72566f7465733a206e6f742079657420646574656040820152651c9b5a5b995960d21b606082015260800190565b6020808252601e908201527f4374783a3a7065726d69743a20696e76616c6964207369676e61747572650000604082015260600190565b6020808252601c908201527f4374783a3a6d696e743a206578636565646564206d696e742063617000000000604082015260600190565b60208082526025908201527f4374783a3a64656c656761746542795369673a20696e76616c6964207369676e604082015264617475726560d81b606082015260800190565b6020808252602a908201527f4374783a3a5f617070726f76653a20617070726f766520746f20746865207a65604082015269726f206164647265737360b01b606082015260800190565b60208082526023908201527f4374783a3a6d696e743a206f6e6c7920746865206d696e7465722063616e206d6040820152621a5b9d60ea1b606082015260800190565b6020808252601e908201527f4374783a3a7065726d69743a207369676e617475726520657870697265640000604082015260600190565b6020808252602d908201527f4374783a3a6d696e743a2063616e6e6f74207472616e7366657220746f20746860408201526c6520437478206164647265737360981b606082015260800190565b6020808252602e908201527f4374783a3a6d696e743a2063616e6e6f74207472616e7366657220746f20746860408201526d65207a65726f206164647265737360901b606082015260800190565b60208082526039908201527f4374783a3a5f7472616e73666572546f6b656e733a2063616e6e6f742074726160408201527f6e7366657220746f20746865207a65726f206164647265737300000000000000606082015260800190565b60208082526019908201527f4374783a3a7065726d69743a20756e617574686f72697a656400000000000000604082015260600190565b6020808252602c908201527f4374783a3a5f617070726f76653a20617070726f76652066726f6d207468652060408201526b7a65726f206164647265737360a01b606082015260800190565b60208082526025908201527f4374783a3a64656c656761746542795369673a207369676e61747572652065786040820152641c1a5c995960da1b606082015260800190565b60208082526022908201527f4374783a3a6d696e743a206d696e74696e67206e6f7420616c6c6f7765642079604082015261195d60f21b606082015260800190565b6020808252603d908201527f4374783a3a7365744d696e7465723a206f6e6c7920746865206d696e7465722060408201527f63616e206368616e676520746865206d696e7465722061646472657373000000606082015260800190565b60208082526038908201527f4374783a3a5f7472616e73666572546f6b656e733a2063616e6e6f742074726160408201527f6e7366657220746f207468652043747820616464726573730000000000000000606082015260800190565b6020808252603b908201527f4374783a3a5f7472616e73666572546f6b656e733a2063616e6e6f742074726160408201527f6e736665722066726f6d20746865207a65726f20616464726573730000000000606082015260800190565b63ffffffff91909116815260200190565b63ffffffff9290921682526001600160601b0316602082015260400190565b60ff91909116815260200190565b6001600160601b0391909116815260200190565b6001600160601b039283168152911660208201526040019056fe4374783a3a5f7472616e73666572546f6b656e733a207472616e7366657220616d6f756e74206f766572666c6f77734374783a3a7472616e7366657246726f6d3a207472616e7366657220616d6f756e742065786365656473207370656e64657220616c6c6f77616e63654374783a3a5f7472616e73666572546f6b656e733a207472616e7366657220616d6f756e7420657863656564732062616c616e63654374783a3a7472616e736665723a20616d6f756e74206578636565647320393620626974734374783a3a7065726d69743a20616d6f756e74206578636565647320393620626974734374783a3a617070726f76653a20616d6f756e74206578636565647320393620626974734374783a3a696e637265617365416c6c6f77616e63653a20616d6f756e74206578636565647320393620626974734374783a3a5f6d6f7665566f7465733a20766f746520616d6f756e7420756e646572666c6f77734374783a3a5f6d6f7665566f7465733a20766f746520616d6f756e74206f766572666c6f7773536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774374783a3a696e637265617365416c6c6f77616e63653a207472616e7366657220616d6f756e74206f766572666c6f77734374783a3a6465637265617365416c6c6f77616e63653a20616d6f756e74206578636565647320393620626974734374783a3a5f7772697465436865636b706f696e743a20626c6f636b206e756d626572206578636565647320333220626974734374783a3a6d696e743a20746f74616c537570706c79206578636565647320393620626974734374783a3a6465637265617365416c6c6f77616e63653a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726f4374783a3a6d696e743a207472616e7366657220616d6f756e74206f766572666c6f77734374783a3a6d696e743a20616d6f756e7420657863656564732039362062697473a2646970667358221220f223d1ce1c284bbd7e147e3e03bfcf025f37e8e4f96a729f30e37c811cb6cdc364736f6c63430007050033
Verified Source Code Full Match
Compiler: v0.7.5+commit.eb77ed08
EVM: istanbul
Optimization: Yes (200 runs)
Ctx.sol 671 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.7.5;
pragma experimental ABIEncoderV2;
import "@openzeppelin/contracts/math/SafeMath.sol";
contract Ctx {
/// @notice EIP-20 token name for this token
string public constant name = "Cryptex";
/// @notice EIP-20 token symbol for this token
string public constant symbol = "CTX";
/// @notice EIP-20 token decimals for this token
uint8 public constant decimals = 18;
/// @notice Total number of tokens in circulation
uint256 public totalSupply = 10000000e18; // 10 million CTX
/// @notice Address which may mint new tokens
address public minter;
/// @notice The timestamp after which minting may occur
uint256 public mintingAllowedAfter;
/// @notice Minimum time between mints
uint32 public constant minimumTimeBetweenMints = 1 days * 365;
/// @notice Cap on the percentage of totalSupply that can be minted at each mint
uint8 public constant mintCap = 2;
/// @dev Allowance amounts on behalf of others
mapping(address => mapping(address => uint96)) internal allowances;
/// @dev Official record of token balances for each account
mapping(address => uint96) internal balances;
/// @notice A record of each accounts delegate
mapping(address => address) public delegates;
/// @notice A checkpoint for marking number of votes from a given block
struct Checkpoint {
uint32 fromBlock;
uint96 votes;
}
/// @notice A record of votes checkpoints for each account, by index
mapping(address => mapping(uint32 => Checkpoint)) public checkpoints;
/// @notice The number of checkpoints for each account
mapping(address => uint32) public numCheckpoints;
/// @notice The EIP-712 typehash for the contract's domain
bytes32 public constant DOMAIN_TYPEHASH =
keccak256(
"EIP712Domain(string name,uint256 chainId,address verifyingContract)"
);
/// @notice The EIP-712 typehash for the delegation struct used by the contract
bytes32 public constant DELEGATION_TYPEHASH =
keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
/// @notice The EIP-712 typehash for the permit struct used by the contract
bytes32 public constant PERMIT_TYPEHASH =
keccak256(
"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"
);
/// @notice A record of states for signing / validating signatures
mapping(address => uint256) public nonces;
/// @notice An event thats emitted when the minter address is changed
event MinterChanged(address minter, address newMinter);
/// @notice An event thats emitted when an account changes its delegate
event DelegateChanged(
address indexed delegator,
address indexed fromDelegate,
address indexed toDelegate
);
/// @notice An event thats emitted when a delegate account's vote balance changes
event DelegateVotesChanged(
address indexed delegate,
uint256 previousBalance,
uint256 newBalance
);
/// @notice The standard EIP-20 transfer event
event Transfer(address indexed from, address indexed to, uint256 amount);
/// @notice The standard EIP-20 approval event
event Approval(
address indexed owner,
address indexed spender,
uint256 amount
);
/**
* @notice Construct a new Ctx token
* @param account The initial account to grant all the tokens
* @param minter_ The account with minting ability
* @param mintingAllowedAfter_ The timestamp after which minting may occur
*/
constructor(
address account,
address minter_,
uint256 mintingAllowedAfter_
) {
require(
mintingAllowedAfter_ >= block.timestamp,
"Ctx::constructor: minting can only begin after deployment"
);
balances[account] = uint96(totalSupply);
emit Transfer(address(0), account, totalSupply);
minter = minter_;
emit MinterChanged(address(0), minter);
mintingAllowedAfter = mintingAllowedAfter_;
}
/**
* @notice Change the minter address
* @param minter_ The address of the new minter
*/
function setMinter(address minter_) external {
require(
msg.sender == minter,
"Ctx::setMinter: only the minter can change the minter address"
);
emit MinterChanged(minter, minter_);
minter = minter_;
}
/**
* @notice Mint new tokens
* @param dst The address of the destination account
* @param rawAmount The number of tokens to be minted
*/
function mint(address dst, uint256 rawAmount) external {
require(msg.sender == minter, "Ctx::mint: only the minter can mint");
require(
block.timestamp >= mintingAllowedAfter,
"Ctx::mint: minting not allowed yet"
);
require(
dst != address(0),
"Ctx::mint: cannot transfer to the zero address"
);
require(
dst != address(this),
"Ctx::mint: cannot transfer to the Ctx address"
);
// record the mint
mintingAllowedAfter = SafeMath.add(
block.timestamp,
minimumTimeBetweenMints
);
// mint the amount
uint96 amount = safe96(rawAmount, "Ctx::mint: amount exceeds 96 bits");
require(
amount <= SafeMath.div(SafeMath.mul(totalSupply, mintCap), 100),
"Ctx::mint: exceeded mint cap"
);
totalSupply = safe96(
SafeMath.add(totalSupply, amount),
"Ctx::mint: totalSupply exceeds 96 bits"
);
// transfer the amount to the recipient
balances[dst] = add96(
balances[dst],
amount,
"Ctx::mint: transfer amount overflows"
);
emit Transfer(address(0), dst, amount);
// move delegates
_moveDelegates(address(0), delegates[dst], amount);
}
/**
* @notice Get the number of tokens `spender` is approved to spend on behalf of `account`
* @param account The address of the account holding the funds
* @param spender The address of the account spending the funds
* @return The number of tokens approved
*/
function allowance(address account, address spender)
external
view
returns (uint256)
{
return allowances[account][spender];
}
/**
* @notice Sets `amount` as the allowance of `spender` over the `owner` s tokens.
* @param owner The address of the caller.
* @param spender The address of the account which may transfer tokens
* @param amount The number of tokens that are approved
* @dev This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
* @dev Emits an Approval event.
* @dev owner cannot be the zero address.
* @dev spender cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint96 amount
) internal virtual {
require(
owner != address(0),
"Ctx::_approve: approve from the zero address"
);
require(
spender != address(0),
"Ctx::_approve: approve to the zero address"
);
allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @notice Approve `spender` to transfer up to `amount` from `src`
* @param spender The address of the account which may transfer tokens
* @param rawAmount The number of tokens that are approved (2^256-1 means infinite)
* @dev This will overwrite the approval amount for `spender`
* and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)
* @return Whether or not the approval succeeded
*/
function approve(address spender, uint256 rawAmount) external returns (bool) {
uint96 amount;
if (rawAmount == uint256(-1)) {
amount = uint96(-1);
} else {
amount = safe96(rawAmount, "Ctx::approve: amount exceeds 96 bits");
}
_approve(msg.sender, spender, amount);
return true;
}
/**
* @notice Atomically increases the allowance granted to `spender` by the caller.
* @param spender address
* @param addedValue uint256 raw
* @dev This is an alternative to {approve} that can be used as a mitigation for
* problems of Allowance Double-Spend Exploit.
* @dev Emits Approval event indicating the updated allowance.
* @dev spender cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue)
public
virtual
returns (bool)
{
uint96 amount;
if (addedValue == uint256(-1)) {
amount = uint96(-1);
} else {
amount = safe96(
addedValue,
"Ctx::increaseAllowance: amount exceeds 96 bits"
);
}
_approve(
msg.sender,
spender,
add96(
allowances[msg.sender][spender],
amount,
"Ctx::increaseAllowance: transfer amount overflows"
)
);
return true;
}
/**
* @notice Atomically decreases the allowance granted to `spender` by the caller.
* @param spender address
* @param subtractedValue uint256 raw
* @dev This is an alternative to {approve} that can be used as a mitigation for
* problems of Allowance Double-Spend Exploit.
* @dev Emits an Approval event indicating the updated allowance.
* @dev spender cannot be the sero address
* @dev spender must have allowance for the caller of at least subtractedValue
*/
function decreaseAllowance(address spender, uint256 subtractedValue)
public
virtual
returns (bool)
{
uint96 amount;
if (subtractedValue == uint256(-1)) {
amount = uint96(-1);
} else {
amount = safe96(
subtractedValue,
"Ctx::decreaseAllowance: amount exceeds 96 bits"
);
}
_approve(
msg.sender,
spender,
sub96(
allowances[msg.sender][spender],
amount,
"Ctx::decreaseAllowance: decreased allowance below zero"
)
);
return true;
}
/**
* @notice Triggers an approval from owner to spends
* @param owner The address to approve from
* @param spender The address to be approved
* @param rawAmount The number of tokens that are approved (2^256-1 means infinite)
* @param deadline The time at which to expire the signature
* @param v The recovery byte of the signature
* @param r Half of the ECDSA signature pair
* @param s Half of the ECDSA signature pair
*/
function permit(
address owner,
address spender,
uint256 rawAmount,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external {
uint96 amount;
if (rawAmount == uint256(-1)) {
amount = uint96(-1);
} else {
amount = safe96(rawAmount, "Ctx::permit: amount exceeds 96 bits");
}
bytes32 domainSeparator =
keccak256(
abi.encode(
DOMAIN_TYPEHASH,
keccak256(bytes(name)),
getChainId(),
address(this)
)
);
bytes32 structHash =
keccak256(
abi.encode(
PERMIT_TYPEHASH,
owner,
spender,
rawAmount,
nonces[owner]++,
deadline
)
);
bytes32 digest =
keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
address signatory = ecrecover(digest, v, r, s);
require(signatory != address(0), "Ctx::permit: invalid signature");
require(signatory == owner, "Ctx::permit: unauthorized");
require(block.timestamp <= deadline, "Ctx::permit: signature expired");
allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @notice Get the number of tokens held by the `account`
* @param account The address of the account to get the balance of
* @return The number of tokens held
*/
function balanceOf(address account) external view returns (uint256) {
return balances[account];
}
/**
* @notice Transfer `amount` tokens from `msg.sender` to `dst`
* @param dst The address of the destination account
* @param rawAmount The number of tokens to transfer
* @return Whether or not the transfer succeeded
*/
function transfer(address dst, uint256 rawAmount) external returns (bool) {
uint96 amount = safe96(rawAmount, "Ctx::transfer: amount exceeds 96 bits");
_transferTokens(msg.sender, dst, amount);
return true;
}
/**
* @notice Transfer `amount` tokens from `src` to `dst`
* @param src The address of the source account
* @param dst The address of the destination account
* @param rawAmount The number of tokens to transfer
* @return Whether or not the transfer succeeded
*/
function transferFrom(
address src,
address dst,
uint256 rawAmount
) external returns (bool) {
address spender = msg.sender;
uint96 spenderAllowance = allowances[src][spender];
uint96 amount = safe96(rawAmount, "Ctx::approve: amount exceeds 96 bits");
if (spender != src && spenderAllowance != uint96(-1)) {
uint96 newAllowance =
sub96(
spenderAllowance,
amount,
"Ctx::transferFrom: transfer amount exceeds spender allowance"
);
allowances[src][spender] = newAllowance;
emit Approval(src, spender, newAllowance);
}
_transferTokens(src, dst, amount);
return true;
}
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegatee The address to delegate votes to
*/
function delegate(address delegatee) public {
return _delegate(msg.sender, delegatee);
}
/**
* @notice Delegates votes from signatory to `delegatee`
* @param delegatee The address to delegate votes to
* @param nonce The contract state required to match the signature
* @param expiry The time at which to expire the signature
* @param v The recovery byte of the signature
* @param r Half of the ECDSA signature pair
* @param s Half of the ECDSA signature pair
*/
function delegateBySig(
address delegatee,
uint256 nonce,
uint256 expiry,
uint8 v,
bytes32 r,
bytes32 s
) public {
bytes32 domainSeparator =
keccak256(
abi.encode(
DOMAIN_TYPEHASH,
keccak256(bytes(name)),
getChainId(),
address(this)
)
);
bytes32 structHash =
keccak256(abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry));
bytes32 digest =
keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
address signatory = ecrecover(digest, v, r, s);
require(signatory != address(0), "Ctx::delegateBySig: invalid signature");
require(nonce == nonces[signatory]++, "Ctx::delegateBySig: invalid nonce");
require(block.timestamp <= expiry, "Ctx::delegateBySig: signature expired");
return _delegate(signatory, delegatee);
}
/**
* @notice Gets the current votes balance for `account`
* @param account The address to get votes balance
* @return The number of current votes for `account`
*/
function getCurrentVotes(address account) external view returns (uint96) {
uint32 nCheckpoints = numCheckpoints[account];
return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;
}
/**
* @notice Determine the prior number of votes for an account as of a block number
* @dev Block number must be a finalized block or else this function will revert to prevent misinformation.
* @param account The address of the account to check
* @param blockNumber The block number to get the vote balance at
* @return The number of votes the account had as of the given block
*/
function getPriorVotes(address account, uint256 blockNumber)
public
view
returns (uint96)
{
require(
blockNumber < block.number,
"Ctx::getPriorVotes: not yet determined"
);
uint32 nCheckpoints = numCheckpoints[account];
if (nCheckpoints == 0) {
return 0;
}
// First check most recent balance
if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {
return checkpoints[account][nCheckpoints - 1].votes;
}
// Next check implicit zero balance
if (checkpoints[account][0].fromBlock > blockNumber) {
return 0;
}
uint32 lower = 0;
uint32 upper = nCheckpoints - 1;
while (upper > lower) {
uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow
Checkpoint memory cp = checkpoints[account][center];
if (cp.fromBlock == blockNumber) {
return cp.votes;
} else if (cp.fromBlock < blockNumber) {
lower = center;
} else {
upper = center - 1;
}
}
return checkpoints[account][lower].votes;
}
function _delegate(address delegator, address delegatee) internal {
address currentDelegate = delegates[delegator];
uint96 delegatorBalance = balances[delegator];
delegates[delegator] = delegatee;
emit DelegateChanged(delegator, currentDelegate, delegatee);
_moveDelegates(currentDelegate, delegatee, delegatorBalance);
}
function _transferTokens(
address src,
address dst,
uint96 amount
) internal {
require(
src != address(0),
"Ctx::_transferTokens: cannot transfer from the zero address"
);
require(
dst != address(0),
"Ctx::_transferTokens: cannot transfer to the zero address"
);
require(
dst != address(this),
"Ctx::_transferTokens: cannot transfer to the Ctx address"
);
balances[src] = sub96(
balances[src],
amount,
"Ctx::_transferTokens: transfer amount exceeds balance"
);
balances[dst] = add96(
balances[dst],
amount,
"Ctx::_transferTokens: transfer amount overflows"
);
emit Transfer(src, dst, amount);
_moveDelegates(delegates[src], delegates[dst], amount);
}
function _moveDelegates(
address srcRep,
address dstRep,
uint96 amount
) internal {
if (srcRep != dstRep && amount > 0) {
if (srcRep != address(0)) {
uint32 srcRepNum = numCheckpoints[srcRep];
uint96 srcRepOld =
srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;
uint96 srcRepNew =
sub96(srcRepOld, amount, "Ctx::_moveVotes: vote amount underflows");
_writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);
}
if (dstRep != address(0)) {
uint32 dstRepNum = numCheckpoints[dstRep];
uint96 dstRepOld =
dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;
uint96 dstRepNew =
add96(dstRepOld, amount, "Ctx::_moveVotes: vote amount overflows");
_writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);
}
}
}
function _writeCheckpoint(
address delegatee,
uint32 nCheckpoints,
uint96 oldVotes,
uint96 newVotes
) internal {
uint32 blockNumber =
safe32(
block.number,
"Ctx::_writeCheckpoint: block number exceeds 32 bits"
);
if (
nCheckpoints > 0 &&
checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber
) {
checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;
} else {
checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes);
numCheckpoints[delegatee] = nCheckpoints + 1;
}
emit DelegateVotesChanged(delegatee, oldVotes, newVotes);
}
function safe32(uint256 n, string memory errorMessage)
internal
pure
returns (uint32)
{
require(n < 2**32, errorMessage);
return uint32(n);
}
function safe96(uint256 n, string memory errorMessage)
internal
pure
returns (uint96)
{
require(n < 2**96, errorMessage);
return uint96(n);
}
function add96(
uint96 a,
uint96 b,
string memory errorMessage
) internal pure returns (uint96) {
uint96 c = a + b;
require(c >= a, errorMessage);
return c;
}
function sub96(
uint96 a,
uint96 b,
string memory errorMessage
) internal pure returns (uint96) {
require(b <= a, errorMessage);
return a - b;
}
function getChainId() internal pure returns (uint256) {
uint256 chainId;
assembly {
chainId := chainid()
}
return chainId;
}
}
SafeMath.sol 159 lines
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// 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 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
Read Contract
DELEGATION_TYPEHASH 0xe7a324dc → bytes32
DOMAIN_TYPEHASH 0x20606b70 → bytes32
PERMIT_TYPEHASH 0x30adf81f → bytes32
allowance 0xdd62ed3e → uint256
balanceOf 0x70a08231 → uint256
checkpoints 0xf1127ed8 → uint32, uint96
decimals 0x313ce567 → uint8
delegates 0x587cde1e → address
getCurrentVotes 0xb4b5ea57 → uint96
getPriorVotes 0x782d6fe1 → uint96
minimumTimeBetweenMints 0x5c11d62f → uint32
mintCap 0x76c71ca1 → uint8
minter 0x07546172 → address
mintingAllowedAfter 0x30b36cef → uint256
name 0x06fdde03 → string
nonces 0x7ecebe00 → uint256
numCheckpoints 0x6fcfff45 → uint32
symbol 0x95d89b41 → string
totalSupply 0x18160ddd → uint256
Write Contract 10 functions
These functions modify contract state and require a wallet transaction to execute.
approve 0x095ea7b3
address spender
uint256 rawAmount
returns: bool
decreaseAllowance 0xa457c2d7
address spender
uint256 subtractedValue
returns: bool
delegate 0x5c19a95c
address delegatee
delegateBySig 0xc3cda520
address delegatee
uint256 nonce
uint256 expiry
uint8 v
bytes32 r
bytes32 s
increaseAllowance 0x39509351
address spender
uint256 addedValue
returns: bool
mint 0x40c10f19
address dst
uint256 rawAmount
permit 0xd505accf
address owner
address spender
uint256 rawAmount
uint256 deadline
uint8 v
bytes32 r
bytes32 s
setMinter 0xfca3b5aa
address minter_
transfer 0xa9059cbb
address dst
uint256 rawAmount
returns: bool
transferFrom 0x23b872dd
address src
address dst
uint256 rawAmount
returns: bool
Top Interactions
| Address | Txns | Sent | Received |
|---|---|---|---|
| 0xa03400E0...7687 | 1 | 1 |
Recent Transactions
|
| Hash | Block | Age | From/To | Value | |
|---|---|---|---|---|---|
| 0x1d5a0671...286d73 | 24,436,270 | IN | 0xa03400E0...7687 | 0 ETH |