Fundamentals of Smart Contract Security