BLX Bank
Introduction
Example of Upgradeable Smart Contract
Environment
Engines versions
Scripts
You will need to use npm scripts to run and test this application.
Environment
This exercise is done in Solidity**. The development environment to compile, deploy, test and run the code provided by hardhat is already configured.
Tools and libraries
The tools and libraries listed below are already set-up for you.
- Hardhat: development environment to compile, deploy, test, and debug your Ethereum software
- Ethers.js: a JavaScript library to interact with Ethereum
- Waffle: a library for testing smart contracts.
- Chai: a BDD/TDD assertion library
- Solhint: a Solidity linter
Tasks
- Feature work as expected
- Tests have been written
- Quality controls are passed
#1 - BLX Token
BLXToken.sol is ERC20 token contract with BLX
symbol, Bloxify Token
name, and 18
decimals.
Token is transferable and mintable.
All user stories:
- User can get meta-information about the token - name, symbol, total supply, and decimals
- methods:
name()
,symbol()
,totalSupply()
,decimals()
- methods:
- User can get information about the balance of a given address
- method:
balanceOf(address)
- method:
- User is able to mint any number of tokens for himself
- method:
mint(uint256)
- method:
- User is able to transfer any number of currently owned tokens to any address
- method:
transfer(address, uint256)
- method:
- User is able to approve any other address to use the given number of his tokens
- method:
approve(address, uint256)
- method:
- User can get information about the allowed number of tokens of one address that can be used by another address
- method:
allowance(address, address)
- method:
- As a user that is approved to use other's tokens, user is able to transfer the allowed number
of tokens from the owner to any other address
- method:
transferFrom(address, address, uint256)
- method:
#2 - BLX Bank
BLXBank.sol is a Bank contract where users could create their accounts and can store BLX
token
The bank store information about the number of user accounts and global BLX balance.
It's also possible to get public information about any user account - date of creation, balance, and number of transactions (deposits and withdrawals).
The bank have the owner account that is able to pause and unpause deposits
All user stories:
- User can get a global bank balance of
BLX
token - User can get the address of the owner of the bank
- User is able to deposit any number of
BLX
tokens to his bank account - User is able to withdraw any number of
BLX
tokens that is available in his account - User is able to check that the global bank balance of
BLX
token changes after the deposit or withdrawal - User can get information about his account - date of creation, balance, number of transaction if account is active
- User is able to deactivate his account
- User is able to transfer funds from his bank account to another existing bank account
- User is unable to transfer funds from his bank account to an inactive bank account
- Owner is able to pause and unpause deposits to the bank
- User is unable to deposit tokens when deposits are paused
#3 - BLX Locker
BLXLocker is Extended/upgraded Bank contract and allow users to lock funds for other users.
Locked funds is possible to unlock at a specific date.
All user stories:
- User can create the lock from his bank account balance for the given address
- User can provide start time of the lock, end time of the lock, locked amount
- User can get all locks that were created for him
- User can get the amount of tokens that are unlocked in the given lock
- User is able to claim the amount of tokens that is available in the given lock
- User can get the amount of tokens that he already claimed in the given lock
- User can get the total balance of all locked tokens from all locks that were created for him
Thank you for your time and good luck! 🍀
Powered by Bloxify