ETH Price: $2,073.24 (-2.86%)

Transaction Decoder

Block:
10422877 at Jul-09-2020 03:22:12 AM +UTC
Transaction Fee:
0.0226378548 ETH $46.93
Gas Used:
571,663 Gas / 39.6 Gwei

Emitted Events:

Account State Difference:

  Address   Before After State Difference Code
0x1bFd0ba1...68E337A44
0 Eth
Nonce: 0
0 Eth
Nonce: 1
From: 0 To: 64431220824861729942719870048802352464460672767201338040695699821236046998997224262391123327089218685944283047717586406524252861968658598000878860931326521023598661074443686714187697180249682866386679539484036396841244083862924825200808381017567753298898347807950252679165812880995176970775438457214618884867906929097728781098069669464495776693369619169306199488111628734605868476415340590520801468858264516685047876993650392387683986841216259521778231745395022452158092103795777944606830522816695737510537432024451816039736835571384900229240921520295454649653928971622154778379741813283842956320144525779831120629392317560500485315777527329520762953427303919458994140621898187945834733274878830426307233314850567016538020543368503294720138555967391456657868598167508328458994399731969034256501950133142731744894325960221027240328175856346575376473398489468016956420264119001251299026112288682474317603435959260706550477871983012860010837238536335394400384853842255216791936642335164071054602389026684526712476562105996850396568050091252878027610251835235542245223961529435068464829814767211420601977053986810782827739224529079623183652847834569020202710742897944444085748717915630110491986450478798370426030448663647846537364773287567419988961387055179388576828104957952479936184556274062412085064775450251308276816322769076769576051390438458637346073959334389883025203232341513151233658545408015978851517795964826302785994333116533174171992243191058578736376496817850087014096327194655394447462487640622431825909867820301947725325955972909204223136735100069531123316722349615010600782780024843898699439311117034509951657245507815081361820902554578205038304823997489709128044491263896063774371610498405208743063346082470266134860346688621743013909755176859579143828956095342427274408976379579605129605362674305012215613882019321171986623910790880016995282962286786311143684139325186255872441379136721472914994167415426547129426188467984992676468921206456214959896995675883664319795007524001095239206892536038918549940123702157325964276534347913685111854203773960705148862719954161921597339119176857188593156938961420853049459641373200589546735323635617543027930165695061132014043203345596351543879546566912708856159453209088072926279608691962818119119552965002582110380290422272233675789922246207281671082814241476081565870699126622459304106771778997791603961029002137096687723330039037323237814441277950824596959888336804405415719782154975444759784978218868075058327890688875429572153389783799241952418110164048253930950977144620774731333201911076697192299664062354718942192344199810268741755035889605844935768159794835899960189342327902090747789113755455721658118856155390269327098891255699964200814645291698493076643733519789667327128383647481650598783493841267624513654162469578331034918708725305262589129464042990996163217399981454485121306245019613783671469716586741724599755701127994777805003668203136747795675688942400406908916220789170223623038896655230442140592068670049434137481714012961935039112930893411828420259069023118041002654592177444063014005494011215255476819371239732835400868461976320836939438677233255670286202560196172436785041831314727454604947662587752023506655175710429960355528949716883252753421689267642950232391733351612166269007949147817073356602274530250977090510820751547459578657916723547333767324614561945198777519193593660491981814081509509895555736978041382457311408841402017500529148038769167213985812714905365507554011116361620157971894209250087966401076887420219922684157603197471339388792790148640787776451837578010269920898660128129747006886559240503465334367082501417590544304652404163451318768420089565960882346263478072663556503530396949307061842007664240710724849242257278366522609647121017625004752811108104872434326972865182210746873420589787912467093773918709355330249074859398379533196861469038502148975256710318374875776130876615377065745030849060771148404379028746146395243991775528752791497229022768718940995384469319431910808170448526193236654440051915262765120746089727649579744961160391342489932086010369285026093729872717676386985348759920842871649427196758216719086384402651859092748503951275540127286113190166248697797691362321568385576318887720552884010252308826562874074575498511488301800968764183743643826121128828177428900519566582979699573510113339030359424701424129201086276870793337001284271005475730215405334406660571778123759166623877461792940779651215649906283987754125383816275616315304866361253909565409239971501588507391833270726359102243552886360940620437158273728906615611311069959111669773064707663712936341116328058211047460276603316497376709769747628609654355241546697993564070502314610866029474433127910060321910343564851900570111733215287987233351036600016159875325065721495257065573185652925914849594044479942083539394814420184168095208580799894437487642126322392047564637961411610683334215377259830246029719244855587317016123692848108259102210697774939387901036774254957482765888566346914642175140132309362683455140713548836163748513419439696412475050214709486516285391300336729219631627739086091541408390449909527975826552162273063260156993118860856469019894182357012979379867911698042436901217253317285865182694640849943427397845284546680286652927094165925468459036266480504701916635582742653433197714272236074910973117599509107022064345678916079161240085287458352679257623327196403547543283386362626098
(ZET Technologies)
23.013987754963305522 Eth23.036625609763305522 Eth0.0226378548
0x7c84124F...439ca91c1
(AVA Labs: Payment Master)
0xE4dc667f...dD0FD3C8c
36.618886793735018927 Eth
Nonce: 3098
36.596248938935018927 Eth
Nonce: 3099
0.0226378548

Execution Trace

PaymentMaster.CALL( )
  • 0x1bfd0ba1bf829de36d79e69b7c48dde68e337a44.60806040( )
    // File: @openzeppelin/contracts/GSN/Context.sol
    
    pragma solidity ^0.5.0;
    
    /*
     * @dev Provides information about the current execution context, including the
     * sender of the transaction and its data. While these are generally available
     * via msg.sender and msg.data, they should not be accessed in such a direct
     * manner, since when dealing with GSN meta-transactions the account sending and
     * paying for execution may not be the actual sender (as far as an application
     * is concerned).
     *
     * This contract is only required for intermediate, library-like contracts.
     */
    contract Context {
        // Empty internal constructor, to prevent people from mistakenly deploying
        // an instance of this contract, which should be used via inheritance.
        constructor () internal { }
        // solhint-disable-previous-line no-empty-blocks
    
        function _msgSender() internal view returns (address payable) {
            return msg.sender;
        }
    
        function _msgData() internal view returns (bytes memory) {
            this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
            return msg.data;
        }
    }
    
    // File: @openzeppelin/contracts/ownership/Ownable.sol
    
    pragma solidity ^0.5.0;
    
    /**
     * @dev Contract module which provides a basic access control mechanism, where
     * there is an account (an owner) that can be granted exclusive access to
     * specific functions.
     *
     * This module is used through inheritance. It will make available the modifier
     * `onlyOwner`, which can be applied to your functions to restrict their use to
     * the owner.
     */
    contract Ownable is Context {
        address private _owner;
    
        event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
    
        /**
         * @dev Initializes the contract setting the deployer as the initial owner.
         */
        constructor () internal {
            address msgSender = _msgSender();
            _owner = msgSender;
            emit OwnershipTransferred(address(0), msgSender);
        }
    
        /**
         * @dev Returns the address of the current owner.
         */
        function owner() public view returns (address) {
            return _owner;
        }
    
        /**
         * @dev Throws if called by any account other than the owner.
         */
        modifier onlyOwner() {
            require(isOwner(), "Ownable: caller is not the owner");
            _;
        }
    
        /**
         * @dev Returns true if the caller is the current owner.
         */
        function isOwner() public view returns (bool) {
            return _msgSender() == _owner;
        }
    
        /**
         * @dev Leaves the contract without owner. It will not be possible to call
         * `onlyOwner` functions anymore. Can only be called by the current owner.
         *
         * NOTE: Renouncing ownership will leave the contract without an owner,
         * thereby removing any functionality that is only available to the owner.
         */
        function renounceOwnership() public onlyOwner {
            emit OwnershipTransferred(_owner, address(0));
            _owner = address(0);
        }
    
        /**
         * @dev Transfers ownership of the contract to a new account (`newOwner`).
         * Can only be called by the current owner.
         */
        function transferOwnership(address newOwner) public onlyOwner {
            _transferOwnership(newOwner);
        }
    
        /**
         * @dev Transfers ownership of the contract to a new account (`newOwner`).
         */
        function _transferOwnership(address newOwner) internal {
            require(newOwner != address(0), "Ownable: new owner is the zero address");
            emit OwnershipTransferred(_owner, newOwner);
            _owner = newOwner;
        }
    }
    
    // File: @openzeppelin/contracts/token/ERC20/IERC20.sol
    
    pragma solidity ^0.5.0;
    
    /**
     * @dev Interface of the ERC20 standard as defined in the EIP. Does not include
     * the optional functions; to access them see {ERC20Detailed}.
     */
    interface IERC20 {
        /**
         * @dev Returns the amount of tokens in existence.
         */
        function totalSupply() external view returns (uint256);
    
        /**
         * @dev Returns the amount of tokens owned by `account`.
         */
        function balanceOf(address account) external view returns (uint256);
    
        /**
         * @dev Moves `amount` tokens from the caller's account to `recipient`.
         *
         * Returns a boolean value indicating whether the operation succeeded.
         *
         * Emits a {Transfer} event.
         */
        function transfer(address recipient, uint256 amount) external returns (bool);
    
        /**
         * @dev Returns the remaining number of tokens that `spender` will be
         * allowed to spend on behalf of `owner` through {transferFrom}. This is
         * zero by default.
         *
         * This value changes when {approve} or {transferFrom} are called.
         */
        function allowance(address owner, address spender) external view returns (uint256);
    
        /**
         * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
         *
         * Returns a boolean value indicating whether the operation succeeded.
         *
         * IMPORTANT: Beware that changing an allowance with this method brings the risk
         * that someone may use both the old and the new allowance by unfortunate
         * transaction ordering. One possible solution to mitigate this race
         * condition is to first reduce the spender's allowance to 0 and set the
         * desired value afterwards:
         * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
         *
         * Emits an {Approval} event.
         */
        function approve(address spender, uint256 amount) external returns (bool);
    
        /**
         * @dev Moves `amount` tokens from `sender` to `recipient` using the
         * allowance mechanism. `amount` is then deducted from the caller's
         * allowance.
         *
         * Returns a boolean value indicating whether the operation succeeded.
         *
         * Emits a {Transfer} event.
         */
        function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
    
        /**
         * @dev Emitted when `value` tokens are moved from one account (`from`) to
         * another (`to`).
         *
         * Note that `value` may be zero.
         */
        event Transfer(address indexed from, address indexed to, uint256 value);
    
        /**
         * @dev Emitted when the allowance of a `spender` for an `owner` is set by
         * a call to {approve}. `value` is the new allowance.
         */
        event Approval(address indexed owner, address indexed spender, uint256 value);
    }
    
    // File: @openzeppelin/contracts/math/SafeMath.sol
    
    pragma solidity ^0.5.0;
    
    /**
     * @dev Wrappers over Solidity's arithmetic operations with added overflow
     * checks.
     *
     * Arithmetic operations in Solidity wrap on overflow. This can easily result
     * in bugs, because programmers usually assume that an overflow raises an
     * error, which is the standard behavior in high level programming languages.
     * `SafeMath` restores this intuition by reverting the transaction when an
     * operation overflows.
     *
     * Using this library instead of the unchecked operations eliminates an entire
     * class of bugs, so it's recommended to use it always.
     */
    library SafeMath {
        /**
         * @dev Returns the addition of two unsigned integers, reverting on
         * overflow.
         *
         * Counterpart to Solidity's `+` operator.
         *
         * Requirements:
         * - Addition cannot overflow.
         */
        function add(uint256 a, uint256 b) internal pure returns (uint256) {
            uint256 c = a + b;
            require(c >= a, "SafeMath: addition overflow");
    
            return c;
        }
    
        /**
         * @dev Returns the subtraction of two unsigned integers, reverting on
         * overflow (when the result is negative).
         *
         * Counterpart to Solidity's `-` operator.
         *
         * Requirements:
         * - Subtraction cannot overflow.
         */
        function sub(uint256 a, uint256 b) internal pure returns (uint256) {
            return sub(a, b, "SafeMath: subtraction overflow");
        }
    
        /**
         * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
         * overflow (when the result is negative).
         *
         * Counterpart to Solidity's `-` operator.
         *
         * Requirements:
         * - Subtraction cannot overflow.
         *
         * _Available since v2.4.0._
         */
        function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
            require(b <= a, errorMessage);
            uint256 c = a - b;
    
            return c;
        }
    
        /**
         * @dev Returns the multiplication of two unsigned integers, reverting on
         * overflow.
         *
         * Counterpart to Solidity's `*` operator.
         *
         * Requirements:
         * - Multiplication cannot overflow.
         */
        function mul(uint256 a, uint256 b) internal pure returns (uint256) {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) {
                return 0;
            }
    
            uint256 c = a * b;
            require(c / a == b, "SafeMath: multiplication overflow");
    
            return c;
        }
    
        /**
         * @dev Returns the integer division of two unsigned integers. Reverts on
         * division by zero. The result is rounded towards zero.
         *
         * Counterpart to Solidity's `/` operator. Note: this function uses a
         * `revert` opcode (which leaves remaining gas untouched) while Solidity
         * uses an invalid opcode to revert (consuming all remaining gas).
         *
         * Requirements:
         * - The divisor cannot be zero.
         */
        function div(uint256 a, uint256 b) internal pure returns (uint256) {
            return div(a, b, "SafeMath: division by zero");
        }
    
        /**
         * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
         * division by zero. The result is rounded towards zero.
         *
         * Counterpart to Solidity's `/` operator. Note: this function uses a
         * `revert` opcode (which leaves remaining gas untouched) while Solidity
         * uses an invalid opcode to revert (consuming all remaining gas).
         *
         * Requirements:
         * - The divisor cannot be zero.
         *
         * _Available since v2.4.0._
         */
        function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
            // Solidity only automatically asserts when dividing by 0
            require(b > 0, errorMessage);
            uint256 c = a / b;
            // assert(a == b * c + a % b); // There is no case in which this doesn't hold
    
            return c;
        }
    
        /**
         * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
         * Reverts when dividing by zero.
         *
         * Counterpart to Solidity's `%` operator. This function uses a `revert`
         * opcode (which leaves remaining gas untouched) while Solidity uses an
         * invalid opcode to revert (consuming all remaining gas).
         *
         * Requirements:
         * - The divisor cannot be zero.
         */
        function mod(uint256 a, uint256 b) internal pure returns (uint256) {
            return mod(a, b, "SafeMath: modulo by zero");
        }
    
        /**
         * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
         * Reverts with custom message when dividing by zero.
         *
         * Counterpart to Solidity's `%` operator. This function uses a `revert`
         * opcode (which leaves remaining gas untouched) while Solidity uses an
         * invalid opcode to revert (consuming all remaining gas).
         *
         * Requirements:
         * - The divisor cannot be zero.
         *
         * _Available since v2.4.0._
         */
        function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
            require(b != 0, errorMessage);
            return a % b;
        }
    }
    
    // File: @openzeppelin/contracts/utils/Address.sol
    
    pragma solidity ^0.5.5;
    
    /**
     * @dev Collection of functions related to the address type
     */
    library Address {
        /**
         * @dev Returns true if `account` is a contract.
         *
         * [IMPORTANT]
         * ====
         * It is unsafe to assume that an address for which this function returns
         * false is an externally-owned account (EOA) and not a contract.
         *
         * Among others, `isContract` will return false for the following 
         * types of addresses:
         *
         *  - an externally-owned account
         *  - a contract in construction
         *  - an address where a contract will be created
         *  - an address where a contract lived, but was destroyed
         * ====
         */
        function isContract(address account) internal view returns (bool) {
            // According to EIP-1052, 0x0 is the value returned for not-yet created accounts
            // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
            // for accounts without code, i.e. `keccak256('')`
            bytes32 codehash;
            bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
            // solhint-disable-next-line no-inline-assembly
            assembly { codehash := extcodehash(account) }
            return (codehash != accountHash && codehash != 0x0);
        }
    
        /**
         * @dev Converts an `address` into `address payable`. Note that this is
         * simply a type cast: the actual underlying value is not changed.
         *
         * _Available since v2.4.0._
         */
        function toPayable(address account) internal pure returns (address payable) {
            return address(uint160(account));
        }
    
        /**
         * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
         * `recipient`, forwarding all available gas and reverting on errors.
         *
         * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
         * of certain opcodes, possibly making contracts go over the 2300 gas limit
         * imposed by `transfer`, making them unable to receive funds via
         * `transfer`. {sendValue} removes this limitation.
         *
         * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
         *
         * IMPORTANT: because control is transferred to `recipient`, care must be
         * taken to not create reentrancy vulnerabilities. Consider using
         * {ReentrancyGuard} or the
         * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
         *
         * _Available since v2.4.0._
         */
        function sendValue(address payable recipient, uint256 amount) internal {
            require(address(this).balance >= amount, "Address: insufficient balance");
    
            // solhint-disable-next-line avoid-call-value
            (bool success, ) = recipient.call.value(amount)("");
            require(success, "Address: unable to send value, recipient may have reverted");
        }
    }
    
    // File: @openzeppelin/contracts/token/ERC20/SafeERC20.sol
    
    pragma solidity ^0.5.0;
    
    
    
    
    /**
     * @title SafeERC20
     * @dev Wrappers around ERC20 operations that throw on failure (when the token
     * contract returns false). Tokens that return no value (and instead revert or
     * throw on failure) are also supported, non-reverting calls are assumed to be
     * successful.
     * To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract,
     * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
     */
    library SafeERC20 {
        using SafeMath for uint256;
        using Address for address;
    
        function safeTransfer(IERC20 token, address to, uint256 value) internal {
            callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
        }
    
        function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
            callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
        }
    
        function safeApprove(IERC20 token, address spender, uint256 value) internal {
            // safeApprove should only be called when setting an initial allowance,
            // or when resetting it to zero. To increase and decrease it, use
            // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
            // solhint-disable-next-line max-line-length
            require((value == 0) || (token.allowance(address(this), spender) == 0),
                "SafeERC20: approve from non-zero to non-zero allowance"
            );
            callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
        }
    
        function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
            uint256 newAllowance = token.allowance(address(this), spender).add(value);
            callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    
        function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
            uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
            callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    
        /**
         * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
         * on the return value: the return value is optional (but if data is returned, it must not be false).
         * @param token The token targeted by the call.
         * @param data The call data (encoded using abi.encode or one of its variants).
         */
        function callOptionalReturn(IERC20 token, bytes memory data) private {
            // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
            // we're implementing it ourselves.
    
            // A Solidity high level call has three parts:
            //  1. The target address is checked to verify it contains contract code
            //  2. The call itself is made, and success asserted
            //  3. The return value is decoded, which in turn checks the size of the returned data.
            // solhint-disable-next-line max-line-length
            require(address(token).isContract(), "SafeERC20: call to non-contract");
    
            // solhint-disable-next-line avoid-low-level-calls
            (bool success, bytes memory returndata) = address(token).call(data);
            require(success, "SafeERC20: low-level call failed");
    
            if (returndata.length > 0) { // Return data is optional
                // solhint-disable-next-line max-line-length
                require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
            }
        }
    }
    
    // File: contracts/PaymentHandler.sol
    
    pragma solidity ^0.5.0;
    
    
    
    /**
     * The payment handler is responsible for receiving payments.
     * If the payment is in ETH, it auto forwards to its parent master's owner.
     * If the payment is in ERC20, it holds the tokens until it is asked to sweep.
     * It can only sweep ERC20s to the parent master's owner.
     */
    contract PaymentHandler {
    	using SafeERC20 for IERC20;
    
    	// Keep track of the parent master contract - cannot be changed once set
    	PaymentMaster public master;
    
    	/**
    	 * General constructor called by the master
    	 */
    	constructor(PaymentMaster _master) public {
    		master = _master;
    	}
    
    	/**
    	 * Helper function to return the parent master's address
    	 */
    	function getMasterAddress() public view returns (address) {
    		return address(master);
    	}
    
    	/**
    	 * Default payable function - forwards to the owner and triggers event
    	 */
    	function() external payable {
    		// Get the parent master's owner address - explicity convert to payable
    		address payable ownerAddress = address(uint160(master.owner()));
    
    		// Forward the funds to the owner
    		ownerAddress.transfer(msg.value);
    
    		// Trigger the event notification in the parent master
    		master.firePaymentReceivedEvent(address(this), msg.sender, msg.value);
    	}
    
    	/**
    	 * Sweep any tokens to the owner of the master
    	 */
    	function sweepTokens(IERC20 token) public {
    		// Get the owner address
    		address ownerAddress = master.owner();
    
    		// Get the current balance
    		uint balance = token.balanceOf(address(this));
    
    		// Transfer to the owner
    		token.safeTransfer(ownerAddress, balance);
    	}
    
    }
    
    // File: contracts/PaymentMaster.sol
    
    pragma solidity ^0.5.0;
    
    
    
    
    
    /**
     * The PaymentMaster sits above the payment handler contracts.
     * It deploys and keeps track of all the handlers.
     * It can trigger events by child handlers when they receive ETH.
     * It allows ERC20 tokens to be swept in bulk to the owner account.
     */
    contract PaymentMaster is Ownable {
    	using SafeERC20 for IERC20;
    
    	// A list of handler addresses for retrieval
      address[] public handlerList;
    
    	// A mapping of handler addresses for lookups
    	mapping(address => bool) public handlerMap;
    
    	// Events triggered for listeners
    	event HandlerCreated(address indexed _addr);
    	event EthPaymentReceived(address indexed _to, address indexed _from, uint256 _amount);
    
    	/**
    	 * Anyone can call the function to deploy a new payment handler.
    	 * The new contract will be created, added to the list, and an event fired.
    	 */
    	function deployNewHandler() public {
    		// Deploy the new contract
    		PaymentHandler createdHandler = new PaymentHandler(this);
    
    		// Add it to the list and the mapping
    		handlerList.push(address(createdHandler));
    		handlerMap[address(createdHandler)] = true;
    
    		// Emit event to let watchers know that a new handler was created
    		emit HandlerCreated(address(createdHandler));
    	}
    
    	/**
    	 * This is a convenience method to allow watchers to get the entire list
    	 */
    	function getHandlerList() public view returns (address[] memory) {
    			// Return the entire list
          return handlerList;
      }
    
    	/**
    	 * Allows caller to determine how long the handler list is for convenience
    	 */
    	function getHandlerListLength() public view returns (uint) {
    		return handlerList.length;
    	}
    
    	/**
    	 * This function is called by handlers when they receive ETH payments.
    	 */
    	function firePaymentReceivedEvent(address to, address from, uint256 amount) public {
    		// Verify the call is coming from a handler
    		require(handlerMap[msg.sender], "Only payment handlers are allowed to trigger payment events.");
    
    		// Emit the event
    		emit EthPaymentReceived(to, from, amount);
    	}
    
    	/**
    	 * Allows a caller to sweep multiple handlers in one transaction
    	 */
    	function multiHandlerSweep(address[] memory handlers, IERC20 tokenContract) public {
    		for (uint i = 0; i < handlers.length; i++) {
    
    			// Whitelist calls to only handlers
    			require(handlerMap[handlers[i]], "Only payment handlers are valid sweep targets.");
    
    			// Trigger sweep
    			PaymentHandler(address(uint160(handlers[i]))).sweepTokens(tokenContract);
    		}
    	}
    
    	/**
    	 * Safety function to allow sweep of ERC20s if accidentally sent to this contract
    	 */
    	function sweepTokens(IERC20 token) public {
    		// Get the current balance
    		uint balance = token.balanceOf(address(this));
    
    		// Transfer to the owner
    		token.safeTransfer(this.owner(), balance);
    	}
    }