PIGGY BANK

DESCRIPTION

The bank contract serves as a basic banking system for tokens. It includes functions to add tokens to the bank, deposit tokens into the bank, withdraw tokens from the bank, and retrieve token balances. The contract maintains mappings for tokens and their balances. The owner, specified during contract deployment, has additional privileges such as adding tokens and withdrawing tokens from the bank. Users can deposit tokens by transferring them from their accounts to the bank. The contract ensures that users have sufficient token balances before executing transfers.

FUNCTIONS

  1. addToken: Allows the owner to add a token to the bank by specifying its token address. Only the owner can add tokens to the bank.

  2. deposit: Allows users to deposit a specified amount of a token into the bank. It requires the user to have sufficient balance and transfers the tokens from the user's account to the bank.

  3. withdraw: Allows the owner to withdraw a specified amount of a token from the bank. It requires the owner to have a sufficient balance and transfer the tokens from the bank to the owner's account.

  4. getBalance: Retrieves the balance of a particular token that the bank is holding.

  5. owner()

EXTRA PARAMETERS

Contract Level: Easy

Utility Tags: Token Management, Deposit, Withdraw, Balance Tracking

USES

  1. Token Storage: The bank contract can be used as a secure storage mechanism for various tokens, allowing users to deposit and withdraw tokens as needed.

  2. Token Wallet: The contract can serve as a wallet for managing token balances and enabling secure transactions.

  3. Decentralized Finance (DeFi): The contract can be utilized in DeFi applications as a component for token deposit, withdrawal, and balance tracking.

  4. Token Exchange: The contract can be integrated into a decentralized exchange platform to manage token deposits and withdrawals during trading activities.

Last updated