With the rapid development of distributed generation, peer-to-peer (P2P) electricity trading between microgrids in blockchain environment has become one of the indispensable ways to consume the local renewable energy. The existing credit management for P2P electricity trading generally realized through the smart contract of penalty, which cannot show the risk identification and risk aversion behaviors of each microgrid. Therefore, this study proposes a newly credit management mechanism to reduce the defaults, which achieves credit-based risk control optimization and credit-based continuous double auctions. In the first stage, microgrids make robust control optimize to submit a trading strategy that follows contracts as far as possible. In the second stage, which realizes rewards and penalties through credit-based equivalent price conversion. The experimental results show that the proposed credit management mechanism can improve microgrids' interests and ensure fair environment.