Authentication of users and devices is one of the security issues on the internet of things (IoT). Traditionally, the authentication system is based on a centralized server, which makes it prone to various security threats and potential attacks; also, the stored data can tamper. In this paper, existing issues are resolved using Blockchain. IoT devices do not have much computational power. Blockchain technology, which uses the Proof-of-Work concept, consumes a lot of energy, which makes it not suitable for IoT devices. A new efficient scheme to reduce the computational energy of the devices is discussed, along with an authentication scheme that uses no centralized servers and makes IoT devices interact directly with Blockchain is designed and is implemented. The smart contract concept is used in this scheme, which provides users the flexibility to design there own rules for authentication. © 2020, Springer Nature Switzerland AG.