Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- MasterNodes
- Optimization enabled
- true
- Compiler version
- v0.8.9+commit.e5eed63a
- Optimization runs
- 1000
- EVM Version
- default
- Verified at
- 2024-09-26T15:32:35.288911Z
Constructor Arguments
0x0000000000000000000000005f21e105678b337434580f00848af04f577e71f1
Arg [0] (address) : 0x5f21e105678b337434580f00848af04f577e71f1
Contract source code
// SPDX-License-Identifier: MIT pragma solidity ^0.8.9; contract MasterNodes{ event NodeAdded(address indexed _node); event NodeLocked(address indexed _node); event NodeUnlocked(address indexed _node); event NodeRemoved(address indexed _node); event PointsGranted(address indexed _node, uint _points); event AdminAdded(address indexed _admin); event AdminBlocked(address indexed _admin); uint public nodeCounter; struct Node { address owner; uint points; bool state; uint lastAwardTime; } mapping (uint => Node) public nodesListByIndex; mapping (address => uint) private nodesListByOwner; mapping (address => bool) public admins; constructor(address _firstAdmin) { admins[_firstAdmin] = true; emit AdminAdded(_firstAdmin); } modifier onlyAdmin { require(admins[msg.sender], "MasterNodes: User is not admin"); _; } function addAdmin (address _admin) public onlyAdmin { admins[_admin] = true; emit AdminAdded(_admin); } function blockAdmin (address _admin) public onlyAdmin { admins[_admin] = false; emit AdminBlocked(_admin); } function addNode (address _node) public onlyAdmin{ nodesListByOwner[_node] = nodeCounter; nodesListByIndex[nodeCounter].owner = _node; nodesListByIndex[nodeCounter].state = true; nodeCounter++; emit NodeAdded(_node); } function lockNode (address _node) public onlyAdmin{ nodesListByIndex[nodesListByOwner[_node]].state = false; emit NodeLocked(_node); } function unlockNode (address _node) public onlyAdmin{ nodesListByIndex[nodesListByOwner[_node]].state = true; emit NodeUnlocked(_node); } function removeNode (address _node) public onlyAdmin{ uint index = nodesListByOwner[_node]; delete(nodesListByIndex[index]); delete(nodesListByOwner[_node]); emit NodeRemoved(_node); } function useFreeNode (address _node, uint _index) public onlyAdmin{ nodesListByIndex[_index].owner = _node; nodesListByIndex[_index].state = true; nodesListByIndex[_index].lastAwardTime = block.timestamp; emit NodeAdded(_node); } function grantPoints (address _node, uint _points) public onlyAdmin { uint index = nodesListByOwner[_node]; require(block.timestamp > nodesListByIndex[index].lastAwardTime + 23 hours ); nodesListByIndex[index].lastAwardTime = block.timestamp; nodesListByIndex[index].points += _points; emit PointsGranted(_node, _points); } function listNodeByOwner (address _node) public view returns (Node memory) { return nodesListByIndex[nodesListByOwner[_node]]; } }
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_firstAdmin","internalType":"address"}]},{"type":"event","name":"AdminAdded","inputs":[{"type":"address","name":"_admin","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"AdminBlocked","inputs":[{"type":"address","name":"_admin","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"NodeAdded","inputs":[{"type":"address","name":"_node","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"NodeLocked","inputs":[{"type":"address","name":"_node","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"NodeRemoved","inputs":[{"type":"address","name":"_node","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"NodeUnlocked","inputs":[{"type":"address","name":"_node","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"PointsGranted","inputs":[{"type":"address","name":"_node","internalType":"address","indexed":true},{"type":"uint256","name":"_points","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"addAdmin","inputs":[{"type":"address","name":"_admin","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"addNode","inputs":[{"type":"address","name":"_node","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"admins","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"blockAdmin","inputs":[{"type":"address","name":"_admin","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"grantPoints","inputs":[{"type":"address","name":"_node","internalType":"address"},{"type":"uint256","name":"_points","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple","name":"","internalType":"struct MasterNodes.Node","components":[{"type":"address","name":"owner","internalType":"address"},{"type":"uint256","name":"points","internalType":"uint256"},{"type":"bool","name":"state","internalType":"bool"},{"type":"uint256","name":"lastAwardTime","internalType":"uint256"}]}],"name":"listNodeByOwner","inputs":[{"type":"address","name":"_node","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"lockNode","inputs":[{"type":"address","name":"_node","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"nodeCounter","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"owner","internalType":"address"},{"type":"uint256","name":"points","internalType":"uint256"},{"type":"bool","name":"state","internalType":"bool"},{"type":"uint256","name":"lastAwardTime","internalType":"uint256"}],"name":"nodesListByIndex","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"removeNode","inputs":[{"type":"address","name":"_node","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"unlockNode","inputs":[{"type":"address","name":"_node","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"useFreeNode","inputs":[{"type":"address","name":"_node","internalType":"address"},{"type":"uint256","name":"_index","internalType":"uint256"}]}]
Contract Creation Code
0x608060405234801561001057600080fd5b50604051610b86380380610b8683398101604081905261002f9161007e565b6001600160a01b038116600081815260036020526040808220805460ff19166001179055517f44d6d25963f097ad14f29f06854a01f575648a1ef82f30e562ccd3889717e3399190a2506100ae565b60006020828403121561009057600080fd5b81516001600160a01b03811681146100a757600080fd5b9392505050565b610ac9806100bd6000396000f3fe608060405234801561001057600080fd5b50600436106100d45760003560e01c806383abcfda11610081578063b2b99ec91161005b578063b2b99ec9146102ca578063f1ff6a1e146102dd578063f7b4883d146102f057600080fd5b806383abcfda1461029157806396911e7a146102a45780639d95f1cc146102b757600080fd5b80634bc07c53116100b25780634bc07c531461019d578063704802751461026957806380dd652b1461027e57600080fd5b80631ca02e63146100d957806338a995ed146100f5578063429b62e51461016a575b600080fd5b6100e260005481565b6040519081526020015b60405180910390f35b61013a6101033660046109b0565b600160208190526000918252604090912080549181015460028201546003909201546001600160a01b0390931692909160ff169084565b604080516001600160a01b03909516855260208501939093529015159183019190915260608201526080016100ec565b61018d6101783660046109e5565b60036020526000908152604090205460ff1681565b60405190151581526020016100ec565b61022b6101ab3660046109e5565b604080516080810182526000808252602082018190529181018290526060810191909152506001600160a01b03908116600090815260026020818152604080842054845260018083529381902081516080810183528154909616865293840154918501919091529082015460ff1615159083015260030154606082015290565b6040516100ec919081516001600160a01b03168152602080830151908201526040808301511515908201526060918201519181019190915260800190565b61027c6102773660046109e5565b610303565b005b61027c61028c3660046109e5565b6103b3565b61027c61029f366004610a07565b61046f565b61027c6102b2366004610a07565b610548565b61027c6102c53660046109e5565b610659565b61027c6102d83660046109e5565b610761565b61027c6102eb3660046109e5565b610850565b61027c6102fe3660046109e5565b6108f8565b3360009081526003602052604090205460ff166103675760405162461bcd60e51b815260206004820152601e60248201527f4d61737465724e6f6465733a2055736572206973206e6f742061646d696e000060448201526064015b60405180910390fd5b6001600160a01b038116600081815260036020526040808220805460ff19166001179055517f44d6d25963f097ad14f29f06854a01f575648a1ef82f30e562ccd3889717e3399190a250565b3360009081526003602052604090205460ff166104125760405162461bcd60e51b815260206004820152601e60248201527f4d61737465724e6f6465733a2055736572206973206e6f742061646d696e0000604482015260640161035e565b6001600160a01b0381166000818152600260208181526040808420548452600191829052808420909201805460ff19169091179055517f1b123bcf878d187698a3cdde9a0881b681babcd681b2cde1b473b8045f09b21a9190a250565b3360009081526003602052604090205460ff166104ce5760405162461bcd60e51b815260206004820152601e60248201527f4d61737465724e6f6465733a2055736572206973206e6f742061646d696e0000604482015260640161035e565b6000818152600160208190526040808320805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b038716908117825560028201805460ff1916909417909355426003909101555190917fb25d03aaf308d7291709be1ea28b800463cf3a9a4c4a5555d7333a964c1dfebd91a25050565b3360009081526003602052604090205460ff166105a75760405162461bcd60e51b815260206004820152601e60248201527f4d61737465724e6f6465733a2055736572206973206e6f742061646d696e0000604482015260640161035e565b6001600160a01b0382166000908152600260209081526040808320548084526001909252909120600301546105df9062014370610a60565b42116105ea57600080fd5b60008181526001602081905260408220426003820155018054849290610611908490610a60565b90915550506040518281526001600160a01b038416907fee024df340d648f807f11a9c96925f76feded85bcb87a26c2689a066d72049f29060200160405180910390a2505050565b3360009081526003602052604090205460ff166106b85760405162461bcd60e51b815260206004820152601e60248201527f4d61737465724e6f6465733a2055736572206973206e6f742061646d696e0000604482015260640161035e565b600080546001600160a01b038316808352600260208181526040808620859055938552600190819052838520805473ffffffffffffffffffffffffffffffffffffffff191690931790925583548452918320909101805460ff191690911790558054908061072583610a78565b90915550506040516001600160a01b038216907fb25d03aaf308d7291709be1ea28b800463cf3a9a4c4a5555d7333a964c1dfebd90600090a250565b3360009081526003602052604090205460ff166107c05760405162461bcd60e51b815260206004820152601e60248201527f4d61737465724e6f6465733a2055736572206973206e6f742061646d696e0000604482015260640161035e565b6001600160a01b038116600081815260026020818152604080842080548086526001808552838720805473ffffffffffffffffffffffffffffffffffffffff19168155908101879055808601805460ff191690556003018690558686529390925290839055519092917fcfc24166db4bb677e857cacabd1541fb2b30645021b27c5130419589b84db52b91a25050565b3360009081526003602052604090205460ff166108af5760405162461bcd60e51b815260206004820152601e60248201527f4d61737465724e6f6465733a2055736572206973206e6f742061646d696e0000604482015260640161035e565b6001600160a01b038116600081815260036020526040808220805460ff19169055517fb172b82abe077cdcfdf508ab80c083de4ed7930171cf16063f3d0624139433389190a250565b3360009081526003602052604090205460ff166109575760405162461bcd60e51b815260206004820152601e60248201527f4d61737465724e6f6465733a2055736572206973206e6f742061646d696e0000604482015260640161035e565b6001600160a01b03811660008181526002602081815260408084205484526001909152808320909101805460ff19169055517fb33eb89f1d4c76879efa22b299eb7d4b71660eb8bff678389cc0467f04a290799190a250565b6000602082840312156109c257600080fd5b5035919050565b80356001600160a01b03811681146109e057600080fd5b919050565b6000602082840312156109f757600080fd5b610a00826109c9565b9392505050565b60008060408385031215610a1a57600080fd5b610a23836109c9565b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60008219821115610a7357610a73610a31565b500190565b6000600019821415610a8c57610a8c610a31565b506001019056fea264697066735822122008deb3fb54f63c8b5cca3e5b5bbd95476041ba7da492a31624568dbc93ae711164736f6c634300080900330000000000000000000000005f21e105678b337434580f00848af04f577e71f1
Deployed ByteCode
0x608060405234801561001057600080fd5b50600436106100d45760003560e01c806383abcfda11610081578063b2b99ec91161005b578063b2b99ec9146102ca578063f1ff6a1e146102dd578063f7b4883d146102f057600080fd5b806383abcfda1461029157806396911e7a146102a45780639d95f1cc146102b757600080fd5b80634bc07c53116100b25780634bc07c531461019d578063704802751461026957806380dd652b1461027e57600080fd5b80631ca02e63146100d957806338a995ed146100f5578063429b62e51461016a575b600080fd5b6100e260005481565b6040519081526020015b60405180910390f35b61013a6101033660046109b0565b600160208190526000918252604090912080549181015460028201546003909201546001600160a01b0390931692909160ff169084565b604080516001600160a01b03909516855260208501939093529015159183019190915260608201526080016100ec565b61018d6101783660046109e5565b60036020526000908152604090205460ff1681565b60405190151581526020016100ec565b61022b6101ab3660046109e5565b604080516080810182526000808252602082018190529181018290526060810191909152506001600160a01b03908116600090815260026020818152604080842054845260018083529381902081516080810183528154909616865293840154918501919091529082015460ff1615159083015260030154606082015290565b6040516100ec919081516001600160a01b03168152602080830151908201526040808301511515908201526060918201519181019190915260800190565b61027c6102773660046109e5565b610303565b005b61027c61028c3660046109e5565b6103b3565b61027c61029f366004610a07565b61046f565b61027c6102b2366004610a07565b610548565b61027c6102c53660046109e5565b610659565b61027c6102d83660046109e5565b610761565b61027c6102eb3660046109e5565b610850565b61027c6102fe3660046109e5565b6108f8565b3360009081526003602052604090205460ff166103675760405162461bcd60e51b815260206004820152601e60248201527f4d61737465724e6f6465733a2055736572206973206e6f742061646d696e000060448201526064015b60405180910390fd5b6001600160a01b038116600081815260036020526040808220805460ff19166001179055517f44d6d25963f097ad14f29f06854a01f575648a1ef82f30e562ccd3889717e3399190a250565b3360009081526003602052604090205460ff166104125760405162461bcd60e51b815260206004820152601e60248201527f4d61737465724e6f6465733a2055736572206973206e6f742061646d696e0000604482015260640161035e565b6001600160a01b0381166000818152600260208181526040808420548452600191829052808420909201805460ff19169091179055517f1b123bcf878d187698a3cdde9a0881b681babcd681b2cde1b473b8045f09b21a9190a250565b3360009081526003602052604090205460ff166104ce5760405162461bcd60e51b815260206004820152601e60248201527f4d61737465724e6f6465733a2055736572206973206e6f742061646d696e0000604482015260640161035e565b6000818152600160208190526040808320805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b038716908117825560028201805460ff1916909417909355426003909101555190917fb25d03aaf308d7291709be1ea28b800463cf3a9a4c4a5555d7333a964c1dfebd91a25050565b3360009081526003602052604090205460ff166105a75760405162461bcd60e51b815260206004820152601e60248201527f4d61737465724e6f6465733a2055736572206973206e6f742061646d696e0000604482015260640161035e565b6001600160a01b0382166000908152600260209081526040808320548084526001909252909120600301546105df9062014370610a60565b42116105ea57600080fd5b60008181526001602081905260408220426003820155018054849290610611908490610a60565b90915550506040518281526001600160a01b038416907fee024df340d648f807f11a9c96925f76feded85bcb87a26c2689a066d72049f29060200160405180910390a2505050565b3360009081526003602052604090205460ff166106b85760405162461bcd60e51b815260206004820152601e60248201527f4d61737465724e6f6465733a2055736572206973206e6f742061646d696e0000604482015260640161035e565b600080546001600160a01b038316808352600260208181526040808620859055938552600190819052838520805473ffffffffffffffffffffffffffffffffffffffff191690931790925583548452918320909101805460ff191690911790558054908061072583610a78565b90915550506040516001600160a01b038216907fb25d03aaf308d7291709be1ea28b800463cf3a9a4c4a5555d7333a964c1dfebd90600090a250565b3360009081526003602052604090205460ff166107c05760405162461bcd60e51b815260206004820152601e60248201527f4d61737465724e6f6465733a2055736572206973206e6f742061646d696e0000604482015260640161035e565b6001600160a01b038116600081815260026020818152604080842080548086526001808552838720805473ffffffffffffffffffffffffffffffffffffffff19168155908101879055808601805460ff191690556003018690558686529390925290839055519092917fcfc24166db4bb677e857cacabd1541fb2b30645021b27c5130419589b84db52b91a25050565b3360009081526003602052604090205460ff166108af5760405162461bcd60e51b815260206004820152601e60248201527f4d61737465724e6f6465733a2055736572206973206e6f742061646d696e0000604482015260640161035e565b6001600160a01b038116600081815260036020526040808220805460ff19169055517fb172b82abe077cdcfdf508ab80c083de4ed7930171cf16063f3d0624139433389190a250565b3360009081526003602052604090205460ff166109575760405162461bcd60e51b815260206004820152601e60248201527f4d61737465724e6f6465733a2055736572206973206e6f742061646d696e0000604482015260640161035e565b6001600160a01b03811660008181526002602081815260408084205484526001909152808320909101805460ff19169055517fb33eb89f1d4c76879efa22b299eb7d4b71660eb8bff678389cc0467f04a290799190a250565b6000602082840312156109c257600080fd5b5035919050565b80356001600160a01b03811681146109e057600080fd5b919050565b6000602082840312156109f757600080fd5b610a00826109c9565b9392505050565b60008060408385031215610a1a57600080fd5b610a23836109c9565b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60008219821115610a7357610a73610a31565b500190565b6000600019821415610a8c57610a8c610a31565b506001019056fea264697066735822122008deb3fb54f63c8b5cca3e5b5bbd95476041ba7da492a31624568dbc93ae711164736f6c63430008090033