The fog computing is the emerging technology to compute, store, control and connecting smart devices with each other using cloud computing. The Internet of Things (IoT) is an architecture of uniquely identified interrelated physical things, these physical things are able to communicate with each other and can transmit and receive information. This research presents a framework of the combination of the Internet of Things (IoT) and Fog computing. The blockchain is also the emerging technology that provides a hyper, distributed, public, authentic ledger to record the transactions. Blockchains technology is a secured technology that can be a boon for the next generation computing. The combination of fog, blockchains, and IoT creates a new opportunity in this area. In this research, the author presents a middleware framework based on the blockchain, fog, and IoT. The framework is implemented and tested. The results are found positive.