Internet of Things (IoT) is a revolutionary technology which will encompass all the aspects of our lives. Its effect can be seen in the kitchens and appliance to the industrial infrastructures and manufactures. Todays IoT hasn't reached its true potentials. Leaving all the benefits aside, there are many serious concerns which should be dealt with before the full adoption of the technology. Finding an honest service provider or a merchant among a crowd is not an easy task to handle. Furthermore, it may sound impossible to find one in the presence of fraudulent users who invariably try to double-cross the mechanism to gain benefits. Trust and Reputation Systems (TRS) have been around for decades and are helpful to evaluate the trustworthiness of an entity based on its past behavior. Therefore IoT nodes which utilize such a system can avoid hazardous trades. Conventional online TRSs are based on the central architecture which have some defects like being the single point of failure. On the other hand, previous decentralized alternatives may not do their tasks in the presence of an adversary. One of IoTs potentials is Sensing-as-a-Service. With the advent of blockchain and distributed ledgers technology, we can take a step further in decentralizing what we previously thought was impossible. Distributed ledger based TRSs have the advantages of decentralized ones and robustness of centralized models. In this thesis, a new distributed ledger using blockchain and Tangle have been introduced. A blockchain has been put in conjunction with Tangle for further robustness and security of the system. The designed TRS will sit on top of the aforementioned ledger. The results show the proposed system is well-suited for IoT devices and it considers IoT constraints. The system performs robustly in the presence of adversarial activities. Key Words:Blockchain, Distributed Ledger, Trust and Reputation System, TRS, IoT, Internet of Things, Distributed System