Slab Token Storage is a smart contract that allows users to deposit a specific type of ERC20 tokens into predefined slabs based on the deposit amount. The contract keeps track of the remaining capacities of each slab and assigns a deposit to the highest available slab. Users can also withdraw their tokens and query the slab index of a specific depositor.
These instructions will help you set up and use the Slab Token Storage smart contract on your local machine.
- Clone the repository:
git clone https://github.com/your_username/slab-token-storage.git
- Change the current directory to the project root:
cd slab-token-storage
- Install the dependencies:
npm install
- Compile the smart contracts:
npx hardhat compile
- Deploy the ERC20 token contract and Slab Token Storage contract to the Hardhat Network:
npx hardhat run scripts/deploy.js --network <network-name>
You can interact with the smart contract using Hardhat tasks or web3.js/ethers.js library in your application. The available functions in the Slab Token Storage contract are:
deposit(uint256 _amount)
: Deposit_amount
of ERC20 tokens from the user into the contract.withdraw()
: Withdraw the user's tokens from the contract.getSlabOfDepositor(address _depositor)
: Returns the slab index for the given depositor address.
- Run the unit tests:
npx hardhat test
- Run code coverage (optional):
npx hardhat coverage
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update the tests as appropriate.
This project is licensed under the MIT License. See the LICENSE file for details.