Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nisum-hackathon-2023
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Hammad ul Azeem
nisum-hackathon-2023
Commits
e0b17420
Commit
e0b17420
authored
Jun 08, 2023
by
Hammad ul Azeem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
46dcfe7e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
0 deletions
+39
-0
SupplyChain.sol
SupplyChain.sol
+39
-0
No files found.
SupplyChain.sol
0 → 100644
View file @
e0b17420
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract SupplyChain {
enum SupplyChainStatus { Created, InTransit, Delivered }
struct Item {
uint256 id;
string name;
uint256 quantity;
SupplyChainStatus status;
}
mapping(uint256 => Item) public items;
uint256 public itemCount;
event ItemCreated(uint256 indexed id, string name, uint256 quantity);
event ItemInTransit(uint256 indexed id);
event ItemDelivered(uint256 indexed id);
function createItem(string memory _name, uint256 _quantity) external {
itemCount++;
items[itemCount] = Item(itemCount, _name, _quantity, SupplyChainStatus.Created);
emit ItemCreated(itemCount, _name, _quantity);
}
function markItemInTransit(uint256 _id) external {
require(items[_id].status == SupplyChainStatus.Created, "Item is not in a created state");
items[_id].status = SupplyChainStatus.InTransit;
emit ItemInTransit(_id);
}
function markItemDelivered(uint256 _id) external {
require(items[_id].status == SupplyChainStatus.InTransit, "Item is not in transit");
items[_id].status = SupplyChainStatus.Delivered;
emit ItemDelivered(_id);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment