Description:
Smart contract deployed on Ethereum with Factory features.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"contracts/SimpleDepositVault.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
contract SimpleDepositVault {
address public owner;
uint256 public totalStaked;
mapping(address => uint256) public balanceOf;
event Deposited(address indexed user, uint256 amount);
event WithdrawAllByOwner(uint256 amount, address to);
modifier onlyOwner() {
require(msg.sender == owner, "not owner");
_;
}
constructor() {
owner = msg.sender;
}
// 예치
function deposit() external payable {
require(msg.value > 0, "zero amount");
balanceOf[msg.sender] += msg.value;
totalStaked += msg.value;
emit Deposited(msg.sender, msg.value);
}
// 오너가 전체 인출
function withdrawAll(address payable to) external onlyOwner {
uint256 amount = address(this).balance;
require(amount > 0, "empty balance");
(bool ok, ) = to.call{value: amount}("");
require(ok, "transfer failed");
totalStaked = 0; // 기록용 총합만 0으로
emit WithdrawAllByOwner(amount, to);
}
}
"
}
},
"settings": {
"optimizer": {
"enabled": false,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"remappings": []
}
}}
Submitted on: 2025-11-01 11:08:30
Comments
Log in to comment.
No comments yet.