Beyond cryptocurrencies, blockchain technologies have shown great potential in enabling a wealth of decentralized applications (DApps), including but not limited to trustworthy auction, election, autonomous organization. While public blockchains are well recognized to allow participants mutually unbeknownst to achieve consensus, financial/business organizations also find great interest in consortium blockchains for better organizational collaborations. We will touch both types of blockchain and corresponding applications in this tutorial. In particular, we will summarize existing blockchain technologies and applications, elaborate the principles of designing and implementing secure DApps, and analyze the security concerns therein. Through concrete examples, we will discuss common practices and pitfalls, such as on-chain/off-chain interaction, randomness generation, and various corner cases. If time permits, we will also go through the implementation of the cloud-based blockchain backbone that powers this tutorial, possibly covering a layered architecture, and discuss deployment choices and security issues along the way. The tutorial will be interspersed with revisiting the security and implementation rules, so that participants are expected to readily apply the tutorial content into real-world practice. The design principles elaborated in this tutorial will be transferable to participants' development of secure and trustworthy blockchain applications and systems in their own workplaces.