Source Code
Overview
S Balance
0 S
More Info
ContractCreator
Loading...
Loading
Contract Name:
PeerToPlayImplementations
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 Interface for the Factory contract. interface IndexInterface { /// @notice Get the master address from the Factory contract. /// @return The address of the master. function master() external view returns (address); } /// @title Contract for setting up default and specific function implementations. contract Setup { /// @notice The default implementation address. address public defaultImplementation; mapping(bytes4 => address) internal sigImplementations; mapping(address => bytes4[]) internal implementationSigs; } /// @title Contract for managing and updating function implementations. contract Implementations is Setup { /// @notice Event emitted when the default implementation is set. event LogSetDefaultImplementation( address indexed oldImplementation, address indexed newImplementation ); /// @notice Event emitted when a new implementation is added. event LogAddImplementation(address indexed implementation, bytes4[] sigs); /// @notice Event emitted when an implementation is removed. event LogRemoveImplementation( address indexed implementation, bytes4[] sigs ); /// @notice The Factory contract interface. IndexInterface public immutable peerToPlayFactory; /// @param _peerToPlayFactory The address of the Factory contract. constructor(address _peerToPlayFactory) { peerToPlayFactory = IndexInterface(_peerToPlayFactory); } /// @notice Modifier to check if the caller is the master address. modifier isMaster() { require( msg.sender == peerToPlayFactory.master(), "Implementations: not-master" ); _; } /// @notice Set the default implementation address. /// @param _defaultImplementation The address of the new default implementation. function setDefaultImplementation( address _defaultImplementation ) external isMaster { require( _defaultImplementation != address(0), "Implementations: _defaultImplementation address not valid" ); require( _defaultImplementation != defaultImplementation, "Implementations: _defaultImplementation cannot be same" ); emit LogSetDefaultImplementation( defaultImplementation, _defaultImplementation ); defaultImplementation = _defaultImplementation; } /// @notice Add a new implementation. /// @param _implementation The address of the new implementation. /// @param _sigs The function signatures that should use this implementation. function addImplementation( address _implementation, bytes4[] calldata _sigs ) external isMaster { require( _implementation != address(0), "Implementations: _implementation not valid." ); require( implementationSigs[_implementation].length == 0, "Implementations: _implementation already added." ); for (uint i = 0; i < _sigs.length; i++) { bytes4 _sig = _sigs[i]; require( sigImplementations[_sig] == address(0), "Implementations: _sig already added" ); sigImplementations[_sig] = _implementation; } implementationSigs[_implementation] = _sigs; emit LogAddImplementation(_implementation, _sigs); } /// @notice Remove an implementation. /// @param _implementation The address of the implementation to remove. function removeImplementation(address _implementation) external isMaster { require( _implementation != address(0), "Implementations: _implementation not valid." ); require( implementationSigs[_implementation].length != 0, "Implementations: _implementation not found." ); bytes4[] memory sigs = implementationSigs[_implementation]; for (uint i = 0; i < sigs.length; i++) { bytes4 sig = sigs[i]; delete sigImplementations[sig]; } delete implementationSigs[_implementation]; emit LogRemoveImplementation(_implementation, sigs); } } /// @title Contract for querying function implementations. contract PeerToPlayImplementations is Implementations { /// @param _peerToPlayFactory The address of the Factory contract. constructor( address _peerToPlayFactory ) Implementations(_peerToPlayFactory) {} /// @notice Get the implementation address for a function signature. /// @param _sig The function signature to query. /// @return The address of the implementation. function getImplementation(bytes4 _sig) external view returns (address) { address _implementation = sigImplementations[_sig]; return _implementation == address(0) ? defaultImplementation : _implementation; } /// @notice Get all function signatures for a given implementation address. /// @param _impl The implementation address to query. /// @return An array of function signatures. function getImplementationSigs( address _impl ) external view returns (bytes4[] memory) { return implementationSigs[_impl]; } /// @notice Get the implementation address for a given function signature. /// @param _sig The function signature to query. /// @return The address of the implementation. function getSigImplementation(bytes4 _sig) external view returns (address) { return sigImplementations[_sig]; } }
{ "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":"address","name":"implementation","type":"address"},{"indexed":false,"internalType":"bytes4[]","name":"sigs","type":"bytes4[]"}],"name":"LogAddImplementation","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"},{"indexed":false,"internalType":"bytes4[]","name":"sigs","type":"bytes4[]"}],"name":"LogRemoveImplementation","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldImplementation","type":"address"},{"indexed":true,"internalType":"address","name":"newImplementation","type":"address"}],"name":"LogSetDefaultImplementation","type":"event"},{"inputs":[{"internalType":"address","name":"_implementation","type":"address"},{"internalType":"bytes4[]","name":"_sigs","type":"bytes4[]"}],"name":"addImplementation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"defaultImplementation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_sig","type":"bytes4"}],"name":"getImplementation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_impl","type":"address"}],"name":"getImplementationSigs","outputs":[{"internalType":"bytes4[]","name":"","type":"bytes4[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_sig","type":"bytes4"}],"name":"getSigImplementation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"peerToPlayFactory","outputs":[{"internalType":"contract IndexInterface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_implementation","type":"address"}],"name":"removeImplementation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_defaultImplementation","type":"address"}],"name":"setDefaultImplementation","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60a060405234801561001057600080fd5b50604051610e11380380610e1183398101604081905261002f91610040565b6001600160a01b0316608052610070565b60006020828403121561005257600080fd5b81516001600160a01b038116811461006957600080fd5b9392505050565b608051610d7261009f6000396000818160e30152818161018b0152818161044701526107290152610d726000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c8063b39c45931161005b578063b39c45931461011d578063dc9cc64514610130578063ef7e5c7b14610143578063f0c01b421461017657600080fd5b806322175a321461008d5780637c16ffc4146100a257806389396dc8146100b5578063ab23b618146100de575b600080fd5b6100a061009b366004610ae8565b610189565b005b6100a06100b0366004610ae8565b610445565b6100c86100c3366004610ae8565b61064b565b6040516100d59190610b05565b60405180910390f35b6101057f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100d5565b600054610105906001600160a01b031681565b61010561013e366004610b70565b6106e4565b610105610151366004610b70565b6001600160e01b0319166000908152600160205260409020546001600160a01b031690565b6100a0610184366004610b8b565b610727565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663ee97f7f36040518163ffffffff1660e01b8152600401602060405180830381865afa1580156101e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061020b9190610c13565b6001600160a01b0316336001600160a01b0316146102445760405162461bcd60e51b815260040161023b90610c30565b60405180910390fd5b6001600160a01b03811661026a5760405162461bcd60e51b815260040161023b90610c67565b6001600160a01b03811660009081526002602052604081205490036102e55760405162461bcd60e51b815260206004820152602b60248201527f496d706c656d656e746174696f6e733a205f696d706c656d656e746174696f6e60448201526a103737ba103337bab7321760a91b606482015260840161023b565b6001600160a01b03811660009081526002602090815260408083208054825181850281018501909352808352919290919083018282801561037257602002820191906000526020600020906000905b82829054906101000a900460e01b6001600160e01b031916815260200190600401906020826003010492830192600103820291508084116103345790505b5050505050905060005b81518110156103de57600082828151811061039957610399610cb2565b6020908102919091018101516001600160e01b031916600090815260019091526040902080546001600160a01b031916905550806103d681610cc8565b91505061037c565b506001600160a01b0382166000908152600260205260408120610400916109e0565b816001600160a01b03167fb7d759e6cdda23e8a1749bce345fc77355b8a22eeaf92c6e4e7257d959c162c7826040516104399190610b05565b60405180910390a25050565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663ee97f7f36040518163ffffffff1660e01b8152600401602060405180830381865afa1580156104a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104c79190610c13565b6001600160a01b0316336001600160a01b0316146104f75760405162461bcd60e51b815260040161023b90610c30565b6001600160a01b0381166105735760405162461bcd60e51b815260206004820152603960248201527f496d706c656d656e746174696f6e733a205f64656661756c74496d706c656d6560448201527f6e746174696f6e2061646472657373206e6f742076616c696400000000000000606482015260840161023b565b6000546001600160a01b03908116908216036105f05760405162461bcd60e51b815260206004820152603660248201527f496d706c656d656e746174696f6e733a205f64656661756c74496d706c656d656044820152756e746174696f6e2063616e6e6f742062652073616d6560501b606482015260840161023b565b600080546040516001600160a01b03808516939216917f3b337225b8d68d037e0c721876335a3832bd08162c943fe5f88e8d428597ca8f91a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0381166000908152600260209081526040918290208054835181840281018401909452808452606093928301828280156106d857602002820191906000526020600020906000905b82829054906101000a900460e01b6001600160e01b0319168152602001906004019060208260030104928301926001038202915080841161069a5790505b50505050509050919050565b6001600160e01b031981166000908152600160205260408120546001600160a01b031680156107135780610720565b6000546001600160a01b03165b9392505050565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663ee97f7f36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610785573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107a99190610c13565b6001600160a01b0316336001600160a01b0316146107d95760405162461bcd60e51b815260040161023b90610c30565b6001600160a01b0383166107ff5760405162461bcd60e51b815260040161023b90610c67565b6001600160a01b0383166000908152600260205260409020541561087d5760405162461bcd60e51b815260206004820152602f60248201527f496d706c656d656e746174696f6e733a205f696d706c656d656e746174696f6e60448201526e1030b63932b0b23c9030b23232b21760891b606482015260840161023b565b60005b8181101561097357600083838381811061089c5761089c610cb2565b90506020020160208101906108b19190610b70565b6001600160e01b031981166000908152600160205260409020549091506001600160a01b0316156109305760405162461bcd60e51b815260206004820152602360248201527f496d706c656d656e746174696f6e733a205f73696720616c726561647920616460448201526219195960ea1b606482015260840161023b565b6001600160e01b031916600090815260016020526040902080546001600160a01b0319166001600160a01b0386161790558061096b81610cc8565b915050610880565b506001600160a01b0383166000908152600260205260409020610997908383610a08565b50826001600160a01b03167ff9c512a86be00aaec236065d0a439f064133f367de889c782448c3578a3f30c583836040516109d3929190610cef565b60405180910390a2505050565b508054600082556007016008900490600052602060002090810190610a059190610abe565b50565b82805482825590600052602060002090600701600890048101928215610aae5791602002820160005b83821115610a7c5783356001600160e01b03191683826101000a81548163ffffffff021916908360e01c02179055509260200192600401602081600301049283019260010302610a31565b8015610aac5782816101000a81549063ffffffff0219169055600401602081600301049283019260010302610a7c565b505b50610aba929150610abe565b5090565b5b80821115610aba5760008155600101610abf565b6001600160a01b0381168114610a0557600080fd5b600060208284031215610afa57600080fd5b813561072081610ad3565b6020808252825182820181905260009190848201906040850190845b81811015610b475783516001600160e01b03191683529284019291840191600101610b21565b50909695505050505050565b80356001600160e01b031981168114610b6b57600080fd5b919050565b600060208284031215610b8257600080fd5b61072082610b53565b600080600060408486031215610ba057600080fd5b8335610bab81610ad3565b9250602084013567ffffffffffffffff80821115610bc857600080fd5b818601915086601f830112610bdc57600080fd5b813581811115610beb57600080fd5b8760208260051b8501011115610c0057600080fd5b6020830194508093505050509250925092565b600060208284031215610c2557600080fd5b815161072081610ad3565b6020808252601b908201527f496d706c656d656e746174696f6e733a206e6f742d6d61737465720000000000604082015260600190565b6020808252602b908201527f496d706c656d656e746174696f6e733a205f696d706c656d656e746174696f6e60408201526a103737ba103b30b634b21760a91b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b600060018201610ce857634e487b7160e01b600052601160045260246000fd5b5060010190565b60208082528181018390526000908460408401835b86811015610d31576001600160e01b0319610d1e84610b53565b1682529183019190830190600101610d04565b50969550505050505056fea2646970667358221220166ae18a803261797e2347ed01b2483650275e57761e9a600e57e42838b313ec64736f6c634300081400330000000000000000000000004fb50724220d7dc1d796542c5e4cbf36f8c1cf62
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106100885760003560e01c8063b39c45931161005b578063b39c45931461011d578063dc9cc64514610130578063ef7e5c7b14610143578063f0c01b421461017657600080fd5b806322175a321461008d5780637c16ffc4146100a257806389396dc8146100b5578063ab23b618146100de575b600080fd5b6100a061009b366004610ae8565b610189565b005b6100a06100b0366004610ae8565b610445565b6100c86100c3366004610ae8565b61064b565b6040516100d59190610b05565b60405180910390f35b6101057f0000000000000000000000004fb50724220d7dc1d796542c5e4cbf36f8c1cf6281565b6040516001600160a01b0390911681526020016100d5565b600054610105906001600160a01b031681565b61010561013e366004610b70565b6106e4565b610105610151366004610b70565b6001600160e01b0319166000908152600160205260409020546001600160a01b031690565b6100a0610184366004610b8b565b610727565b7f0000000000000000000000004fb50724220d7dc1d796542c5e4cbf36f8c1cf626001600160a01b031663ee97f7f36040518163ffffffff1660e01b8152600401602060405180830381865afa1580156101e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061020b9190610c13565b6001600160a01b0316336001600160a01b0316146102445760405162461bcd60e51b815260040161023b90610c30565b60405180910390fd5b6001600160a01b03811661026a5760405162461bcd60e51b815260040161023b90610c67565b6001600160a01b03811660009081526002602052604081205490036102e55760405162461bcd60e51b815260206004820152602b60248201527f496d706c656d656e746174696f6e733a205f696d706c656d656e746174696f6e60448201526a103737ba103337bab7321760a91b606482015260840161023b565b6001600160a01b03811660009081526002602090815260408083208054825181850281018501909352808352919290919083018282801561037257602002820191906000526020600020906000905b82829054906101000a900460e01b6001600160e01b031916815260200190600401906020826003010492830192600103820291508084116103345790505b5050505050905060005b81518110156103de57600082828151811061039957610399610cb2565b6020908102919091018101516001600160e01b031916600090815260019091526040902080546001600160a01b031916905550806103d681610cc8565b91505061037c565b506001600160a01b0382166000908152600260205260408120610400916109e0565b816001600160a01b03167fb7d759e6cdda23e8a1749bce345fc77355b8a22eeaf92c6e4e7257d959c162c7826040516104399190610b05565b60405180910390a25050565b7f0000000000000000000000004fb50724220d7dc1d796542c5e4cbf36f8c1cf626001600160a01b031663ee97f7f36040518163ffffffff1660e01b8152600401602060405180830381865afa1580156104a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104c79190610c13565b6001600160a01b0316336001600160a01b0316146104f75760405162461bcd60e51b815260040161023b90610c30565b6001600160a01b0381166105735760405162461bcd60e51b815260206004820152603960248201527f496d706c656d656e746174696f6e733a205f64656661756c74496d706c656d6560448201527f6e746174696f6e2061646472657373206e6f742076616c696400000000000000606482015260840161023b565b6000546001600160a01b03908116908216036105f05760405162461bcd60e51b815260206004820152603660248201527f496d706c656d656e746174696f6e733a205f64656661756c74496d706c656d656044820152756e746174696f6e2063616e6e6f742062652073616d6560501b606482015260840161023b565b600080546040516001600160a01b03808516939216917f3b337225b8d68d037e0c721876335a3832bd08162c943fe5f88e8d428597ca8f91a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0381166000908152600260209081526040918290208054835181840281018401909452808452606093928301828280156106d857602002820191906000526020600020906000905b82829054906101000a900460e01b6001600160e01b0319168152602001906004019060208260030104928301926001038202915080841161069a5790505b50505050509050919050565b6001600160e01b031981166000908152600160205260408120546001600160a01b031680156107135780610720565b6000546001600160a01b03165b9392505050565b7f0000000000000000000000004fb50724220d7dc1d796542c5e4cbf36f8c1cf626001600160a01b031663ee97f7f36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610785573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107a99190610c13565b6001600160a01b0316336001600160a01b0316146107d95760405162461bcd60e51b815260040161023b90610c30565b6001600160a01b0383166107ff5760405162461bcd60e51b815260040161023b90610c67565b6001600160a01b0383166000908152600260205260409020541561087d5760405162461bcd60e51b815260206004820152602f60248201527f496d706c656d656e746174696f6e733a205f696d706c656d656e746174696f6e60448201526e1030b63932b0b23c9030b23232b21760891b606482015260840161023b565b60005b8181101561097357600083838381811061089c5761089c610cb2565b90506020020160208101906108b19190610b70565b6001600160e01b031981166000908152600160205260409020549091506001600160a01b0316156109305760405162461bcd60e51b815260206004820152602360248201527f496d706c656d656e746174696f6e733a205f73696720616c726561647920616460448201526219195960ea1b606482015260840161023b565b6001600160e01b031916600090815260016020526040902080546001600160a01b0319166001600160a01b0386161790558061096b81610cc8565b915050610880565b506001600160a01b0383166000908152600260205260409020610997908383610a08565b50826001600160a01b03167ff9c512a86be00aaec236065d0a439f064133f367de889c782448c3578a3f30c583836040516109d3929190610cef565b60405180910390a2505050565b508054600082556007016008900490600052602060002090810190610a059190610abe565b50565b82805482825590600052602060002090600701600890048101928215610aae5791602002820160005b83821115610a7c5783356001600160e01b03191683826101000a81548163ffffffff021916908360e01c02179055509260200192600401602081600301049283019260010302610a31565b8015610aac5782816101000a81549063ffffffff0219169055600401602081600301049283019260010302610a7c565b505b50610aba929150610abe565b5090565b5b80821115610aba5760008155600101610abf565b6001600160a01b0381168114610a0557600080fd5b600060208284031215610afa57600080fd5b813561072081610ad3565b6020808252825182820181905260009190848201906040850190845b81811015610b475783516001600160e01b03191683529284019291840191600101610b21565b50909695505050505050565b80356001600160e01b031981168114610b6b57600080fd5b919050565b600060208284031215610b8257600080fd5b61072082610b53565b600080600060408486031215610ba057600080fd5b8335610bab81610ad3565b9250602084013567ffffffffffffffff80821115610bc857600080fd5b818601915086601f830112610bdc57600080fd5b813581811115610beb57600080fd5b8760208260051b8501011115610c0057600080fd5b6020830194508093505050509250925092565b600060208284031215610c2557600080fd5b815161072081610ad3565b6020808252601b908201527f496d706c656d656e746174696f6e733a206e6f742d6d61737465720000000000604082015260600190565b6020808252602b908201527f496d706c656d656e746174696f6e733a205f696d706c656d656e746174696f6e60408201526a103737ba103b30b634b21760a91b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b600060018201610ce857634e487b7160e01b600052601160045260246000fd5b5060010190565b60208082528181018390526000908460408401835b86811015610d31576001600160e01b0319610d1e84610b53565b1682529183019190830190600101610d04565b50969550505050505056fea2646970667358221220166ae18a803261797e2347ed01b2483650275e57761e9a600e57e42838b313ec64736f6c63430008140033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000004fb50724220d7dc1d796542c5e4cbf36f8c1cf62
-----Decoded View---------------
Arg [0] : _peerToPlayFactory (address): 0x4Fb50724220d7DC1D796542c5E4CBF36f8C1CF62
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 0000000000000000000000004fb50724220d7dc1d796542c5e4cbf36f8c1cf62
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
[ Download: CSV Export ]
[ Download: CSV Export ]
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.