mirror of
https://github.com/arkorty/B.Tech-Project-III.git
synced 2026-04-19 20:51:49 +00:00
init
This commit is contained in:
53
negot8/contracts/AgreementRegistry.sol
Normal file
53
negot8/contracts/AgreementRegistry.sol
Normal file
@@ -0,0 +1,53 @@
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user