Skip to content
Verified contractExactMIT

ImmutablePersonalVault

Address0xd982d06d770774ca8c7f986e1a4c2df40b6aebc4
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.8.34

 

Same code

4 more contracts

 

Details

Compiler
solc 0.8.34+commit.80d5c536
Language
solidity
Optimization
No
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,023,007
Creation transaction
0xb753bf8a70…f013e44bcf

Vault.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

/**
 * @title ImmutablePersonalVault
 * @notice A personal vault contract hardcoded exclusively to wallet 0xD95fb8d5043db98398b7a782ee33f76Ae6066F8a.
 * @dev Owner address is immutable and hardcoded. No ownership transfer can ever occur.
 */
contract ImmutablePersonalVault {
    // Hardcoded owner address - Immutable means it cannot be altered post-deployment.
    address public immutable OWNER = 0xD95fb8d5043db98398b7a782ee33f76Ae6066F8a;

    // Events for tracking deposits and withdrawals on-chain
    event Deposit(address indexed sender, uint256 amount);
    event Withdraw(address indexed owner, uint256 amount);
    event WithdrawToken(address indexed token, address indexed owner, uint256 amount);

    // Custom Error for gas-efficient access control checks
    error Unauthorized();
    error TransferFailed();

    /// @dev Restricts execution exclusively to the hardcoded owner address
    modifier onlyOwner() {
        if (msg.sender != OWNER) {
            revert Unauthorized();
        }
        _;
    }

    /// @notice Receive native currency (ETH/BNB/MATIC depending on network)
    receive() external payable {
        emit Deposit(msg.sender, msg.value);
    }

    /// @notice Fallback function to accept funds sent with data
    fallback() external payable {
        emit Deposit(msg.sender, msg.value);
    }

    /// @notice Deposit funds directly with an event trigger
    function deposit() external payable {
        emit Deposit(msg.sender, msg.value);
    }

    /// @notice Withdraw a specific amount of native funds to your hardcoded wallet
    function withdraw(uint256 amount) external onlyOwner {
        require(address(this).balance >= amount, "Insufficient vault balance");
        
        (bool success, ) = OWNER.call{value: amount}("");
        if (!success) revert TransferFailed();
        
        emit Withdraw(OWNER, amount);
    }

    /// @notice Withdraw the ENTIRE native currency balance of the vault
    function withdrawAll() external onlyOwner {
        uint256 balance = address(this).balance;
        require(balance > 0, "Vault balance is zero");

        (bool success, ) = OWNER.call{value: balance}("");
        if (!success) revert TransferFailed();

        emit Withdraw(OWNER, balance);
    }

    /// @notice Emergency/utility function to recover ERC-20 tokens accidentally sent to the vault
    function withdrawERC20(address tokenAddress) external onlyOwner {
        // Minimal ERC20 interface execution
        (bool success, bytes memory data) = tokenAddress.call(
            abi.encodeWithSignature("balanceOf(address)", address(this))
        );
        require(success, "Failed to fetch token balance");
        uint256 balance = abi.decode(data, (uint256));
        require(balance > 0, "No tokens to withdraw");

        (bool transferSuccess, bytes memory returnData) = tokenAddress.call(
            abi.encodeWithSignature("transfer(address,uint256)", OWNER, balance)
        );
        require(transferSuccess && (returnData.length == 0 || abi.decode(returnData, (bool))), "Token transfer failed");

        emit WithdrawToken(tokenAddress, OWNER, balance);
    }

    /// @notice Helper function to view vault balance
    function getBalance() external view returns (uint256) {
        return address(this).balance;
    }
}
Compiler settingsShow
{
  "optimizer": {
    "runs": 200,
    "enabled": false
  },
  "remappings": []
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.