Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0xC0B9a1da6A581950e695a1995Bf720e7367F76f8
Balance 0.000970493 ETH
Nonce 1
Code Size 4667 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

4667 bytes
0x608060405260043610610147575f3560e01c80637cb46fb7116100b3578063db2e21bc1161006d578063db2e21bc146103fd578063eac6b7b614610411578063f2fde38b14610430578063f3c1b9281461044f578063f729cf0d1461046e578063fd2d500614610556575f80fd5b80637cb46fb7146103245780638456cb591461035b5780638da5cb5b1461036f5780639f46271914610395578063b957a310146103b4578063d2889531146103e8575f80fd5b80633f4ba83a116101045780633f4ba83a1461029e5780635bad4e2e146102b25780635c975abb146102c65780635e077aa0146102dd5780635f3c2ed2146102fc578063715018a614610310575f80fd5b806321e13b4e1461014b5780632e56e38a1461016057806334ead4d31461017f578063360d95b6146101a757806338ed7cfc146101e55780633e693b4d14610273575b5f80fd5b61015e61015936600461109e565b610575565b005b34801561016b575f80fd5b5061015e61017a3660046110b5565b610699565b34801561018a575f80fd5b5061019461012c81565b6040519081526020015b60405180910390f35b3480156101b2575f80fd5b506101d56101c1366004611149565b60056020525f908152604090205460ff1681565b604051901515815260200161019e565b3480156101f0575f80fd5b5061023b6101ff36600461109e565b60066020525f9081526040902080546001820154600283015460038401546004909401546001600160a01b0390931693919260ff909116919085565b604080516001600160a01b0390961686526020860194909452911515928401929092526060830191909152608082015260a00161019e565b34801561027e575f80fd5b5061019461028d366004611149565b60046020525f908152604090205481565b3480156102a9575f80fd5b5061015e610890565b3480156102bd575f80fd5b50600354610194565b3480156102d1575f80fd5b5060025460ff166101d5565b3480156102e8575f80fd5b5061015e6102f7366004611169565b6108a2565b348015610307575f80fd5b50610194600a81565b34801561031b575f80fd5b5061015e610909565b34801561032f575f80fd5b506101d561033e366004611149565b6001600160a01b03165f9081526005602052604090205460ff1690565b348015610366575f80fd5b5061015e61091a565b34801561037a575f80fd5b505f546040516001600160a01b03909116815260200161019e565b3480156103a0575f80fd5b5061015e6103af36600461109e565b61092a565b3480156103bf575f80fd5b506101946103ce366004611149565b6001600160a01b03165f9081526004602052604090205490565b3480156103f3575f80fd5b5061019460035481565b348015610408575f80fd5b5061015e610aa4565b34801561041c575f80fd5b506101d561042b36600461109e565b610b39565b34801561043b575f80fd5b5061015e61044a366004611149565b610bc5565b34801561045a575f80fd5b5061015e61046936600461109e565b610c40565b348015610479575f80fd5b5061050e61048836600461109e565b6040805160a0810182525f80825260208201819052918101829052606081018290526080810191909152505f90815260066020908152604091829020825160a08101845281546001600160a01b03168152600182015492810192909252600281015460ff1615159282019290925260038201546060820152600490910154608082015290565b60405161019e919081516001600160a01b0316815260208083015190820152604080830151151590820152606080830151908201526080918201519181019190915260a00190565b348015610561575f80fd5b5061015e61057036600461109e565b610cde565b61057d610d5a565b610585610db3565b345f036105a557604051631f2a200560e01b815260040160405180910390fd5b5f818152600660205260409020546001600160a01b0316156105da57604051633b9d9a8d60e21b815260040160405180910390fd5b6040805160a081018252338082523460208084018281525f8587018181524260608801908152608088018381528a84526006865292899020975188546001600160a01b0319166001600160a01b03909116178855925160018801555160028701805460ff1916911515919091179055905160038601555160049094019390935592519283529183917fc9f761cef4b498085beaa83472253ad1dbcaa175c7e97bd6893d9da4b6ab0868910160405180910390a361069660018055565b50565b6106a1610d5a565b6106a9610db3565b335f9081526005602052604090205460ff166106d85760405163729ee4a560e11b815260040160405180910390fd5b5f84815260066020526040902080546001600160a01b031661070d5760405163c0a8563160e01b815260040160405180910390fd5b600281015460ff161561073357604051631cf660bb60e31b815260040160405180910390fd5b600354816003015461074591906111b6565b4211156107655760405163ef3ceaeb60e01b815260040160405180910390fd5b6107728585858533610df9565b61078f576040516309bde33960e01b815260040160405180910390fd5b60028101805460ff191660019081179091556004808301869055335f9081526020919091526040812054918301546064906107cb9084906111cf565b6107d591906111e6565b60018401546040519192505f913391908381818185875af1925050503d805f811461081b576040519150601f19603f3d011682016040523d82523d5f602084013e610820565b606091505b5050905080610842576040516312171d8360e31b815260040160405180910390fd5b604080518881526020810184905289917f9bb5b9fff77191c79356e2cc9fbdb082cd52c3d60643ca121716890337f818e7910160405180910390a25050505061088a60018055565b50505050565b610898610f1e565b6108a0610f77565b565b6108aa610f1e565b6001600160a01b0382165f81815260056020908152604091829020805460ff191685151590811790915591519182527f5e09e79221e29a6d762b708b6fa399e730dfc027f946b2e81a31d849b2fb1fa991015b60405180910390a25050565b610911610f1e565b6108a05f610fc9565b610922610f1e565b6108a0611018565b610932610d5a565b5f81815260066020526040902080546001600160a01b03166109675760405163c0a8563160e01b815260040160405180910390fd5b600281015460ff161561098d57604051631cf660bb60e31b815260040160405180910390fd5b600354816003015461099f91906111b6565b42116109be57604051630d9fd01160e41b815260040160405180910390fd5b60028101805460ff191660019081179091558154908201546040515f926001600160a01b031691908381818185875af1925050503d805f8114610a1c576040519150601f19603f3d011682016040523d82523d5f602084013e610a21565b606091505b5050905080610a43576040516312171d8360e31b815260040160405180910390fd5b827f6d0630378727aa3fba39e2995e5d2ca401d78915b282724ee36ce7079f4b0de2604051610a91906020808252600b908201526a129bd888195e1c1a5c995960aa1b604082015260600190565b60405180910390a2505061069660018055565b610aac610f1e565b610ab4611055565b475f610ac75f546001600160a01b031690565b6001600160a01b0316826040515f6040518083038185875af1925050503d805f8114610b0e576040519150601f19603f3d011682016040523d82523d5f602084013e610b13565b606091505b5050905080610b35576040516312171d8360e31b815260040160405180910390fd5b5050565b5f818152600660209081526040808320815160a08101835281546001600160a01b0316808252600183015494820194909452600282015460ff1615159281019290925260038101546060830152600401546080820152901580610b9d575080604001515b15610baa57505f92915050565b6003548160600151610bbc91906111b6565b42119392505050565b610bcd610f1e565b6001600160a01b038116610c375760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b61069681610fc9565b335f9081526005602052604090205460ff16610c6f5760405163729ee4a560e11b815260040160405180910390fd5b600a811115610c9157604051631037c10f60e11b815260040160405180910390fd5b335f81815260046020908152604091829020805490859055825181815291820185905292917f80d7b9862e154a6b2316248fbb122ed5128ebcd35e61e4fdb65a20c133b98bf591016108fd565b610ce6610f1e565b603c811080610cf757506201518081115b15610d155760405163033091b360e51b815260040160405180910390fd5b600380549082905560408051828152602081018490527fa49f2a190aefeb56ae40dd02dc957f8fdf4923edc10cdaf59f5f9ddccf609c73910160405180910390a15050565b600260015403610dac5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610c2e565b6002600155565b60025460ff16156108a05760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610c2e565b5f60418314610e0957505f610f15565b604080516020808201899052818301889052606085811b6bffffffffffffffffffffffff191690830152825180830360540181526074830190935282519201919091207f19457468657265756d205369676e6564204d6573736167653a0a333200000000609483015260b08201819052905f9060d00160408051808303601f1901815282825280516020918201205f8085528285018085528290528a840135811a9385018490528a3560608601819052928b01356080860181905291955091939092919060019060a0016020604051602081039080840390855afa158015610ef3573d5f803e3d5ffd5b5050604051601f1901516001600160a01b038a81169116149750505050505050505b95945050505050565b5f546001600160a01b031633146108a05760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610c2e565b610f7f611055565b6002805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b611020610db3565b6002805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258610fac3390565b60025460ff166108a05760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610c2e565b5f602082840312156110ae575f80fd5b5035919050565b5f805f80606085870312156110c8575f80fd5b8435935060208501359250604085013567ffffffffffffffff808211156110ed575f80fd5b818701915087601f830112611100575f80fd5b81358181111561110e575f80fd5b88602082850101111561111f575f80fd5b95989497505060200194505050565b80356001600160a01b0381168114611144575f80fd5b919050565b5f60208284031215611159575f80fd5b6111628261112e565b9392505050565b5f806040838503121561117a575f80fd5b6111838361112e565b915060208301358015158114611197575f80fd5b809150509250929050565b634e487b7160e01b5f52601160045260245ffd5b808201808211156111c9576111c96111a2565b92915050565b80820281158282048414176111c9576111c96111a2565b5f8261120057634e487b7160e01b5f52601260045260245ffd5b50049056fea26469706673582212207e2fda86f1d5dbaf4d59b9a8dd64b115cc6ffe328b08347629f6dc43447afce064736f6c63430008140033

Verified Source Code Full Match

Compiler: v0.8.20+commit.a1b79de6 EVM: shanghai Optimization: Yes (200 runs)
Ownable.sol 83 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @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.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * 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.
 */
abstract 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() {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(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 virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}
Pausable.sol 105 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract Pausable is Context {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor() {
        _paused = false;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        _requireNotPaused();
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        _requirePaused();
        _;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        require(!paused(), "Pausable: paused");
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        require(paused(), "Pausable: not paused");
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}
ReentrancyGuard.sol 77 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;
    }

    function _nonReentrantAfter() private {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == _ENTERED;
    }
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.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 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.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}
BlobKitEscrow.sol 355 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/security/Pausable.sol";

/**
 * @title BlobKitEscrow
 * @notice Escrow contract for BlobKit blob storage payments
 * @dev Handles trustless payments for blob transaction execution
 *
 * Features:
 * - Job payment management with automatic refunds
 * - Proxy authorization and fee collection
 * - Configurable timeouts and replay protection
 * - Emergency pause functionality
 *
 * @author Zak Cole ([email protected])
 */
contract BlobKitEscrow is Ownable, ReentrancyGuard, Pausable {
    /*//////////////////////////////////////////////////////////////
                                CONSTANTS
    //////////////////////////////////////////////////////////////*/

    /// @notice Maximum proxy fee percentage (10%)
    uint256 public constant MAX_PROXY_FEE_PERCENT = 10;

    /// @notice Default job timeout (5 minutes)
    uint256 public constant DEFAULT_JOB_TIMEOUT = 5 minutes;

    /*//////////////////////////////////////////////////////////////
                                STORAGE
    //////////////////////////////////////////////////////////////*/

    /// @notice Job timeout duration in seconds
    uint256 public jobTimeout;

    /// @notice Mapping from proxy address to fee percentage
    mapping(address => uint256) public proxyFees;

    /// @notice Mapping from proxy address to authorization status
    mapping(address => bool) public authorizedProxies;

    /// @notice Job data structure
    struct Job {
        address user; // User who paid for the job
        uint256 amount; // Amount paid in wei
        bool completed; // Whether job has been completed
        uint256 timestamp; // When the job was created
        bytes32 blobTxHash; // Transaction hash of blob (set when completed)
    }

    /// @notice Mapping from job ID to job data
    mapping(bytes32 => Job) public jobs;

    /*//////////////////////////////////////////////////////////////
                                 EVENTS
    //////////////////////////////////////////////////////////////*/

    /// @notice Emitted when a new job is created with payment
    event JobCreated(bytes32 indexed jobId, address indexed user, uint256 amount);

    /// @notice Emitted when a job is completed by a proxy
    event JobCompleted(bytes32 indexed jobId, bytes32 blobTxHash, uint256 proxyFee);

    /// @notice Emitted when a job is refunded
    event JobRefunded(bytes32 indexed jobId, string reason);

    /// @notice Emitted when job timeout is updated
    event JobTimeoutUpdated(uint256 oldTimeout, uint256 newTimeout);

    /// @notice Emitted when a proxy is authorized or deauthorized
    event ProxyAuthorizationChanged(address indexed proxy, bool authorized);

    /// @notice Emitted when a proxy fee is updated
    event ProxyFeeUpdated(address indexed proxy, uint256 oldFee, uint256 newFee);

    /*//////////////////////////////////////////////////////////////
                                 ERRORS
    //////////////////////////////////////////////////////////////*/

    error JobAlreadyExists();
    error JobNotFound();
    error JobAlreadyCompleted();
    error JobExpired();
    error JobNotExpired();
    error UnauthorizedProxy();
    error InvalidProxyFee();
    error InvalidJobTimeout();
    error InvalidProof();
    error TransferFailed();
    error ZeroAmount();

    /*//////////////////////////////////////////////////////////////
                              CONSTRUCTOR
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Initialize the escrow contract
     * @param _owner Address of the contract owner
     */
    constructor(address _owner) {
        _transferOwnership(_owner);
        jobTimeout = DEFAULT_JOB_TIMEOUT;
    }

    /*//////////////////////////////////////////////////////////////
                            EXTERNAL FUNCTIONS
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Deposit payment for a blob job
     * @param jobId Unique identifier for the job
     * @dev Creates a new job with payment. Job ID must be unique.
     */
    function depositForBlob(bytes32 jobId) external payable nonReentrant whenNotPaused {
        if (msg.value == 0) revert ZeroAmount();
        if (jobs[jobId].user != address(0)) revert JobAlreadyExists();

        jobs[jobId] = Job({
            user: msg.sender,
            amount: msg.value,
            completed: false,
            timestamp: block.timestamp,
            blobTxHash: bytes32(0)
        });

        emit JobCreated(jobId, msg.sender, msg.value);
    }

    /**
     * @notice Complete a job and claim payment (proxy only)
     * @param jobId Job identifier
     * @param blobTxHash Transaction hash of the blob
     * @param proof Cryptographic proof of job completion
     * @dev Only authorized proxies can complete jobs. Includes replay protection.
     */
    function completeJob(bytes32 jobId, bytes32 blobTxHash, bytes calldata proof) external nonReentrant whenNotPaused {
        if (!authorizedProxies[msg.sender]) revert UnauthorizedProxy();

        Job storage job = jobs[jobId];
        if (job.user == address(0)) revert JobNotFound();
        if (job.completed) revert JobAlreadyCompleted();

        // Check if job is still valid (not expired)
        if (block.timestamp > job.timestamp + jobTimeout) {
            revert JobExpired();
        }

        // Verify proof (simple signature verification)
        if (!_verifyProof(jobId, blobTxHash, proof, msg.sender)) {
            revert InvalidProof();
        }

        // Mark job as completed (replay protection)
        job.completed = true;
        job.blobTxHash = blobTxHash;

        // Calculate proxy fee
        uint256 proxyFeePercent = proxyFees[msg.sender];
        uint256 proxyFee = (job.amount * proxyFeePercent) / 100;

        // Transfer entire amount to proxy (proxy covers blob costs)
        (bool success,) = payable(msg.sender).call{value: job.amount}("");
        if (!success) revert TransferFailed();

        emit JobCompleted(jobId, blobTxHash, proxyFee);
    }

    /**
     * @notice Refund an expired job
     * @param jobId Job identifier
     * @dev Anyone can trigger refunds for expired jobs
     */
    function refundExpiredJob(bytes32 jobId) external nonReentrant {
        Job storage job = jobs[jobId];
        if (job.user == address(0)) revert JobNotFound();
        if (job.completed) revert JobAlreadyCompleted();

        // Check if job has expired
        if (block.timestamp <= job.timestamp + jobTimeout) {
            revert JobNotExpired();
        }

        // Mark job as completed to prevent double refunds
        job.completed = true;

        // Refund full amount to user
        (bool success,) = payable(job.user).call{value: job.amount}("");
        if (!success) revert TransferFailed();

        emit JobRefunded(jobId, "Job expired");
    }

    /**
     * @notice Set proxy fee percentage (proxy only)
     * @param percent Fee percentage (0-10)
     * @dev Only authorized proxies can set their own fees
     */
    function setProxyFee(uint256 percent) external {
        if (!authorizedProxies[msg.sender]) revert UnauthorizedProxy();
        if (percent > MAX_PROXY_FEE_PERCENT) revert InvalidProxyFee();

        uint256 oldFee = proxyFees[msg.sender];
        proxyFees[msg.sender] = percent;

        emit ProxyFeeUpdated(msg.sender, oldFee, percent);
    }

    /*//////////////////////////////////////////////////////////////
                            OWNER FUNCTIONS
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Set job timeout duration (owner only)
     * @param _timeout New timeout in seconds
     * @dev Minimum timeout is 1 minute, maximum is 24 hours
     */
    function setJobTimeout(uint256 _timeout) external onlyOwner {
        if (_timeout < 1 minutes || _timeout > 24 hours) {
            revert InvalidJobTimeout();
        }

        uint256 oldTimeout = jobTimeout;
        jobTimeout = _timeout;

        emit JobTimeoutUpdated(oldTimeout, _timeout);
    }

    /**
     * @notice Authorize or deauthorize a proxy (owner only)
     * @param proxy Proxy address
     * @param authorized Authorization status
     */
    function setProxyAuthorization(address proxy, bool authorized) external onlyOwner {
        authorizedProxies[proxy] = authorized;
        emit ProxyAuthorizationChanged(proxy, authorized);
    }

    /**
     * @notice Pause the contract (owner only)
     * @dev Prevents new deposits and job completions
     */
    function pause() external onlyOwner {
        _pause();
    }

    /**
     * @notice Unpause the contract (owner only)
     */
    function unpause() external onlyOwner {
        _unpause();
    }

    /**
     * @notice Emergency withdrawal (owner only)
     * @dev Only usable when contract is paused
     */
    function emergencyWithdraw() external onlyOwner whenPaused {
        uint256 balance = address(this).balance;
        (bool success,) = payable(owner()).call{value: balance}("");
        if (!success) revert TransferFailed();
    }

    /*//////////////////////////////////////////////////////////////
                             VIEW FUNCTIONS
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Get job timeout duration
     * @return Current job timeout in seconds
     */
    function getJobTimeout() external view returns (uint256) {
        return jobTimeout;
    }

    /**
     * @notice Check if a job exists and get its details
     * @param jobId Job identifier
     * @return job Job details
     */
    function getJob(bytes32 jobId) external view returns (Job memory job) {
        return jobs[jobId];
    }

    /**
     * @notice Check if a job is expired
     * @param jobId Job identifier
     * @return True if job is expired
     */
    function isJobExpired(bytes32 jobId) external view returns (bool) {
        Job memory job = jobs[jobId];
        if (job.user == address(0) || job.completed) return false;
        return block.timestamp > job.timestamp + jobTimeout;
    }

    /**
     * @notice Get proxy fee for a specific proxy
     * @param proxy Proxy address
     * @return Fee percentage
     */
    function getProxyFee(address proxy) external view returns (uint256) {
        return proxyFees[proxy];
    }

    /**
     * @notice Check if a proxy is authorized
     * @param proxy Proxy address
     * @return True if proxy is authorized
     */
    function isProxyAuthorized(address proxy) external view returns (bool) {
        return authorizedProxies[proxy];
    }

    /*//////////////////////////////////////////////////////////////
                           INTERNAL FUNCTIONS
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Verify job completion proof
     * @param jobId Job identifier
     * @param blobTxHash Blob transaction hash
     * @param proof Signature proof
     * @param signer Expected signer address
     * @return True if proof is valid
     * @dev Verifies signature includes proxy address to prevent cross-proxy claims
     */
    function _verifyProof(bytes32 jobId, bytes32 blobTxHash, bytes calldata proof, address signer)
        internal
        pure
        returns (bool)
    {
        if (proof.length != 65) return false;

        // Create message hash that includes the proxy address
        bytes32 messageHash = keccak256(abi.encodePacked(jobId, blobTxHash, signer));
        bytes32 ethSignedMessageHash = keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", messageHash));

        // Extract signature components
        bytes32 r;
        bytes32 s;
        uint8 v;

        assembly {
            r := calldataload(proof.offset)
            s := calldataload(add(proof.offset, 0x20))
            v := byte(0, calldataload(add(proof.offset, 0x40)))
        }

        // Recover signer address
        address recoveredSigner = ecrecover(ethSignedMessageHash, v, r, s);
        return recoveredSigner == signer;
    }
}

Read Contract

DEFAULT_JOB_TIMEOUT 0x34ead4d3 → uint256
MAX_PROXY_FEE_PERCENT 0x5f3c2ed2 → uint256
authorizedProxies 0x360d95b6 → bool
getJob 0xf729cf0d → tuple
getJobTimeout 0x5bad4e2e → uint256
getProxyFee 0xb957a310 → uint256
isJobExpired 0xeac6b7b6 → bool
isProxyAuthorized 0x7cb46fb7 → bool
jobTimeout 0xd2889531 → uint256
jobs 0x38ed7cfc → address, uint256, bool, uint256, bytes32
owner 0x8da5cb5b → address
paused 0x5c975abb → bool
proxyFees 0x3e693b4d → uint256

Write Contract 11 functions

These functions modify contract state and require a wallet transaction to execute.

completeJob 0x2e56e38a
bytes32 jobId
bytes32 blobTxHash
bytes proof
depositForBlob 0x21e13b4e
bytes32 jobId
emergencyWithdraw 0xdb2e21bc
No parameters
pause 0x8456cb59
No parameters
refundExpiredJob 0x9f462719
bytes32 jobId
renounceOwnership 0x715018a6
No parameters
setJobTimeout 0xfd2d5006
uint256 _timeout
setProxyAuthorization 0x5e077aa0
address proxy
bool authorized
setProxyFee 0xf3c1b928
uint256 percent
transferOwnership 0xf2fde38b
address newOwner
unpause 0x3f4ba83a
No parameters

Recent Transactions

No transactions found for this address