In next-generation computing, the role of cloud, internet and smart devices will be capacious. Nowadays we all are familiar with the word smart. This word is used a number of times in our daily life. The Internet of Things (IoT) will produce remarkable different kinds of information from different resources. It can store big data in the cloud. The fog computing acts as an interface between cloud and IoT. The extension of fog in this framework works on physical things under IoT. The IoT devices are called fog nodes, they can have accessed anywhere within the range of the network. The blockchain is a novel approach to record the transactions in a sequence securely. Developing a new blockchains based middleware framework in the architecture of the Internet of Things is one of the critical issues of wireless networking where resolving such an issue would result in constant growth in the use and popularity of IoT. The proposed research creates a framework for providing the middleware framework in the internet of smart devices network for the internet of things using blockchains technology. Our main contribution links a new study that integrates blockchains to the Internet of things and provides communication security to the internet of smart devices.