ETH Price: $1,779.30 (+9.88%)
 

Overview

ETH Balance

0 ETH

ETH Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Withdraw125837142024-04-01 7:32:55386 days ago1711956775IN
0xddfEcC36...27E9410C4
0 ETH0.000003290.03240466
Deposit125837022024-04-01 7:32:31386 days ago1711956751IN
0xddfEcC36...27E9410C4
0.001 ETH0.000002340.03260411

Latest 1 internal transaction

Parent Transaction Hash Block From To
125837142024-04-01 7:32:55386 days ago1711956775
0xddfEcC36...27E9410C4
0.001 ETH

Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
EthWallet

Compiler Version
v0.8.22+commit.4fc1097e

Optimization Enabled:
No with 200 runs

Other Settings:
paris EvmVersion
File 1 of 1 : EthWallet.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/* errors */
error EthWallet__DepositMustBeAboveZero();
error EthWallet__WithdrawalMustBeAboveZero();
error EthWallet__WalletIsEmpty();
error EthWallet__WithdrawalExceedsUserBalance();
error EthWallet_InsufficientContractBalance();

/* events */
event DepositSuccess(address depositer, uint amount);
event WithdrawSuccess(address withdrawer, uint amount);

contract EthWallet {
    /* structs */
    struct User {
        address ownerAddress;
        uint userBalance;
        uint withdrawnToday;
        uint lastWithdrawalTime;
    }

    /* mappings */
    mapping(address => User) private users;

    /* state variables */
    uint public constant dailyWithdrawalLimit = 10 ether;
    bool private locked;
    uint currentBalance;

    modifier withdrawalLimitCheck(uint _withdrawalAmount) {
        User storage currentUser = users[msg.sender];

        // Reset withdrawal amount if a new day has started
        if (isNewDay(currentUser.lastWithdrawalTime)) {
            currentUser.withdrawnToday = 0;
        }

        // Check if the requested withdrawal exceeds the daily limit
        require(
            currentUser.withdrawnToday + _withdrawalAmount <=
                dailyWithdrawalLimit,
            "Daily withdrawal limit exceeded"
        );

        // Update user's withdrawal data
        currentUser.withdrawnToday += _withdrawalAmount;
        currentUser.lastWithdrawalTime = block.timestamp;
        _;
    }

    modifier sufficientBalance(uint _withdrawalAmount) {
        uint withdrawalAmount = _withdrawalAmount;
        currentBalance = users[msg.sender].userBalance;
        if (currentBalance == 0) {
            revert EthWallet__WalletIsEmpty();
        } else if (_withdrawalAmount > address(this).balance) {
            revert EthWallet_InsufficientContractBalance();
        } else if (_withdrawalAmount > currentBalance) {
            revert EthWallet__WithdrawalExceedsUserBalance();
        }
        _;
    }

    modifier noReeentrant() {
        require(!locked, "No re_entrancy");
        locked = true;
        _;
        locked = false;
    }

    // Helper function to determine if a new day has started
    function isNewDay(uint lastWithdrawalTime) internal view returns (bool) {
        uint currentDay = block.timestamp / 1 days;
        uint lastWithdrawalDay = lastWithdrawalTime / 1 days;
        return currentDay > lastWithdrawalDay;
    }

    function deposit() public payable {
        require(msg.value > 0, "Deposit must be above zero!");

        uint depositAmount = msg.value;

        if (users[msg.sender].userBalance > 0) {
            users[msg.sender].userBalance += depositAmount;
        } else {
            users[msg.sender] = User(msg.sender, depositAmount, 0, 0);
        }

        emit DepositSuccess(msg.sender, depositAmount);
    }

    function withdraw(
        uint _withdrawalAmount
    )
        external
        withdrawalLimitCheck(_withdrawalAmount)
        sufficientBalance(_withdrawalAmount)
        noReeentrant
    {
        require(_withdrawalAmount > 0, "Withdrawal must be above zero!");

        uint withdrawalAmount = _withdrawalAmount;

        // Update user Balance
        users[msg.sender].userBalance -= withdrawalAmount;

        // Process withdrawal
        payable(msg.sender).transfer(withdrawalAmount);

        emit WithdrawSuccess(msg.sender, withdrawalAmount);
    }

    function getUserBalance() public view returns (uint) {
        if (users[msg.sender].ownerAddress != address(0)) {
            return users[msg.sender].userBalance;
        } else {
            return 0;
        }
    }
}

Settings
{
  "evmVersion": "paris",
  "optimizer": {
    "enabled": false,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "metadata": {
    "useLiteralContent": true
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

API
[{"inputs":[],"name":"EthWallet_InsufficientContractBalance","type":"error"},{"inputs":[],"name":"EthWallet__WalletIsEmpty","type":"error"},{"inputs":[],"name":"EthWallet__WithdrawalExceedsUserBalance","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"depositer","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"DepositSuccess","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"withdrawer","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawSuccess","type":"event"},{"inputs":[],"name":"dailyWithdrawalLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"deposit","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"getUserBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_withdrawalAmount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b50610b73806100206000396000f3fe60806040526004361061003f5760003560e01c80632e1a7d4d146100445780637620843a1461006d578063b7013dc114610098578063d0e30db0146100c3575b600080fd5b34801561005057600080fd5b5061006b600480360381019061006691906107c4565b6100cd565b005b34801561007957600080fd5b50610082610458565b60405161008f9190610800565b60405180910390f35b3480156100a457600080fd5b506100ad610464565b6040516100ba9190610800565b60405180910390f35b6100cb61054b565b005b8060008060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020905061011d8160030154610756565b1561012d57600081600201819055505b678ac7230489e80000828260020154610146919061084a565b1115610187576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161017e906108db565b60405180910390fd5b8181600201600082825461019b919061084a565b925050819055504281600301819055508260008190506000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010154600281905550600060025403610235576040517f141b945300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b4782111561026f576040517f10af68bd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6002548211156102ab576040517ff23c919700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600160009054906101000a900460ff16156102fb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102f290610947565b60405180910390fd5b60018060006101000a81548160ff02191690831515021790555060008511610358576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161034f906109b3565b60405180910390fd5b6000859050806000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160008282546103ae91906109d3565b925050819055503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050501580156103fb573d6000803e3d6000fd5b507f95e1b0070dbccc052f124fa5143644dca4cc74c53bf1d0fe68ff7295f61cdc0c338260405161042d929190610a48565b60405180910390a1506000600160006101000a81548160ff0219169083151502179055505050505050565b678ac7230489e8000081565b60008073ffffffffffffffffffffffffffffffffffffffff166000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610543576000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101549050610548565b600090505b90565b6000341161058e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161058590610abd565b60405180910390fd5b600034905060008060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010154111561063a57806000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101600082825461062e919061084a565b9250508190555061071a565b60405180608001604052803373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020016000815260200160008152506000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506020820151816001015560408201518160020155606082015181600301559050505b7f60bbf3f279de4eb569cec9565dbd645a7d269bef7d4b20083d8da32ddd6e9460338260405161074b929190610a48565b60405180910390a150565b60008062015180426107689190610b0c565b90506000620151808461077b9190610b0c565b905080821192505050919050565b600080fd5b6000819050919050565b6107a18161078e565b81146107ac57600080fd5b50565b6000813590506107be81610798565b92915050565b6000602082840312156107da576107d9610789565b5b60006107e8848285016107af565b91505092915050565b6107fa8161078e565b82525050565b600060208201905061081560008301846107f1565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006108558261078e565b91506108608361078e565b92508282019050808211156108785761087761081b565b5b92915050565b600082825260208201905092915050565b7f4461696c79207769746864726177616c206c696d697420657863656564656400600082015250565b60006108c5601f8361087e565b91506108d08261088f565b602082019050919050565b600060208201905081810360008301526108f4816108b8565b9050919050565b7f4e6f2072655f656e7472616e6379000000000000000000000000000000000000600082015250565b6000610931600e8361087e565b915061093c826108fb565b602082019050919050565b6000602082019050818103600083015261096081610924565b9050919050565b7f5769746864726177616c206d7573742062652061626f7665207a65726f210000600082015250565b600061099d601e8361087e565b91506109a882610967565b602082019050919050565b600060208201905081810360008301526109cc81610990565b9050919050565b60006109de8261078e565b91506109e98361078e565b9250828203905081811115610a0157610a0061081b565b5b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610a3282610a07565b9050919050565b610a4281610a27565b82525050565b6000604082019050610a5d6000830185610a39565b610a6a60208301846107f1565b9392505050565b7f4465706f736974206d7573742062652061626f7665207a65726f210000000000600082015250565b6000610aa7601b8361087e565b9150610ab282610a71565b602082019050919050565b60006020820190508181036000830152610ad681610a9a565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000610b178261078e565b9150610b228361078e565b925082610b3257610b31610add565b5b82820490509291505056fea2646970667358221220de9ab1ff976cbbe66f246dffc4b52c4d864dec66676168dbce8bc9b5fbc0879c64736f6c63430008160033

Deployed Bytecode

0x60806040526004361061003f5760003560e01c80632e1a7d4d146100445780637620843a1461006d578063b7013dc114610098578063d0e30db0146100c3575b600080fd5b34801561005057600080fd5b5061006b600480360381019061006691906107c4565b6100cd565b005b34801561007957600080fd5b50610082610458565b60405161008f9190610800565b60405180910390f35b3480156100a457600080fd5b506100ad610464565b6040516100ba9190610800565b60405180910390f35b6100cb61054b565b005b8060008060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020905061011d8160030154610756565b1561012d57600081600201819055505b678ac7230489e80000828260020154610146919061084a565b1115610187576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161017e906108db565b60405180910390fd5b8181600201600082825461019b919061084a565b925050819055504281600301819055508260008190506000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010154600281905550600060025403610235576040517f141b945300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b4782111561026f576040517f10af68bd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6002548211156102ab576040517ff23c919700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600160009054906101000a900460ff16156102fb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102f290610947565b60405180910390fd5b60018060006101000a81548160ff02191690831515021790555060008511610358576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161034f906109b3565b60405180910390fd5b6000859050806000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160008282546103ae91906109d3565b925050819055503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050501580156103fb573d6000803e3d6000fd5b507f95e1b0070dbccc052f124fa5143644dca4cc74c53bf1d0fe68ff7295f61cdc0c338260405161042d929190610a48565b60405180910390a1506000600160006101000a81548160ff0219169083151502179055505050505050565b678ac7230489e8000081565b60008073ffffffffffffffffffffffffffffffffffffffff166000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610543576000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101549050610548565b600090505b90565b6000341161058e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161058590610abd565b60405180910390fd5b600034905060008060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010154111561063a57806000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101600082825461062e919061084a565b9250508190555061071a565b60405180608001604052803373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020016000815260200160008152506000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506020820151816001015560408201518160020155606082015181600301559050505b7f60bbf3f279de4eb569cec9565dbd645a7d269bef7d4b20083d8da32ddd6e9460338260405161074b929190610a48565b60405180910390a150565b60008062015180426107689190610b0c565b90506000620151808461077b9190610b0c565b905080821192505050919050565b600080fd5b6000819050919050565b6107a18161078e565b81146107ac57600080fd5b50565b6000813590506107be81610798565b92915050565b6000602082840312156107da576107d9610789565b5b60006107e8848285016107af565b91505092915050565b6107fa8161078e565b82525050565b600060208201905061081560008301846107f1565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006108558261078e565b91506108608361078e565b92508282019050808211156108785761087761081b565b5b92915050565b600082825260208201905092915050565b7f4461696c79207769746864726177616c206c696d697420657863656564656400600082015250565b60006108c5601f8361087e565b91506108d08261088f565b602082019050919050565b600060208201905081810360008301526108f4816108b8565b9050919050565b7f4e6f2072655f656e7472616e6379000000000000000000000000000000000000600082015250565b6000610931600e8361087e565b915061093c826108fb565b602082019050919050565b6000602082019050818103600083015261096081610924565b9050919050565b7f5769746864726177616c206d7573742062652061626f7665207a65726f210000600082015250565b600061099d601e8361087e565b91506109a882610967565b602082019050919050565b600060208201905081810360008301526109cc81610990565b9050919050565b60006109de8261078e565b91506109e98361078e565b9250828203905081811115610a0157610a0061081b565b5b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610a3282610a07565b9050919050565b610a4281610a27565b82525050565b6000604082019050610a5d6000830185610a39565b610a6a60208301846107f1565b9392505050565b7f4465706f736974206d7573742062652061626f7665207a65726f210000000000600082015250565b6000610aa7601b8361087e565b9150610ab282610a71565b602082019050919050565b60006020820190508181036000830152610ad681610a9a565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000610b178261078e565b9150610b228361078e565b925082610b3257610b31610add565b5b82820490509291505056fea2646970667358221220de9ab1ff976cbbe66f246dffc4b52c4d864dec66676168dbce8bc9b5fbc0879c64736f6c63430008160033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.