This paper proposes the SmartCoder-R1 framework to address security and explainability challenges in smart contract generation using large-scale language models (LLMs). SmartCoder-R1 is developed through three steps: continuous pretraining (CPT), long-chain reasoning supervised learning (L-CoT SFT), and security-aware group-relative policy optimization (S-GRPO). CPT specializes the model, and L-CoT SFT trains the model to mimic human security analysis using 7,998 expert-verified reason and code samples. Finally, S-GRPO refines the generation policy by considering security compliance, formal correctness, and compilation success. Evaluation results on 756 real-world function benchmarks show that SmartCoder-R1 achieves top performance in five key metrics (ComPass, VulRate, SafeAval, FuncRate, and FullRate), with FullRate improving by 45.79% over the previous best-performing model, DeepSeek-R1. Human evaluations of the generated inferences also scored highly in terms of functionality, security, and clarity.