Oko contract explorer
Contract

Code for 0xd199…38b3 (ContractRegistry)

Since block 5742824

Verified contract

  1. /**
  2. *Submitted for verification at Etherscan.io on 2018-06-06
  3. */
  4. pragma solidity ^0.4.21;
  5. /*
  6. Owned contract interface
  7. */
  8. contract IOwned {
  9. // this function isn't abstract since the compiler emits automatically generated getter functions as external
  10. function owner() public view returns (address) {}
  11. function transferOwnership(address _newOwner) public;
  12. function acceptOwnership() public;
  13. }
  14. /*
  15. Provides support and utilities for contract ownership
  16. */
  17. contract Owned is IOwned {
  18. address public owner;
  19. address public newOwner;
  20. event OwnerUpdate(address indexed _prevOwner, address indexed _newOwner);
  21. /**
  22. @dev constructor
  23. */
  24. function Owned() public {
  25. owner = msg.sender;
  26. }
  27. // allows execution by the owner only
  28. modifier ownerOnly {
  29. assert(msg.sender == owner);
  30. _;
  31. }
  32. /**
  33. @dev allows transferring the contract ownership
  34. the new owner still needs to accept the transfer
  35. can only be called by the contract owner
  36. @param _newOwner new contract owner
  37. */
  38. function transferOwnership(address _newOwner) public ownerOnly {
  39. require(_newOwner != owner);
  40. newOwner = _newOwner;
  41. }
  42. /**
  43. @dev used by a new owner to accept an ownership transfer
  44. */
  45. function acceptOwnership() public {
  46. require(msg.sender == newOwner);
  47. emit OwnerUpdate(owner, newOwner);
  48. owner = newOwner;
  49. newOwner = address(0);
  50. }
  51. }
  52. /*
  53. Contract Registry interface
  54. */
  55. contract IContractRegistry {
  56. function getAddress(bytes32 _contractName) public view returns (address);
  57. }
  58. /**
  59. Contract Registry
  60. The contract registry keeps contract addresses by name.
  61. The owner can update contract addresses so that a contract name always points to the latest version
  62. of the given contract.
  63. Other contracts can query the registry to get updated addresses instead of depending on specific
  64. addresses.
  65. Note that contract names are limited to 32 bytes, UTF8 strings to optimize gas costs
  66. */
  67. contract ContractRegistry is IContractRegistry, Owned {
  68. mapping (bytes32 => address) addresses;
  69. event AddressUpdate(bytes32 indexed _contractName, address _contractAddress);
  70. /**
  71. @dev constructor
  72. */
  73. function ContractRegistry() public {
  74. }
  75. /**
  76. @dev returns the address associated with the given contract name
  77. @param _contractName contract name
  78. @return contract address
  79. */
  80. function getAddress(bytes32 _contractName) public view returns (address) {
  81. return addresses[_contractName];
  82. }
  83. /**
  84. @dev registers a new address for the contract name
  85. @param _contractName contract name
  86. @param _contractAddress contract address
  87. */
  88. function registerAddress(bytes32 _contractName, address _contractAddress) public ownerOnly {
  89. require(_contractName.length > 0); // validating input
  90. addresses[_contractName] = _contractAddress;
  91. emit AddressUpdate(_contractName, _contractAddress);
  92. }
  93. }

Contract sourced from Etherscan. Solidity version v0.4.21+commit.dfe3193c.

Panoramix decompilation

# Palkeoramix decompiler. 

def storage:
  owner is address at storage 0
  newOwner is address at storage 1
  address is mapping of address at storage 2

def getAddress(bytes32 id): # not payable
  return address[id]

def owner(): # not payable
  return owner

def newOwner(): # not payable
  return newOwner

#
#  Regular functions
#

def _fallback(?) payable: # default function
  revert

def transferOwnership(address newOwner): # not payable
  require owner == caller
  require owner != newOwner
  newOwner = newOwner

def acceptOwnership(): # not payable
  require newOwner == caller
  log OwnerUpdate(
        address _prevOwner=owner,
        address _newOwner=newOwner)
  owner = newOwner
  newOwner = 0

def registerAddress(bytes32 _contractName, address _contractAddress): # not payable
  require owner == caller
  address[_contractName] = _contractAddress
  log AddressUpdate(
        bytes32 _contractName=_contractAddress,
        address _contractAddress=_contractName)

Decompilation generated by Panoramix.

Raw bytecode

0x6060604052600436106100775763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166321f8a721811461007c578063662de379146100bb57806379ba5097146100ec5780638da5cb5b146100ff578063d4ee1d9014610112578063f2fde38b14610125575b600080fd5b341561008757600080fd5b610092600435610151565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b34156100c657600080fd5b6100ea60043573ffffffffffffffffffffffffffffffffffffffff60243516610179565b005b34156100f757600080fd5b6100ea610231565b341561010a57600080fd5b6100926102e6565b341561011d57600080fd5b610092610302565b341561013057600080fd5b6100ea73ffffffffffffffffffffffffffffffffffffffff6004351661031e565b60009081526002602052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b6000543373ffffffffffffffffffffffffffffffffffffffff90811691161461019e57fe5b60008281526002602052604090819020805473ffffffffffffffffffffffffffffffffffffffff191673ffffffffffffffffffffffffffffffffffffffff841617905582907ffc08d1253c81bcd5444fc7056ef1f5a5df4c9220b6fd70d7449267f1f0f299189083905173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390a25050565b6001543373ffffffffffffffffffffffffffffffffffffffff90811691161461025957600080fd5b60015460005473ffffffffffffffffffffffffffffffffffffffff91821691167f343765429aea5a34b3ff6a3785a98a5abb2597aca87bfbb58632c173d585373a60405160405180910390a3600180546000805473ffffffffffffffffffffffffffffffffffffffff1990811673ffffffffffffffffffffffffffffffffffffffff841617909155169055565b60005473ffffffffffffffffffffffffffffffffffffffff1681565b60015473ffffffffffffffffffffffffffffffffffffffff1681565b6000543373ffffffffffffffffffffffffffffffffffffffff90811691161461034357fe5b60005473ffffffffffffffffffffffffffffffffffffffff8281169116141561036b57600080fd5b6001805473ffffffffffffffffffffffffffffffffffffffff191673ffffffffffffffffffffffffffffffffffffffff929092169190911790555600a165627a7a723058203f31c817cb2ad76ddb76aa2d6bbb4b3326362386c8cc6144c2d1c80680a861a80029