Contract Explorer

Interactively explore smart contracts, their functions, and AI-identified vulnerabilities.

Select a Contract

Source Code: DeFiLendProtocol.sol

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

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";

contract DeFiLendProtocol is ReentrancyGuard {
    mapping(address => uint256) public balances;

    function deposit() external payable nonReentrant {
        balances[msg.sender] += msg.value;
    }

    function withdraw(uint256 amount) external nonReentrant {
        require(balances[msg.sender] >= amount, "Insufficient balance");
        balances[msg.sender] -= amount;
        (bool success, ) = msg.sender.call{value: amount}("");
        require(success, "Transfer failed.");
    }
}

  • deposit()

    Allows users to deposit ETH into the protocol.

  • withdraw(uint256 amount)

    Allows users to withdraw their deposited ETH.