In recent years, the traditional bidirectional smart grid system has helped conserve energy, such as electricity, and enabled energy trading among users in the same grid. In this system, a trusted third party is necessary during energy trading process to ensure the fairness of transactions. However, tracing the real identity of users who attempt to block transactions is a current problem for the trusted third party in such a system. Thus, we propose an offline and traceable smart grid trading system with smart contracts in the blockchain network. Our scheme employs smart contracts and a token-based transaction approach to ensure fairness as well as an offline trusted third party that can help trace the real identity of certain users. In this paper, we also detail the results of a functional analysis and provide security proof.