In this paper, a blockchain based authentication model is proposed where the identity of each node is stored on the blockchain. The public and private blockchains are used for authentication. The authentication of Sensor Nodes (SNs) is performed at the private blockchain, whereas the public blockchain authenticates the cluster heads. The existing malicious node detection methods do not guarantee ... [Show full abstract] the authentication of the entities in Wireless Sensor Networks (WSNs). The unregistered nodes can easily access the resources of the network and perform malicious activities. Moreover, the malicious nodes broadcast wrong route information that increases packet delay and lowers packet delivery ratio. In the proposed model, the trust value is calculated in order to remove the malicious nodes. The secure routing is performed on the basis of the most trustworthy nodes in the network. The aim is to reduce the packet delay and increase the packet delivery ratio. The simulation results show that the high throughput and packet delivery ratio is achieved due to the presence of highly trusted nodes. Moreover, our proposed model detects the malicious nodes effectively.