Smart Contracts and Bitcoin

Enter bitcoin

Since its origin, bitcoin comes with a limited but powerful scripting language to express transfer of ownership of coins. When a transaction sends coins from A to B, there’s actually a script expressing the conditions in which B can take ownership of those coins. In the simple case, B needs to produce a cryptographic signature corresponding to a certain public key. In a general sense, a transaction output sets the rules (via a script) by which it can be spent, and a future transaction needs to produce the data input for that script to execute successfully.

Multisig

The first ever alternative behavior attached to bitcoins. It’s really simple to understand: instead of having a single entity own the coins, we set a group of entities (identified by their public keys) that will control the funds. Additionally, we can configure how many of those owners are needed to sign off any use of those bitcoins.

Payment Channels

Payment channels are another simple yet powerful smart contract currently being used. It allows for a continuous flow of off-chain micropayments to be negotiated between two parties in a trustless manner. In this way, one party can provide a service (the provider) in exchange for bitcoins from the other (the consumer), in a truly pay-as-you-go mechanism. There are several similar schemes proposed that implement this high-level behavior, but this one I find most elegant:

Conclusion

Smart contracts allow to automate interactions between parties using code. It should be possible to create a script typification that improves how we talk about, think of, and develop smart contracts. One can then think of composing and combining different contracts to achieve more complex high-level behaviors (e.g Payment Channels use a multisig contract internally). A simple scheme will be proposed in a future post.

--

--

In search of truth and good stories to tell.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store