-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathdeproject.sol
38 lines (30 loc) · 1.3 KB
/
deproject.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract DeProjectHub {
// Struct to hold project information
struct Project {
string projectName;
address owner;
string repositoryLink;
}
// Mapping to store all projects by an ID
mapping(uint256 => Project) public projects;
// Counter for project IDs
uint256 public projectCount = 0;
// Event triggered when a new project is added
event ProjectAdded(uint256 indexed projectId, string projectName, address indexed owner, string repositoryLink);
// Function to add a new project
function addProject(string memory _projectName, string memory _repositoryLink) public {
// Increment the project count for unique IDs
projectCount++;
// Store the new project
projects[projectCount] = Project(_projectName, msg.sender, _repositoryLink);
// Emit event for the added project
emit ProjectAdded(projectCount, _projectName, msg.sender, _repositoryLink);
}
// Function to get details of a project by its ID
function getProject(uint256 _projectId) public view returns (string memory, address, string memory) {
Project memory project = projects[_projectId];
return (project.projectName, project.owner, project.repositoryLink);
}
}