diff --git a/smart-contracts/contracts/DAppContract.sol b/smart-contracts/contracts/DAppContract.sol new file mode 100644 index 000000000..667740d08 --- /dev/null +++ b/smart-contracts/contracts/DAppContract.sol @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +contract DAppContract { + string public name; + address public owner; + mapping(address => uint256) public balances; + + event Deposit(address indexed user, uint256 amount); + event Withdraw(address indexed user, uint256 amount); + + constructor(string memory _name) { + name = _name; + owner = msg.sender; + } + + function deposit() external payable { + require(msg.value > 0, "Deposit amount must be greater than 0"); + balances[msg.sender] += msg.value; + emit Deposit(msg.sender, msg.value); + } + + function withdraw(uint256 amount) external { + require(balances[msg.sender] >= amount, "Insufficient balance"); + balances[msg.sender] -= amount; + payable(msg.sender).transfer(amount); + emit Withdraw(msg.sender, amount); + } + + function getBalance() external view returns (uint256) { + return balances[msg.sender]; + } +}