Programming Secure Smart Contracts