Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
This contract has been partially verified via Sourcify.
View contract in Sourcify repository
- Contract name:
- ProxyRegistry
- Optimization enabled
- true
- Compiler version
- v0.4.20+commit.3155dd80
- Optimization runs
- 200
- Verified at
- 2026-05-12T06:02:14.828533Z
Constructor Arguments
0000000000000000000000001043fbd15c10a3234664cbdd944a16a204f945e6
Arg [0] (address) : 0x1043fbd15c10a3234664cbdd944a16a204f945e6
ProxyRegistry.sol
pragma solidity ^0.4.18;
contract DSAuthority {
function canCall(
address src, address dst, bytes4 sig
) public view returns (bool);
}
contract DSAuthEvents {
event LogSetAuthority (address indexed authority);
event LogSetOwner (address indexed owner);
}
contract DSAuth is DSAuthEvents {
DSAuthority public authority;
address public owner;
function DSAuth() public {
owner = msg.sender;
LogSetOwner(msg.sender);
}
function setOwner(address owner_)
public
auth
{
owner = owner_;
LogSetOwner(owner);
}
function setAuthority(DSAuthority authority_)
public
auth
{
authority = authority_;
LogSetAuthority(authority);
}
modifier auth {
require(isAuthorized(msg.sender, msg.sig));
_;
}
function isAuthorized(address src, bytes4 sig) internal view returns (bool) {
if (src == address(this)) {
return true;
} else if (src == owner) {
return true;
} else if (authority == DSAuthority(0)) {
return false;
} else {
return authority.canCall(src, this, sig);
}
}
}
contract DSNote {
event LogNote(
bytes4 indexed sig,
address indexed guy,
bytes32 indexed foo,
bytes32 indexed bar,
uint wad,
bytes fax
) anonymous;
modifier note {
bytes32 foo;
bytes32 bar;
assembly {
foo := calldataload(4)
bar := calldataload(36)
}
LogNote(msg.sig, msg.sender, foo, bar, msg.value, msg.data);
_;
}
}
// DSProxy
// Allows code execution using a persistant identity This can be very
// useful to execute a sequence of atomic actions. Since the owner of
// the proxy can be changed, this allows for dynamic ownership models
// i.e. a multisig
contract DSProxy is DSAuth, DSNote {
DSProxyCache public cache; // global cache for contracts
function DSProxy(address _cacheAddr) public {
require(setCache(_cacheAddr));
}
function() public payable {
}
// use the proxy to execute calldata _data on contract _code
function execute(bytes _code, bytes _data)
public
payable
returns (address target, bytes32 response)
{
target = cache.read(_code);
if (target == 0x0) {
// deploy contract & store its address in cache
target = cache.write(_code);
}
response = execute(target, _data);
}
function execute(address _target, bytes _data)
public
auth
note
payable
returns (bytes32 response)
{
require(_target != 0x0);
// call contract in current context
assembly {
let succeeded := delegatecall(sub(gas, 5000), _target, add(_data, 0x20), mload(_data), 0, 32)
response := mload(0) // load delegatecall output
switch iszero(succeeded)
case 1 {
// throw if delegatecall failed
revert(0, 0)
}
}
}
//set new cache
function setCache(address _cacheAddr)
public
auth
note
returns (bool)
{
require(_cacheAddr != 0x0); // invalid cache address
cache = DSProxyCache(_cacheAddr); // overwrite cache
return true;
}
}
// DSProxyFactory
// This factory deploys new proxy instances through build()
// Deployed proxy addresses are logged
contract DSProxyFactory {
event Created(address indexed sender, address proxy, address cache);
mapping(address=>bool) public isProxy;
DSProxyCache public cache = new DSProxyCache();
// deploys a new proxy instance
// sets owner of proxy to caller
function build() public returns (DSProxy proxy) {
proxy = build(msg.sender);
}
// deploys a new proxy instance
// sets custom owner of proxy
function build(address owner) public returns (DSProxy proxy) {
proxy = new DSProxy(cache);
Created(owner, address(proxy), address(cache));
proxy.setOwner(owner);
isProxy[proxy] = true;
}
}
// DSProxyCache
// This global cache stores addresses of contracts previously deployed
// by a proxy. This saves gas from repeat deployment of the same
// contracts and eliminates blockchain bloat.
// By default, all proxies deployed from the same factory store
// contracts in the same cache. The cache a proxy instance uses can be
// changed. The cache uses the sha3 hash of a contract's bytecode to
// lookup the address
contract DSProxyCache {
mapping(bytes32 => address) cache;
function read(bytes _code) public view returns (address) {
bytes32 hash = keccak256(_code);
return cache[hash];
}
function write(bytes _code) public returns (address target) {
assembly {
target := create(0, add(_code, 0x20), mload(_code))
switch iszero(extcodesize(target))
case 1 {
// throw if contract failed to deploy
revert(0, 0)
}
}
bytes32 hash = keccak256(_code);
cache[hash] = target;
}
}
// ProxyRegistry
// This Registry deploys new proxy instances through DSProxyFactory.build(address) and keeps a registry of owner => proxies
contract ProxyRegistry {
mapping(address=>DSProxy[]) public proxies;
mapping(address=>uint) public proxiesCount;
DSProxyFactory factory;
function ProxyRegistry(DSProxyFactory factory_) public {
factory = factory_;
}
// deploys a new proxy instance
// sets owner of proxy to caller
function build() public returns (DSProxy proxy) {
proxy = build(msg.sender);
}
// deploys a new proxy instance
// sets custom owner of proxy
function build(address owner) public returns (DSProxy proxy) {
proxy = factory.build(owner);
proxies[owner].push(proxy);
proxiesCount[owner] ++;
}
}
Compiler Settings
{"remappings":[],"optimizer":{"runs":200,"enabled":true},"libraries":{},"compilationTarget":{"ProxyRegistry.sol":"ProxyRegistry"}}
Contract ABI
[{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":""}],"name":"proxies","inputs":[{"type":"address","name":""},{"type":"uint256","name":""}],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"address","name":"proxy"}],"name":"build","inputs":[],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":""}],"name":"proxiesCount","inputs":[{"type":"address","name":""}],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"address","name":"proxy"}],"name":"build","inputs":[{"type":"address","name":"owner"}],"constant":false},{"type":"constructor","stateMutability":"nonpayable","payable":false,"inputs":[{"type":"address","name":"factory_"}]}]
Contract Creation Code
0x6060604052341561000f57600080fd5b6040516020806103398339810160405280805160028054600160a060020a03909216600160a060020a031990921691909117905550506102e5806100546000396000f3006060604052600436106100615763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416635dcf7c8c81146100665780638e1a55fc146100a4578063d224f1ed146100b7578063f3701da2146100e8575b600080fd5b341561007157600080fd5b610088600160a060020a0360043516602435610107565b604051600160a060020a03909116815260200160405180910390f35b34156100af57600080fd5b61008861013e565b34156100c257600080fd5b6100d6600160a060020a036004351661014e565b60405190815260200160405180910390f35b34156100f357600080fd5b610088600160a060020a0360043516610160565b60006020528160005260406000208181548110151561012257fe5b600091825260209091200154600160a060020a03169150829050565b600061014933610160565b905090565b60016020526000908152604090205481565b600254600090600160a060020a031663f3701da28383604051602001526040517c010000000000000000000000000000000000000000000000000000000063ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b15156101d457600080fd5b6102c65a03f115156101e557600080fd5b5050506040518051600160a060020a0384166000908152602081905260409020805491935091506001810161021a838261026f565b506000918252602080832091909101805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a038581169190911790915593909316815260019283905260409020805490920190915590565b81548183558181151161029357600083815260209020610293918101908301610298565b505050565b6102b691905b808211156102b2576000815560010161029e565b5090565b905600a165627a7a7230582097917404a78dc404253c485d8d6190923b3c0146210442f727cadae521df778a00290000000000000000000000001043fbd15c10a3234664cbdd944a16a204f945e6
Deployed ByteCode
0x6060604052600436106100615763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416635dcf7c8c81146100665780638e1a55fc146100a4578063d224f1ed146100b7578063f3701da2146100e8575b600080fd5b341561007157600080fd5b610088600160a060020a0360043516602435610107565b604051600160a060020a03909116815260200160405180910390f35b34156100af57600080fd5b61008861013e565b34156100c257600080fd5b6100d6600160a060020a036004351661014e565b60405190815260200160405180910390f35b34156100f357600080fd5b610088600160a060020a0360043516610160565b60006020528160005260406000208181548110151561012257fe5b600091825260209091200154600160a060020a03169150829050565b600061014933610160565b905090565b60016020526000908152604090205481565b600254600090600160a060020a031663f3701da28383604051602001526040517c010000000000000000000000000000000000000000000000000000000063ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b15156101d457600080fd5b6102c65a03f115156101e557600080fd5b5050506040518051600160a060020a0384166000908152602081905260409020805491935091506001810161021a838261026f565b506000918252602080832091909101805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a038581169190911790915593909316815260019283905260409020805490920190915590565b81548183558181151161029357600083815260209020610293918101908301610298565b505050565b6102b691905b808211156102b2576000815560010161029e565b5090565b905600a165627a7a7230582097917404a78dc404253c485d8d6190923b3c0146210442f727cadae521df778a0029