Skip to content

SeyedMojtaba1/Simple-Bank-Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

BankProject

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.

Table of Contents

Features

  • 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.

Requirements

  • 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

Installation

  1. Clone the repository or copy the contract code into your Solidity development environment.

  2. 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;
    }
}
  1. Compile the contract using your chosen development environment.

Usage

Deploying the Contract

  1. Open your Solidity development environment (e.g., Remix).
  2. Paste the contract code into a new file.
  3. Ensure the SafeMath library is in the same directory.
  4. Compile the contract.
  5. Deploy the contract to your desired Ethereum network. Ensure you have enough ETH for gas fees.

Depositing Funds

  1. Ensure you are connected with the owner's address.
  2. Call the deposite function and send the desired amount of ETH.

Withdrawing Funds

  1. Ensure you are connected with the owner's address.
  2. Call the withdrawal function with the amount you want to withdraw.

Checking Balance

  1. Ensure you are connected with the owner's address.
  2. Call the show_balance function to view the current balance.

Events

  • 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.

License

This project is licensed under the MIT License. See the LICENSE file for details.


About

In this project I modeled the operation of a bank in a simple way by solidity. This bank can do (depositing/withdrawal/showing balance). also I use safemath library for my subtraction and summation in this project.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors