BankProject is a simple Ethereum smart contract for a basic banking system. It allows the owner of the contract to deposit, withdraw, and check their balance securely. The contract uses the SafeMath library to prevent overflows and underflows in arithmetic operations.
- Deposit Funds: Allows the contract owner to deposit funds into their account.
- Withdraw Funds: Allows the contract owner to withdraw funds from their account.
- Check Balance: Allows the contract owner to check their account balance.
- SafeMath Integration: Uses SafeMath to ensure safe arithmetic operations.
- Solidity version >0.7.0 <0.9.0
- A Solidity development environment like Remix, Truffle, or Hardhat
- MetaMask or any Ethereum wallet for deployment and interaction
-
Clone the repository or copy the contract code into your Solidity development environment.
-
Ensure you have the SafeMath library available in the same directory as your contract:
// SPDX-License-Identifier: MIT
pragma solidity >0.7.0 <0.9.0;
library safemath {
function sum(uint a, uint b) internal pure returns (uint) {
uint c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint a, uint b) internal pure returns (uint) {
require(b <= a, "SafeMath: subtraction overflow");
uint c = a - b;
return c;
}
}- Compile the contract using your chosen development environment.
- Open your Solidity development environment (e.g., Remix).
- Paste the contract code into a new file.
- Ensure the SafeMath library is in the same directory.
- Compile the contract.
- Deploy the contract to your desired Ethereum network. Ensure you have enough ETH for gas fees.
- Ensure you are connected with the owner's address.
- Call the
depositefunction and send the desired amount of ETH.
- Ensure you are connected with the owner's address.
- Call the
withdrawalfunction with the amount you want to withdraw.
- Ensure you are connected with the owner's address.
- Call the
show_balancefunction to view the current balance.
deposite_result(uint value, string message): Emitted when a deposit is successfully made.withdrawal_result(uint value, string message): Emitted when a withdrawal is successfully made.
This project is licensed under the MIT License. See the LICENSE file for details.