From 0a634a3eceb1b1d672b8072b454f1f3d69e9124f Mon Sep 17 00:00:00 2001 From: KOSASIH Date: Sun, 16 Jun 2024 11:40:29 +0700 Subject: [PATCH] Create PIBankUtils.sol --- .../contracts/PI-bank/utils/PIBankUtils.sol | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 blockchain_integration/pi_network/contracts/PI-bank/utils/PIBankUtils.sol diff --git a/blockchain_integration/pi_network/contracts/PI-bank/utils/PIBankUtils.sol b/blockchain_integration/pi_network/contracts/PI-bank/utils/PIBankUtils.sol new file mode 100644 index 000000000..696d6987d --- /dev/null +++ b/blockchain_integration/pi_network/contracts/PI-bank/utils/PIBankUtils.sol @@ -0,0 +1,15 @@ +pragma solidity ^0.8.0; + +library PIBankUtils { + function calculateInterestRate(uint256 _balance, uint256 _interestRate) internal pure returns (uint256) { + return _balance * _interestRate / 100; + } + + function generateRandomNumber(uint256 _seed) internal view returns (uint256) { + return uint256(keccak256(abi.encodePacked(_seed, block.timestamp))); + } + + function encodeData(string memory _data) internal pure returns (bytes memory) { + return abi.encodePacked(_data); + } +}