Based on:
Massimo Bartoletti and Roberto Zunino, 2018, January. "BitML: a calculus for Bitcoin smart contracts"
and
Atzei, N., Bartoletti, M., Lande, S. and Zunino, R., 2018, February. "A formal model of Bitcoin transactions"
The compilation is based on the following Agda formalizations:
Browse the Agda code in HTML here.