Oko contract explorer
Contract

Code for 0x2545…ff83

Since block 20228743

Verified contract

  1. // SPDX-License-Identifier: LGPL-3.0-only
  2. pragma solidity >=0.7.0 <0.9.0;
  3. /// @title IProxy - Helper interface to access masterCopy of the Proxy on-chain
  4. /// @author Richard Meissner - <richard@gnosis.io>
  5. interface IProxy {
  6. function masterCopy() external view returns (address);
  7. }
  8. /// @title GnosisSafeProxy - Generic proxy contract allows to execute all transactions applying the code of a master contract.
  9. /// @author Stefan George - <stefan@gnosis.io>
  10. /// @author Richard Meissner - <richard@gnosis.io>
  11. contract GnosisSafeProxy {
  12. // singleton always needs to be first declared variable, to ensure that it is at the same location in the contracts to which calls are delegated.
  13. // To reduce deployment costs this variable is internal and needs to be retrieved via `getStorageAt`
  14. address internal singleton;
  15. /// @dev Constructor function sets address of singleton contract.
  16. /// @param _singleton Singleton address.
  17. constructor(address _singleton) {
  18. require(_singleton != address(0), "Invalid singleton address provided");
  19. singleton = _singleton;
  20. }
  21. /// @dev Fallback function forwards all transactions and returns all received return data.
  22. fallback() external payable {
  23. // solhint-disable-next-line no-inline-assembly
  24. assembly {
  25. let _singleton := and(sload(0), 0xffffffffffffffffffffffffffffffffffffffff)
  26. // 0xa619486e == keccak("masterCopy()"). The value is right padded to 32-bytes with 0s
  27. if eq(calldataload(0), 0xa619486e00000000000000000000000000000000000000000000000000000000) {
  28. mstore(0, _singleton)
  29. return(0, 0x20)
  30. }
  31. calldatacopy(0, 0, calldatasize())
  32. let success := delegatecall(gas(), _singleton, 0, calldatasize(), 0, 0)
  33. returndatacopy(0, 0, returndatasize())
  34. if eq(success, 0) {
  35. revert(0, returndatasize())
  36. }
  37. return(0, returndatasize())
  38. }
  39. }
  40. }
  41. /// @title Proxy Factory - Allows to create new proxy contact and execute a message call to the new proxy within one transaction.
  42. /// @author Stefan George - <stefan@gnosis.pm>
  43. contract GnosisSafeProxyFactory {
  44. event ProxyCreation(GnosisSafeProxy proxy, address singleton);
  45. /// @dev Allows to create new proxy contact and execute a message call to the new proxy within one transaction.
  46. /// @param singleton Address of singleton contract.
  47. /// @param data Payload for message call sent to new proxy contract.
  48. function createProxy(address singleton, bytes memory data) public returns (GnosisSafeProxy proxy) {
  49. proxy = new GnosisSafeProxy(singleton);
  50. if (data.length > 0)
  51. // solhint-disable-next-line no-inline-assembly
  52. assembly {
  53. if eq(call(gas(), proxy, 0, add(data, 0x20), mload(data), 0, 0), 0) {
  54. revert(0, 0)
  55. }
  56. }
  57. emit ProxyCreation(proxy, singleton);
  58. }
  59. /// @dev Allows to retrieve the runtime code of a deployed Proxy. This can be used to check that the expected Proxy was deployed.
  60. function proxyRuntimeCode() public pure returns (bytes memory) {
  61. return type(GnosisSafeProxy).runtimeCode;
  62. }
  63. /// @dev Allows to retrieve the creation code used for the Proxy deployment. With this it is easily possible to calculate predicted address.
  64. function proxyCreationCode() public pure returns (bytes memory) {
  65. return type(GnosisSafeProxy).creationCode;
  66. }
  67. /// @dev Allows to create new proxy contact using CREATE2 but it doesn't run the initializer.
  68. /// This method is only meant as an utility to be called from other methods
  69. /// @param _singleton Address of singleton contract.
  70. /// @param initializer Payload for message call sent to new proxy contract.
  71. /// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
  72. function deployProxyWithNonce(
  73. address _singleton,
  74. bytes memory initializer,
  75. uint256 saltNonce
  76. ) internal returns (GnosisSafeProxy proxy) {
  77. // If the initializer changes the proxy address should change too. Hashing the initializer data is cheaper than just concatinating it
  78. bytes32 salt = keccak256(abi.encodePacked(keccak256(initializer), saltNonce));
  79. bytes memory deploymentData = abi.encodePacked(type(GnosisSafeProxy).creationCode, uint256(uint160(_singleton)));
  80. // solhint-disable-next-line no-inline-assembly
  81. assembly {
  82. proxy := create2(0x0, add(0x20, deploymentData), mload(deploymentData), salt)
  83. }
  84. require(address(proxy) != address(0), "Create2 call failed");
  85. }
  86. /// @dev Allows to create new proxy contact and execute a message call to the new proxy within one transaction.
  87. /// @param _singleton Address of singleton contract.
  88. /// @param initializer Payload for message call sent to new proxy contract.
  89. /// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
  90. function createProxyWithNonce(
  91. address _singleton,
  92. bytes memory initializer,
  93. uint256 saltNonce
  94. ) public returns (GnosisSafeProxy proxy) {
  95. proxy = deployProxyWithNonce(_singleton, initializer, saltNonce);
  96. if (initializer.length > 0)
  97. // solhint-disable-next-line no-inline-assembly
  98. assembly {
  99. if eq(call(gas(), proxy, 0, add(initializer, 0x20), mload(initializer), 0, 0), 0) {
  100. revert(0, 0)
  101. }
  102. }
  103. emit ProxyCreation(proxy, _singleton);
  104. }
  105. /// @dev Allows to create new proxy contact, execute a message call to the new proxy and call a specified callback within one transaction
  106. /// @param _singleton Address of singleton contract.
  107. /// @param initializer Payload for message call sent to new proxy contract.
  108. /// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
  109. /// @param callback Callback that will be invoced after the new proxy contract has been successfully deployed and initialized.
  110. function createProxyWithCallback(
  111. address _singleton,
  112. bytes memory initializer,
  113. uint256 saltNonce,
  114. IProxyCreationCallback callback
  115. ) public returns (GnosisSafeProxy proxy) {
  116. uint256 saltNonceWithCallback = uint256(keccak256(abi.encodePacked(saltNonce, callback)));
  117. proxy = createProxyWithNonce(_singleton, initializer, saltNonceWithCallback);
  118. if (address(callback) != address(0)) callback.proxyCreated(proxy, _singleton, initializer, saltNonce);
  119. }
  120. /// @dev Allows to get the address for a new proxy contact created via `createProxyWithNonce`
  121. /// This method is only meant for address calculation purpose when you use an initializer that would revert,
  122. /// therefore the response is returned with a revert. When calling this method set `from` to the address of the proxy factory.
  123. /// @param _singleton Address of singleton contract.
  124. /// @param initializer Payload for message call sent to new proxy contract.
  125. /// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
  126. function calculateCreateProxyWithNonceAddress(
  127. address _singleton,
  128. bytes calldata initializer,
  129. uint256 saltNonce
  130. ) external returns (GnosisSafeProxy proxy) {
  131. proxy = deployProxyWithNonce(_singleton, initializer, saltNonce);
  132. revert(string(abi.encodePacked(proxy)));
  133. }
  134. }
  135. interface IProxyCreationCallback {
  136. function proxyCreated(
  137. GnosisSafeProxy proxy,
  138. address _singleton,
  139. bytes calldata initializer,
  140. uint256 saltNonce
  141. ) external;
  142. }

Contract sourced from Etherscan. Solidity version v0.7.6+commit.7338295f.

Panoramix decompilation

# Palkeoramix decompiler. 

def storage:
  stor0 is address at storage 0

def _fallback(?) payable: # default function
  if call.func_hash == 0xa619486e00000000000000000000000000000000000000000000000000000000:
      return stor0
  delegate stor0 with:
     funct call.data[0 len 4]
       gas gas_remaining wei
      args call.data[4 len calldata.size - 4]
  if not delegate.return_code:
      revert with ext_call.return_data[0 len return_data.size]
  return ext_call.return_data[0 len return_data.size]

Decompilation generated by Panoramix.

Raw bytecode

0x608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea2646970667358221220d1429297349653a4918076d650332de1a1068c5f3e07c5c82360c277770b955264736f6c63430007060033