Logical foundations of Smart Contracts