While smart factories are becoming widely recognized as a fundamental concept of Industry 4.0, their implementation has posed several challenges insofar that they generate, process, and exchange vast amounts of security critical and privacy sensitive data, which makes them attractive targets of attacks and unauthorized access. Security requirements in such scenario include integrity, confidentiality, traceability and notarization of exchanged data in the one hand plus access control, privacy and trust in the other one. In this context, we design a distributed resource management framework using the emerging smart contracts technology for Industry 4.0 applications and more specifically for smart factories environments. This last, named DRMF, utilizes three Ethereum smart contracts specifically a Governance Contract (GC), an Access Contract (AC) and a Lookup Contract (LC) that are respectively responsible for the registration of new joining entities as well as those requesting consensus partaking permissions, second the dynamic access authorization and third the mapping between the required services and contracts ensuring their management. Using the blockchain technology, this framework is expected to achieve distributed, flexible, verifiable and trustworthy access control in addition to a transparent, traceable and notarized resource usage and sharing. Results from a real implementation plus performance evaluation prove the proposed concept and demonstrate its feasibility.