mirror of
https://github.com/arkorty/B.Tech-Project-III.git
synced 2026-04-19 12:41:48 +00:00
54 lines
1.4 KiB
Solidity
54 lines
1.4 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity ^0.8.19;
|
|
|
|
contract AgreementRegistry {
|
|
struct Agreement {
|
|
bytes32 agreementHash;
|
|
string featureType;
|
|
string summary;
|
|
uint256 timestamp;
|
|
address registeredBy;
|
|
}
|
|
|
|
mapping(string => Agreement) public agreements; // negotiationId => Agreement
|
|
string[] public agreementIds;
|
|
|
|
event AgreementRegistered(
|
|
string indexed negotiationId,
|
|
bytes32 agreementHash,
|
|
string featureType,
|
|
string summary,
|
|
uint256 timestamp
|
|
);
|
|
|
|
function registerAgreement(
|
|
string calldata negotiationId,
|
|
bytes32 agreementHash,
|
|
string calldata featureType,
|
|
string calldata summary
|
|
) external {
|
|
agreements[negotiationId] = Agreement({
|
|
agreementHash: agreementHash,
|
|
featureType: featureType,
|
|
summary: summary,
|
|
timestamp: block.timestamp,
|
|
registeredBy: msg.sender
|
|
});
|
|
agreementIds.push(negotiationId);
|
|
|
|
emit AgreementRegistered(
|
|
negotiationId, agreementHash, featureType, summary, block.timestamp
|
|
);
|
|
}
|
|
|
|
function getAgreement(string calldata negotiationId)
|
|
external view returns (Agreement memory)
|
|
{
|
|
return agreements[negotiationId];
|
|
}
|
|
|
|
function totalAgreements() external view returns (uint256) {
|
|
return agreementIds.length;
|
|
}
|
|
}
|