Source Code
Overview
S Balance
0 S
More Info
ContractCreator
Loading...
Loading
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0xef1912Ac...9814cE36E The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
PeerToPlayConnectors
Compiler Version
v0.8.20+commit.a1b79de6
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title PeerToPlayConnectors * @dev This contract serves as a registry for Connectors. It allows for the addition, updating, and removal of connectors. */ /** * @dev Interface for the PeerToPlayFactory contract to fetch the master address. */ interface IndexInterface { function master() external view returns (address); } /** * @dev Interface for the Connector to fetch its name. */ interface ConnectorInterface { function name() external view returns (string memory); } /** * @title Controllers * @dev This contract manages the chief controllers who have the authority to add, update, or remove connectors. */ contract Controllers { event LogController(address indexed addr, bool indexed isChief); // Address of the PeerToPlayFactory contract. address public immutable peerToPlayFactory; constructor(address _peerToPlayFactory) { peerToPlayFactory = _peerToPlayFactory; } // Mapping to check if an address is a chief. mapping(address => bool) public chief; // Mapping of connector names to their addresses. mapping(string => address) public connectors; /** * @dev Modifier to ensure the caller is a chief or the master of the PeerToPlayFactory. */ modifier isChief() { require( chief[msg.sender] || msg.sender == IndexInterface(peerToPlayFactory).master(), "not-an-chief" ); _; } /** * @dev Enables or disables a chief controller. * @param _chiefAddress Address of the chief to be toggled. */ function toggleChief(address _chiefAddress) external { require( msg.sender == IndexInterface(peerToPlayFactory).master(), "toggleChief: not-master" ); chief[_chiefAddress] = !chief[_chiefAddress]; emit LogController(_chiefAddress, chief[_chiefAddress]); } } /** * @title PeerToPlayConnectors * @dev Main contract for managing and interacting with connectors. */ contract PeerToPlayConnectors is Controllers { event LogConnectorAdded( bytes32 indexed connectorNameHash, string connectorName, address indexed connector ); event LogConnectorUpdated( bytes32 indexed connectorNameHash, string connectorName, address indexed oldConnector, address indexed newConnector ); event LogConnectorRemoved( bytes32 indexed connectorNameHash, string connectorName, address indexed connector ); constructor(address _peerToPlayFactory) Controllers(_peerToPlayFactory) {} /** * @dev Adds new connectors to the registry. * @param _connectorNames Names of the connectors to be added. * @param _connectors Addresses of the connectors to be added. */ function addConnectors( string[] calldata _connectorNames, address[] calldata _connectors ) external isChief { require( _connectorNames.length == _connectors.length, "addConnectors: not same length" ); for (uint i = 0; i < _connectors.length; i++) { require( connectors[_connectorNames[i]] == address(0), "addConnectors: _connectorName added already" ); require( _connectors[i] != address(0), "addConnectors: _connectors address not valid" ); ConnectorInterface(_connectors[i]).name(); // Verifying if connector has function name() connectors[_connectorNames[i]] = _connectors[i]; emit LogConnectorAdded( keccak256(abi.encodePacked(_connectorNames[i])), _connectorNames[i], _connectors[i] ); } } /** * @dev Updates existing connectors in the registry. * @param _connectorNames Names of the connectors to be updated. * @param _connectors New addresses for the connectors. */ function updateConnectors( string[] calldata _connectorNames, address[] calldata _connectors ) external isChief { require( _connectorNames.length == _connectors.length, "updateConnectors: not same length" ); for (uint i = 0; i < _connectors.length; i++) { require( connectors[_connectorNames[i]] != address(0), "updateConnectors: _connectorName not added to update" ); require( _connectors[i] != address(0), "updateConnectors: _connector address is not valid" ); ConnectorInterface(_connectors[i]).name(); // Verifying if connector has function name() emit LogConnectorUpdated( keccak256(abi.encodePacked(_connectorNames[i])), _connectorNames[i], connectors[_connectorNames[i]], _connectors[i] ); connectors[_connectorNames[i]] = _connectors[i]; } } /** * @dev Removes connectors from the registry. * @param _connectorNames Names of the connectors to be removed. */ function removeConnectors( string[] calldata _connectorNames ) external isChief { for (uint i = 0; i < _connectorNames.length; i++) { require( connectors[_connectorNames[i]] != address(0), "removeConnectors: _connectorName not added to update" ); emit LogConnectorRemoved( keccak256(abi.encodePacked(_connectorNames[i])), _connectorNames[i], connectors[_connectorNames[i]] ); delete connectors[_connectorNames[i]]; } } /** * @dev Checks if the provided connector names are registered and returns their addresses. * @param _connectorNames Names of the connectors to be checked. * @return isOk Boolean indicating if all connectors are registered. * @return _connectors Addresses of the checked connectors. */ function isConnectors( string[] calldata _connectorNames ) external view returns (bool isOk, address[] memory _connectors) { isOk = true; uint len = _connectorNames.length; _connectors = new address[](len); for (uint i = 0; i < _connectors.length; i++) { _connectors[i] = connectors[_connectorNames[i]]; if (_connectors[i] == address(0)) { isOk = false; break; } } } }
{ "optimizer": { "enabled": true, "runs": 200 }, "evmVersion": "paris", "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": {} }
[{"inputs":[{"internalType":"address","name":"_peerToPlayFactory","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"connectorNameHash","type":"bytes32"},{"indexed":false,"internalType":"string","name":"connectorName","type":"string"},{"indexed":true,"internalType":"address","name":"connector","type":"address"}],"name":"LogConnectorAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"connectorNameHash","type":"bytes32"},{"indexed":false,"internalType":"string","name":"connectorName","type":"string"},{"indexed":true,"internalType":"address","name":"connector","type":"address"}],"name":"LogConnectorRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"connectorNameHash","type":"bytes32"},{"indexed":false,"internalType":"string","name":"connectorName","type":"string"},{"indexed":true,"internalType":"address","name":"oldConnector","type":"address"},{"indexed":true,"internalType":"address","name":"newConnector","type":"address"}],"name":"LogConnectorUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"addr","type":"address"},{"indexed":true,"internalType":"bool","name":"isChief","type":"bool"}],"name":"LogController","type":"event"},{"inputs":[{"internalType":"string[]","name":"_connectorNames","type":"string[]"},{"internalType":"address[]","name":"_connectors","type":"address[]"}],"name":"addConnectors","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"chief","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"}],"name":"connectors","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string[]","name":"_connectorNames","type":"string[]"}],"name":"isConnectors","outputs":[{"internalType":"bool","name":"isOk","type":"bool"},{"internalType":"address[]","name":"_connectors","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"peerToPlayFactory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string[]","name":"_connectorNames","type":"string[]"}],"name":"removeConnectors","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_chiefAddress","type":"address"}],"name":"toggleChief","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string[]","name":"_connectorNames","type":"string[]"},{"internalType":"address[]","name":"_connectors","type":"address[]"}],"name":"updateConnectors","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106100885760003560e01c80636b1056ae1161005b5780636b1056ae146101195780637a5058c31461014c578063a0a32c0b1461015f578063ab23b6181461018057600080fd5b80630595272a1461008d5780630c17b2a7146100a2578063102c0ffe146100b557806326f9047a146100c8575b600080fd5b6100a061009b366004611092565b6101a7565b005b6100a06100b0366004611092565b610685565b6100a06100c3366004611116565b610aee565b6100fc6100d63660046111a9565b80516020818301810180516001825292820191909301209152546001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b61013c610127366004611116565b60006020819052908152604090205460ff1681565b6040519015158152602001610110565b6100a061015a366004611229565b610c2a565b61017261016d366004611229565b610f15565b60405161011092919061126b565b6100fc7f0000000000000000000000007fd8c47dcf46f78786dc518c27f1b5274505e4dc81565b3360009081526020819052604090205460ff168061025757507f0000000000000000000000007fd8c47dcf46f78786dc518c27f1b5274505e4dc6001600160a01b031663ee97f7f36040518163ffffffff1660e01b8152600401602060405180830381865afa15801561021e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061024291906112c4565b6001600160a01b0316336001600160a01b0316145b61027c5760405162461bcd60e51b8152600401610273906112e1565b60405180910390fd5b8281146102d55760405162461bcd60e51b815260206004820152602160248201527f757064617465436f6e6e6563746f72733a206e6f742073616d65206c656e67746044820152600d60fb1b6064820152608401610273565b60005b8181101561067e57600060018686848181106102f6576102f6611307565b9050602002810190610308919061131d565b604051610316929190611364565b908152604051908190036020019020546001600160a01b0316036103995760405162461bcd60e51b815260206004820152603460248201527f757064617465436f6e6e6563746f72733a205f636f6e6e6563746f724e616d65604482015273206e6f7420616464656420746f2075706461746560601b6064820152608401610273565b60008383838181106103ad576103ad611307565b90506020020160208101906103c29190611116565b6001600160a01b0316036104325760405162461bcd60e51b815260206004820152603160248201527f757064617465436f6e6e6563746f72733a205f636f6e6e6563746f72206164646044820152701c995cdcc81a5cc81b9bdd081d985b1a59607a1b6064820152608401610273565b82828281811061044457610444611307565b90506020020160208101906104599190611116565b6001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa158015610496573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526104be9190810190611374565b508282828181106104d1576104d1611307565b90506020020160208101906104e69190611116565b6001600160a01b0316600186868481811061050357610503611307565b9050602002810190610515919061131d565b604051610523929190611364565b908152604051908190036020019020546001600160a01b031686868481811061054e5761054e611307565b9050602002810190610560919061131d565b604051602001610571929190611364565b604051602081830303815290604052805190602001207f62c84f1d09bf60d3e3072d28fdf70fe9f97d35404ef16afed9cad977566e72dc8888868181106105ba576105ba611307565b90506020028101906105cc919061131d565b6040516105da929190611401565b60405180910390a48282828181106105f4576105f4611307565b90506020020160208101906106099190611116565b600186868481811061061d5761061d611307565b905060200281019061062f919061131d565b60405161063d929190611364565b90815260405190819003602001902080546001600160a01b03929092166001600160a01b03199092169190911790558061067681611430565b9150506102d8565b5050505050565b3360009081526020819052604090205460ff168061073557507f0000000000000000000000007fd8c47dcf46f78786dc518c27f1b5274505e4dc6001600160a01b031663ee97f7f36040518163ffffffff1660e01b8152600401602060405180830381865afa1580156106fc573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061072091906112c4565b6001600160a01b0316336001600160a01b0316145b6107515760405162461bcd60e51b8152600401610273906112e1565b8281146107a05760405162461bcd60e51b815260206004820152601e60248201527f616464436f6e6e6563746f72733a206e6f742073616d65206c656e67746800006044820152606401610273565b60005b8181101561067e57600060018686848181106107c1576107c1611307565b90506020028101906107d3919061131d565b6040516107e1929190611364565b908152604051908190036020019020546001600160a01b03161461085b5760405162461bcd60e51b815260206004820152602b60248201527f616464436f6e6e6563746f72733a205f636f6e6e6563746f724e616d6520616460448201526a64656420616c726561647960a81b6064820152608401610273565b600083838381811061086f5761086f611307565b90506020020160208101906108849190611116565b6001600160a01b0316036108ef5760405162461bcd60e51b815260206004820152602c60248201527f616464436f6e6e6563746f72733a205f636f6e6e6563746f727320616464726560448201526b1cdcc81b9bdd081d985b1a5960a21b6064820152608401610273565b82828281811061090157610901611307565b90506020020160208101906109169190611116565b6001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa158015610953573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261097b9190810190611374565b5082828281811061098e5761098e611307565b90506020020160208101906109a39190611116565b60018686848181106109b7576109b7611307565b90506020028101906109c9919061131d565b6040516109d7929190611364565b90815260405190819003602001902080546001600160a01b03929092166001600160a01b0319909216919091179055828282818110610a1857610a18611307565b9050602002016020810190610a2d9190611116565b6001600160a01b0316858583818110610a4857610a48611307565b9050602002810190610a5a919061131d565b604051602001610a6b929190611364565b604051602081830303815290604052805190602001207fd5f66ff1a09f5892b7170494d8082e4a64a3d903843d7a3cf439c0d0643a129b878785818110610ab457610ab4611307565b9050602002810190610ac6919061131d565b604051610ad4929190611401565b60405180910390a380610ae681611430565b9150506107a3565b7f0000000000000000000000007fd8c47dcf46f78786dc518c27f1b5274505e4dc6001600160a01b031663ee97f7f36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b4c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b7091906112c4565b6001600160a01b0316336001600160a01b031614610bd05760405162461bcd60e51b815260206004820152601760248201527f746f67676c6543686965663a206e6f742d6d61737465720000000000000000006044820152606401610273565b6001600160a01b038116600081815260208190526040808220805460ff19811660ff9182161590811790925591519116151592917f6033a9a2a67d8058b7f983c0785fb0f08b24e0cd7d345b30e3b3c63561b8bfdd91a350565b3360009081526020819052604090205460ff1680610cda57507f0000000000000000000000007fd8c47dcf46f78786dc518c27f1b5274505e4dc6001600160a01b031663ee97f7f36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ca1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cc591906112c4565b6001600160a01b0316336001600160a01b0316145b610cf65760405162461bcd60e51b8152600401610273906112e1565b60005b81811015610f105760006001848484818110610d1757610d17611307565b9050602002810190610d29919061131d565b604051610d37929190611364565b908152604051908190036020019020546001600160a01b031603610dba5760405162461bcd60e51b815260206004820152603460248201527f72656d6f7665436f6e6e6563746f72733a205f636f6e6e6563746f724e616d65604482015273206e6f7420616464656420746f2075706461746560601b6064820152608401610273565b6001838383818110610dce57610dce611307565b9050602002810190610de0919061131d565b604051610dee929190611364565b908152604051908190036020019020546001600160a01b0316838383818110610e1957610e19611307565b9050602002810190610e2b919061131d565b604051602001610e3c929190611364565b604051602081830303815290604052805190602001207f8ef7e58f2570b54253b8a1287bf238cbc3bb5f34c32b15ee8fd58bd3a250bd74858585818110610e8557610e85611307565b9050602002810190610e97919061131d565b604051610ea5929190611401565b60405180910390a36001838383818110610ec157610ec1611307565b9050602002810190610ed3919061131d565b604051610ee1929190611364565b90815260405190819003602001902080546001600160a01b031916905580610f0881611430565b915050610cf9565b505050565b60016060828067ffffffffffffffff811115610f3357610f3361113a565b604051908082528060200260200182016040528015610f5c578160200160208202803683370190505b50915060005b825181101561103d576001868683818110610f7f57610f7f611307565b9050602002810190610f91919061131d565b604051610f9f929190611364565b9081526040519081900360200190205483516001600160a01b0390911690849083908110610fcf57610fcf611307565b60200260200101906001600160a01b031690816001600160a01b03168152505060006001600160a01b031683828151811061100c5761100c611307565b60200260200101516001600160a01b03160361102b576000935061103d565b8061103581611430565b915050610f62565b50509250929050565b60008083601f84011261105857600080fd5b50813567ffffffffffffffff81111561107057600080fd5b6020830191508360208260051b850101111561108b57600080fd5b9250929050565b600080600080604085870312156110a857600080fd5b843567ffffffffffffffff808211156110c057600080fd5b6110cc88838901611046565b909650945060208701359150808211156110e557600080fd5b506110f287828801611046565b95989497509550505050565b6001600160a01b038116811461111357600080fd5b50565b60006020828403121561112857600080fd5b8135611133816110fe565b9392505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff811182821017156111795761117961113a565b604052919050565b600067ffffffffffffffff82111561119b5761119b61113a565b50601f01601f191660200190565b6000602082840312156111bb57600080fd5b813567ffffffffffffffff8111156111d257600080fd5b8201601f810184136111e357600080fd5b80356111f66111f182611181565b611150565b81815285602083850101111561120b57600080fd5b81602084016020830137600091810160200191909152949350505050565b6000806020838503121561123c57600080fd5b823567ffffffffffffffff81111561125357600080fd5b61125f85828601611046565b90969095509350505050565b60006040820184151583526020604081850152818551808452606086019150828701935060005b818110156112b75784516001600160a01b031683529383019391830191600101611292565b5090979650505050505050565b6000602082840312156112d657600080fd5b8151611133816110fe565b6020808252600c908201526b3737ba16b0b716b1b434b2b360a11b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b6000808335601e1984360301811261133457600080fd5b83018035915067ffffffffffffffff82111561134f57600080fd5b60200191503681900382131561108b57600080fd5b8183823760009101908152919050565b6000602080838503121561138757600080fd5b825167ffffffffffffffff81111561139e57600080fd5b8301601f810185136113af57600080fd5b80516113bd6111f182611181565b81815286848385010111156113d157600080fd5b60005b828110156113ef5783810185015182820186015284016113d4565b50600091810190930152509392505050565b60208152816020820152818360408301376000818301604090810191909152601f909201601f19160101919050565b60006001820161145057634e487b7160e01b600052601160045260246000fd5b506001019056fea2646970667358221220e5476d04802d8eecee1682c40fb89a64cd851c34f84abe9ad474211f4baffe4664736f6c63430008140033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.