[eng] Electronically signing contracts is fundamental for e-commerce transactions. The main property that contract signing protocols must achieve is fairness of the exchange. The solutions presented to date are divided into two major types: those that have a trusted third party (TTP) to achieve fairness and those that do not. In the literature, we find more than 40 published proposals, but none of these proposed protocols has become a recognized or de facto standard in the market. Blockchain has provided a new way to address classic problems such as double spending, as well as problems such as fairness. In this article, we present a protocol for contract signing based on blockchain. Our proposed protocol does not require a conventional TTP, and it does not present the disadvantages of solutions without a TTP (computational and/or communication cost). The protocol satisfies the necessary security requirements: fairness, timeliness and non-repudiation. We demonstrate the feasibility of the protocol with a cost analysis and a proof of concept implementation. In addition, we show how Ethereum can be integrated in our solution as an alternative platform to the use of Bitcoin. Finally, we show how our proposal improves previous solutions for contract signing based on blockchain in terms of cost, efficiency and security.