From bcfca06ce53e4d6e2529e4db003baf03a51371c2 Mon Sep 17 00:00:00 2001 From: Harsh P Keshruwala <61151560+hpk24@users.noreply.github.com> Date: Fri, 10 Feb 2023 09:24:36 -0500 Subject: [PATCH] Create TransactionLog.sol --- TransactionLog.sol | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 TransactionLog.sol diff --git a/TransactionLog.sol b/TransactionLog.sol new file mode 100644 index 0000000..d249c8b --- /dev/null +++ b/TransactionLog.sol @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.7.0 <0.9.0; + +contract TransactionLog { + struct Log { + uint256 transactionId; + address sender; + address recipient; + uint256 amount; + uint256 timestamp; + } + + mapping (uint256 => Log) public logs; + uint256 public logCount; + + function addTransaction(address _sender, address _recipient, uint256 _amount) public { + logs[logCount] = Log(logCount, _sender, _recipient, _amount, block.timestamp); + logCount++; + } + + function getTransaction(uint256 _transactionId) public view returns (uint256, address, address, uint256, uint256) { + Log memory log = logs[_transactionId]; + return (log.transactionId, log.sender, log.recipient, log.amount, log.timestamp); + } +}