## 2 Materials and Methods
### Extending WEave for Circular Economy Traceability
#### 2.2.3 Smart Contract Extensions  
We add the following key functions to be implemented in the Fabric chaincode for PC:  
* RecordReturn (productID, reasonCode): Can be invoked by RE (retailer) when a customer returns a product. This function creates a ReturnedProduct asset linked to productID. The original FinishedProduct asset could either be marked as \"inactive\" or \"returned\" status. We might also transfer ownership of the product asset to the Recycler (or to RE itself in a holding state).
* RecycleProduct (productID, outputLotID, outputType, quantity): Invoked by RC. This function first checks that productID corresponds to a returned product that is not already present in the system, either as a new item or as an item that was previously recycled or reused but not yet resold. It then creates a new asset RecycledMaterialLot with ID outputLotID of type outputType (e.g., \"cotton fiber\" or generic \"recycled textile\"), and associates the quantity (mass or count). It links productID in the new asset's metadata (as discussed). It may also mark the original product asset as \"recycled\". Multiple products can be processed together by calling this for each (or one call with multiple IDs if atomic processing is desired--implementation could vary).
* ConsumeRecycledLot (lotID, newProductBatchID): Invoked by manufacturers (RM/TX/FS). This function would allow a recycled lot to be used in a new production process. For instance, the Raw Material supplier (RM) could mix recycled cotton fiber with virgin cotton. Or the Textile mill (TX) could take recycled polyester pellets to spin into yarn. Depending on how we model it, we might let RM use recycled fiber as if it were an alternate input to otherwise virgin material. To keep it general, ConsumeRecycledLotwould mark that lot as used and perhaps create a link to the new batch. However, since our original chaincode already allowed creating new lots (with no direct concept of input aside from the chain-of-custody for quality flags), we might not need a separate function at all: we can simply allow a RawMaterialLot creation transaction to specify if it is recycled content. Alternatively, a simpler method: treat the recycled material as a subtype of raw material and allow the existing functions to include both virgin and recycled sources. For clarity in trace, we may explicitly model it, e.g., TX references either cotton from RM or recycled fiber from RC (or both). The chaincode then ties those references into the fabric asset's lineage.
* TraceProductHistory (assetID): An extension of provenance queries that not only traces the entire product history. Since a product can give rise to recycled materials that become part of new products, the provenance graph becomes a network, not just a tree. A comprehensive query might need to retrieve both ancestors and descendants of a given ID. For now, we implement a simpler approach: if querying an original product ID, it will list its components (ancestors). If querying a recycled material ID, it will list source products. If querying a new product that contains recycled content, one can trace back to the recycled lot and then to the prior product. We document how an auditor could perform these steps to obtain a fuller picture. In the future, one could write a recursive query that finds all related IDs across cycles.