## 3 Methodology and Implementation
### Functions
It checks whether the product is using normal flow and not the return flow and if the product has any abnormality in its status. Then, it updates the product ownership and calls the transferOwnership function to complete the product transfer. 6. returnTransfer(): This function is doing the exact same condition checks and inherits exact logic with the transfer function, but it handles the return logic in the supply chain, so it only allows ownership change in the reverse flow. 7. transferFee(): This function transfers due to commission from one party to another. Modifier functions:  
1. productExists(): This function acts as a modifier to check if a product exists; this is an auxiliary function to help other functions with condition checks. 2. productNotExists(): This function acts as a modifier to check if a product does not exist; this is an auxiliary function to help add a product function for condition check. Internal functions:  
Figure 4: Relation map of functions of Products.sol. Figure 5: UML diagram of Products.sol. transferOwnership(): This function alters the state of the product ownership and removes the product from its owner once its ownership is passed to another party. 2. compareStrings(): Unfortunately, Solidity inherently does not include a function to compare strings, so we are using this function for string comparison; this function is a pure function, which means it does not alter any state in the chain. In Parties.sol, functions necessary for party manipulation in the supply chain organization are located. This contract also utilizes Struct.sol for object model definitions and emits an event when a new party is added to the organization or a party is removed. The functional diagram of Parties.sol and its interactions with other contracts can be seen in Figure 6, and the UML diagram for the contract can be seen in Figure 7.  
Internal functions:  
1. addPartyPrimitive(): This function adds a party to the network. It is called by the addPartyPrimitive function, and when the contract is deployed, the contract creator is the manufacturer. 2. addPartyInternal(): After condition checks, this function adds a particular party to the contract caller's party list. It is called the addPartyPrimitive function. It requires party details of the party to be created as a parameter. This function has condition checks for preventing organizations from adding themselves as to their party list or earlier in the flow, and organizations are only able to add their direct predecessor to the network. 3. getPartyList(): This function is strictly set as a view function; hence, it does not alter any state in the chain. It takes the contract caller's address and retrieves the parties registered by the contract caller. 4. getPartyDetailsInternal(): An internal view function that does not alter any state in the chain and uses contract caller's ID address as a parameter. Gets the party details of the contract callers and returns it. Figure 6: Relation map of functions of Parties.sol. Figure 7: UML diagram of Parties.sol. getParty(): Wrapper utility function for getting details of the specific party; does not alter states and has internal and view decorators and return parties struct. 6. removePartyInternal(): Utility function for removing a party from the network; has internal decorators and checks whether the requested party is not the caller's party struct, and the caller has the authorization to remove that user from the network; then, it emits an event that notifies network about the deletion of the party. Modifier functions:  
1. IsPartyExists(): This function checks whether the requested party exists in the network. 2. hasParty(): This function checks if a party already exists with the same role. It gets a role as a party role that needs to be checked and an account as an account address identifier that needs to be verified, then does condition checks on them to verify whether a party with that specific role exists and returns a boolean variable according to that. 3.