Trust has played a pivotal role in the evolution of modern human societies, and it continues to be an essential underpinning of our social interactions. It is therefore important that we develop rigorous mathematical foundations that will enable us to better understand what promotes and what erodes trust and how to best preserve trustworthiness. To that effect we here propose a trust game, wherein investors, trustworthy trustees, and untrustworthy trustees compete for assets subject to a third-party evaluation system that oversees and modifies each individual reputation. We use Monte Carlo simulations on social networks to determine critical values of the degree of rationality and the reputation threshold that warrant high levels of trust and social wealth. We show that if investors have access to the reputation scores of trustees, the fraction of untrustworthy trustees drops if only the degree of rationality is sufficiently large, and this irrespective of the reputation threshold that determines the cutoff for untrustworthiness. But even though investors are allowed irrational investments, trust can still proliferate if the reputation threshold is sufficiently high. Our results thus formalize essential mechanisms of trust in social networks, which also outline policies to diminish untrustworthiness that can be employed in real life.