Skip to content
Verified contractPartial

EdgewareSignalProxy

Address0xa7556feef00585e85c8d6a2b57233c63071a5fcd
Balance

0 ETH

 

Transactions

2

 

Compiler

solc 0.5.11

 

Same code

11 more contracts

 

Details

Compiler
solc 0.5.11+commit.c082d0b4
Language
solidity
Optimization
Yes, 200 runs
License
Not stated
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
8,440,654
Creation transaction
0xd1c230a646…3f1ee2ea5e

2 files

EdgewareSignalProxy.sol

// Recovered by EthereumHistory (ethereumhistory.com) -sw
pragma solidity ^0.5.11;

import "./Lockdrop.sol";

/// @dev Proxy contract that enables secure signalling through three-distinct private keys.
/// fundSrc = address that provides funds to the proxy
/// fundDst = address that receives funds when signalling is completed
/// admin = address that can trigger release() of funds to fundDst
contract EdgewareSignalProxy {
  address payable public fundDst;
  address public fundSrc;
  address public admin;
  bytes public edgewareAddr;
  Lockdrop public lockdrop;

  /// @dev Establish a new proxy for singnalling.
  /// @param _lockdrop Address of the Edgeware Lockdrop singalling contract
  /// @param _fundSrc The address that provides funds to this proxy
  /// @param _fundDst The address that will receive funds after signalling is complete
  /// @param _admin The administration address: can call signal() and release()
  /// @param _edgewareAddr The edgeware address that will receive funds from the lockdrop
  constructor(
    Lockdrop _lockdrop,
    address _fundSrc,
    address payable _fundDst,
    address _admin,
    bytes memory _edgewareAddr
  ) public {
    lockdrop = _lockdrop;
    fundSrc = _fundSrc;
    fundDst = _fundDst;
    admin = _admin;
    edgewareAddr = _edgewareAddr;
  }

  /// @dev Ensures that only the admin or the fundDst addresses can call a given function.
  modifier auth() {
    require(msg.sender == admin || msg.sender == fundDst, "Sender must be the fund destination or admin address");
    _;
  }

  /// @dev Signals to the lockdrop contract when new founds are deposited.
  /// Will only receive deposits from the designated fundSrc address
  function () external payable {
    require(msg.sender == fundSrc, "Sender must be the fund source address");
    signal();
  }

  /// @dev Calls the signal() method on the lockdrop contract with the Edgeware address
  /// associated with this proxy.
  function signal() internal {
    // Note that the nonce parameter can be set to any value. We're signalling on behalf of
    // oursevles and not another contract and so when Lockdrop.signal calls didCreate
    // the nonce value is ignored.
    lockdrop.signal(address(this), 0, edgewareAddr);
  }

  /// @dev Sends all fund held by this contract back to the fundDst address.
  /// Note that if funds are release()d before the Edgeware Lockdrop snapshot has occurred
  /// that no credit for this signalling will take place. Be sure to release() funds
  /// after the snapshot has completed to ensure credit for signal()ing.
  function release() external auth {
    address(fundDst).transfer(address(this).balance);
  }
}

Lockdrop.sol

// Recovered by EthereumHistory (ethereumhistory.com) -sw
pragma solidity ^0.5.0;

contract Lock {
    // address owner; slot #0
    // address unlockTime; slot #1
    constructor (address owner, uint256 unlockTime) public payable {
        assembly {
            sstore(0x00, owner)
            sstore(0x01, unlockTime)
        }
    }
    
    /**
     * @dev        Withdraw function once timestamp has passed unlock time
     */
    function () external payable { // payable so solidity doesn't add unnecessary logic
        assembly {
            switch gt(timestamp, sload(0x01))
            case 0 { revert(0, 0) }
            case 1 {
                switch call(gas, sload(0x00), balance(address), 0, 0, 0, 0)
                case 0 { revert(0, 0) }
            }
        }
    }
}

contract Lockdrop {
    enum Term {
        ThreeMo,
        SixMo,
        TwelveMo
    }
    // Time constants
    uint256 constant public LOCK_DROP_PERIOD = 1 days * 92; // 3 months
    uint256 public LOCK_START_TIME;
    uint256 public LOCK_END_TIME;
    // ETH locking events
    event Locked(address indexed owner, uint256 eth, Lock lockAddr, Term term, bytes edgewareAddr, bool isValidator, uint time);
    event Signaled(address indexed contractAddr, bytes edgewareAddr, uint time);
    
    constructor(uint startTime) public {
        LOCK_START_TIME = startTime;
        LOCK_END_TIME = startTime + LOCK_DROP_PERIOD;
    }

    /**
     * @dev        Locks up the value sent to contract in a new Lock
     * @param      term         The length of the lock up
     * @param      edgewareAddr The bytes representation of the target edgeware key
     * @param      isValidator  Indicates if sender wishes to be a validator
     */
    function lock(Term term, bytes calldata edgewareAddr, bool isValidator)
        external
        payable
        didStart
        didNotEnd
    {
        uint256 eth = msg.value;
        address owner = msg.sender;
        uint256 unlockTime = unlockTimeForTerm(term);
        // Create ETH lock contract
        Lock lockAddr = (new Lock).value(eth)(owner, unlockTime);
        // ensure lock contract has at least all the ETH, or fail
        assert(address(lockAddr).balance >= msg.value);
        emit Locked(owner, eth, lockAddr, term, edgewareAddr, isValidator, now);
    }

    /**
     * @dev        Signals a contract's (or address's) balance decided after lock period
     * @param      contractAddr  The contract address from which to signal the balance of
     * @param      nonce         The transaction nonce of the creator of the contract
     * @param      edgewareAddr   The bytes representation of the target edgeware key
     */
    function signal(address contractAddr, uint32 nonce, bytes calldata edgewareAddr)
        external
        didStart
        didNotEnd
        didCreate(contractAddr, msg.sender, nonce)
    {
        emit Signaled(contractAddr, edgewareAddr, now);
    }

    function unlockTimeForTerm(Term term) internal view returns (uint256) {
        if (term == Term.ThreeMo) return now + 92 days;
        if (term == Term.SixMo) return now + 183 days;
        if (term == Term.TwelveMo) return now + 365 days;
        
        revert();
    }

    /**
     * @dev        Ensures the lockdrop has started
     */
    modifier didStart() {
        require(now >= LOCK_START_TIME);
        _;
    }

    /**
     * @dev        Ensures the lockdrop has not ended
     */
    modifier didNotEnd() {
        require(now <= LOCK_END_TIME);
        _;
    }

    /**
     * @dev        Rebuilds the contract address from a normal address and transaction nonce
     * @param      _origin  The non-contract address derived from a user's public key
     * @param      _nonce   The transaction nonce from which to generate a contract address
     */
    function addressFrom(address _origin, uint32 _nonce) public pure returns (address) {
        if(_nonce == 0x00)     return address(uint160(uint256(keccak256(abi.encodePacked(byte(0xd6), byte(0x94), _origin, byte(0x80))))));
        if(_nonce <= 0x7f)     return address(uint160(uint256(keccak256(abi.encodePacked(byte(0xd6), byte(0x94), _origin, uint8(_nonce))))));
        if(_nonce <= 0xff)     return address(uint160(uint256(keccak256(abi.encodePacked(byte(0xd7), byte(0x94), _origin, byte(0x81), uint8(_nonce))))));
        if(_nonce <= 0xffff)   return address(uint160(uint256(keccak256(abi.encodePacked(byte(0xd8), byte(0x94), _origin, byte(0x82), uint16(_nonce))))));
        if(_nonce <= 0xffffff) return address(uint160(uint256(keccak256(abi.encodePacked(byte(0xd9), byte(0x94), _origin, byte(0x83), uint24(_nonce))))));
        return address(uint160(uint256(keccak256(abi.encodePacked(byte(0xda), byte(0x94), _origin, byte(0x84), uint32(_nonce)))))); // more than 2^32 nonces not realistic
    }

    /**
     * @dev        Ensures the target address was created by a parent at some nonce
     * @param      target  The target contract address (or trivially the parent)
     * @param      parent  The creator of the alleged contract address
     * @param      nonce   The creator's tx nonce at the time of the contract creation
     */
    modifier didCreate(address target, address parent, uint32 nonce) {
        // Trivially let senders "create" themselves
        if (target == parent) {
            _;
        } else {
            require(target == addressFrom(parent, nonce));
            _;
        }
    }
}
Compiler settingsShow
{
  "optimizer": {
    "runs": 200,
    "enabled": true
  }
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.