Hey Baby, I Think I Wanna Marry You (On the Blockchain) šŸ’’

Written by pabloruiz55 | Published 2017/11/07
Tech Story Tags: ethereum | solidity | blockchain | smart-contracts | development

TLDRvia the TL;DR App

The concept of matrimony has existed for tens of thousands of years, but only a few hundred years ago they started involving actual contracts or even a ceremony. As a matter of fact, even though the Bible features lots of married people, there are no descriptions of ceremoniesĀ According to this article:

The only ā€œceremonyā€ I can find in the Bible is Tobit 7:12ā€“14 in which a father places the hand of his daughter in the hand of the husband, and then writes a contract.[ā€¦]Ā No vows, no priest, no ritual, no prayer, no pronouncement, no license, no registration.

Of course, this has changed in the past hundreds of years. Today, for a marriage to be considered legal it has to be recognized by the State. Each culture, religion, country and state also have their own rules to determine what constitutes a valid marriage. Fro example there are some places where same-sex marriages are permitted and others places where they are not, child marriages and cousin marriages are permitted in some countries or cultures, some countries allow for men to marry more than one woman, etc, etc.

How the ceremonies are performed also vary from place to place. For example, some states and countries require the presence of witnesses during the ceremony. According to what I could find around online, they were mostly required to ensure that neither spouse has been forced into the wedding. Today, they are chosen for being close friends or relatives whom the couple wants to share that special moment with.

Getting Married on the Blockchain

In this article, I intend to approach how a marriage contract could look like on the Blockchain. For this particular contract, Iā€™ve removed the need of witnesses and made the matrimony process as simple as possible, but without leaving out the possibility of having several authorities or registries that define their own rules for officiating marriages.

The marriage process is structured as follows:There is a Marriage Registry that keeps a record of all the marriage proposals and officiated marriages. If someone wants to get married to someone else, all they have to do is to issue a request to the registry, which will verify that both spouses can actually get married.

Being able to get married just means, in the context of this registry, making sure that each person has not already married someone else. There could be other registries with different set of rules given that, as I mentioned before, marriage rules vary from place to place.For example, there could be a Marriage Registry that requires both spouses to be over 18 years old; or both of them to be from the same country or even allow a person to be married to more than one person.

Or even allow people to marry theirĀ cousins.

The other component is the Marriage contract which holds the information of the marriage such as the addresses of the spouses; the status of the matrimony; the date the ceremony was performed, and it is also the main point of contact for the interaction between spouses, such as accepting one anotherā€™s proposal or filing for a divorce.

Itā€™s worth mentioning too that the MarriageRegistry contains a few functions that allow an external party to obtain information about a people from it. Anyone can query the registry for the following information:

  • Given any of the spouses, anyone can retrieve the Marriage contract that bonded them.
  • Given a Marriage contract address, anyone can get he ā€œMarriage Certificateā€ containing the address of both spouses and the date they married.
  • Given one of the spouses, anyone can find out who they are married to.
  • Given two spouses, anyone can find out if they are married or not.
  • Given one of the spouses, anyone can find out if that person is married or not.

These functions are meant to be used, mainly, by other entities that care about a person being married or single for their own processes and procedures. For example, a bank could query this registry to obtain information about the marital status of a couple asking for a joint mortgage.

How to use the contracts:

The MarriageRegistry contract has been deployed in Ropsten testnet and verified through Etherscan at address: 0x57f38682c5E802f78cCC71B2D2932230b1C41c47You can find the source code for the two contracts involved (Marriage.sol and MarriageRegistry.sol) on my Github Repository.

You can use them to marry someone like this:

**1-**šŸ’ Propose marriage to someone: Marriage contracts can only be generated by the MarriageRegistry contract, so, if you want to propose to someone, all you have to do to initiate the process is calling the proposeMarriage() function on MarriageRegistry and specify the address of the person you are proposing to.

2- šŸŒ¹ Have your significant other accept or reject the proposal: The person being proposed marriage now has the option to either reject or accept the proposal. If they reject the proposal by calling rejectProposal() on the newly created Marriage contract, the marriage is off and the contract is destroyed. On the other hand, if they call acceptProposal() then itā€™s official, you are married!Ā When you called proposeMarriage() it generated a new Marriage contract tying both you and the recipient of the proposal. You have to share the address of that contract with the other person for them to act upon it. You can either find it on Etherscan.com or call getMarriageContract() on MarriageRegistry by passing either address as parameter.

3- šŸ“™ Get your marriage certificate: You (or anyone) can query the MarriageRegistry to get the marriage certificate stating the address of both spouses as well as the marriage date. To get the marriage certificate just call getMarriageCertificate() and pass the marriage contract address as parameter.

4-šŸ’” Getting divorced: Sometimes married life is not as we thought it would be and the couple feels it is best to get divorced. For situations like this, we have the requestDivorce() function. As with the marriage proposal, both spouses have to agree on this in order for the divorce to be performed. Once both parties call this function, the contract will be destroyed and they will be free to marry someone else. (Or to stay single šŸŽŠ)

Where to go fromĀ here?

First of all, if you used these contracts to get married, congratulations!Ā Good luck getting some days off at work with the certificate this registry issues, though. šŸ˜ž

When you are back from your honeymoon šŸ–, we can discuss a few improvements that could be made to these contracts, for example:

  • Even though I mentioned the possibility of extending the Marriage Registry and creating other registries with different sets of rules, thereā€™s a problem with this approach. If there are several registries, thereā€™s currently no central registry that keeps track of marriages across these registries. So, if I got married in registry A, registry B would not know about it and I could also get married in registry B if I wanted so. One solution could be to have a central registryā€Šā€”ā€Ša registry of registriesā€Šā€”ā€Šthat keeps track of all registries provides a way for registries to ask each other for information.
  • The current implementation accepts divorces so, if both spouses agree, they get immediately divorced by eliminating the Marriage contract (calling self-destruct) and an event is fired in the MarriageRegistry to log the divorce. For the divorce to happen both parties have to agree, which not always happens. Right now we are not considering the case where one of the parties requests the divorce, but the other refuses to sign. What should be done in these cases?Additionally, I am not contemplating, for example, the death of one of the spouses. If one of them were to pass away, or be incapacitated, thereā€™s no way for a divorce to happen since it requires the agreement of both parties.

  • Anyone can query the registry to get the marital status of any given person (as long as they know their address or the marriage contractā€™s address), this is great as long as this information is used with good intentions, but it also opens the possibility of someone using this information to damage one or both of the spouses. We should probably restrict access to this information and only make it available if one of the spouses authorizes so.
  • You can get married to a smart car, a token crowdsale, a multisig wallet or whatever, sort of.The contract doesnā€™t perform any checks to make sure either spouse is an Externally Owned Account. So, another contract could be provided as parameter and if that contract implements the necessary functions to accept the proposal, then thereā€™s a marriage.Ā As a matter of fact, a married couple could marry another married couple, if they wanted so (and built such a contract). šŸ‘« šŸ‘« https://www.youtube.com/watch?v=t_jHrUE5IOk


Published by HackerNoon on 2017/11/07