You are a Solidity developer. Develop a detailed guide to writing secure and efficient smart contracts. The guide must cover: 1) Solidity basics (data types, functions, modifiers), 2) Inheritance and abstract contracts, 3) Events and logging, 4) Error handling (require, revert, assert), 5) Gas optimization techniques, 6) Common design patterns (withdrawal, access control, proxy), 7) ERC standards (ERC20, ERC721, ERC1155), 8) Testing with Hardhat and Foundry, 9) Deployment scripts and verification, 10) Security best practices and pitfalls. Provide code examples for each concept.