UBS creates Smart Bonds on Ethereum. Is this possible?

In november 2015, Stephan Karpischek, and Ian Cusden from UBS presented a prototype for an Ethereum smart contract that represented a bond issuance.

I’m interested in Bond issuances on the blockchain, as I think it could bring many interesting use cases for small and medium companies to raise money.

However I don’t understand one thing: How can the smart contract guarantee payment of coupons, or principal at maturity? one way would be for the smart contract to block enough cryptocurrency to pay back all the coupons and the principal at the end, but this would render the bond useless. The only possible alternative is that the smart bond¬†can fail to pay back either coupons or principal at maturity. This must be the case, and it changes a big preconception I had about smart contracts, that they guaranteed payment and that this would avoid litigation.

Smart contracts don’t guarantee payment. Now that I think about it, smart contracts don’t even guarantee that they’ll have enough gas to keep running until the maturity of the bond. Smart contracts just automate execution and settlement, which is already pretty cool. ūüôā

Advertisements

Understanding Blockchain: What is a Hash?

A hash is a one way function that transforms a string of data of arbitrary size to a bit string of a fixed size. This function has the following properties:

  1. It is quick
  2. It is impossible to figure out the original string of data from the hash. (except by brute force, trying all possible input strings until we obtain the same hash)
  3. Two different inputs will always produce different outputs
  4. A small change to the input string changes the output radically
  5. Same input always produces same output.

Hash is useful for example when you want to make sure that a file that you have downloaded is the file that the owner of the file intended for you to download and it has not been modified in transit.

For example, you want to download notepad++ so you go to the website and click on the link to download the Notepad++ Installer. A file downloads, but, how do you know the file hasn’t been corrupted or somehow modified while downloading?

notepadplusplus

You can check if the hash of the file you downloaded is the same hash that the owner of the website indicates. If you click on the link called “Sha-1 digests for binary packages”

notepadplusplus2

You can see the SHA-1 hash (there are many hash functions, SHA-1, MD5, SHA-256…) of the file should be¬†6a54e0e8c8dbfca68abe3cbe66d99c66ced59cea

notepadplusplus3

You can now use any SHA-1 hash calculator to chech that the file you have downloaded matches the hash that should be. This would indicate that the bits of this file are exactly the same bits as of the file that the website owner put on the website for download. If we change even 1 bit, the hash would be completely different.

If you have a linux computer you can use command sha1sum and you can see that the resulting hash is exactly the same one. You don’t need to go character by character checking, since if the file had been altered, the result would be wildly different.

notepadplusplus4

If you don’t have a linux command line you can use an online sha1 calculator¬†to see that with the same input, the SHA-1 function will return the same hash, no matter in which platform or computer you execute the function.

notepadplusplus5

Hash functions are used everywhere when we need to check that a file or string of bits matches what we expect. For example VLC player uses hash to look for subtitles to the movie you are playing. Linux uses hash to check that the password you have entered matches the password hash that is stored in the hard drive. This ensures that if someone hacks into the computer, and obtains the passwords file, there is no function that can obtain the original password from the hash, since hash is only one way, but at the same time it’s trivial for the operating system to verify if the password you have entered is correct (since it will produce the same hash as the one stored in the hard drive).

Hash is a key piece of the blockchain algorithm. Since I intend to disect the blockchain algorithm to explain it piece by piece, it’s important that the basic pieces are well understood.

 

What is Fintech?

Fintech is short for “Financial Technology” and covers¬†all technologies applied to finance. It is used mainly to refer to disruptive innovations in the Financial industry which is a topic that’s getting a lot of traction, specially since in 2008 Satoshi Nakamoto published his 9 page paper on bitcoin. However, many of these fintech disruptions don’t necessarily come from new technologies, just new ways of using existing technology.

One way fintech disruption can be classified is

  1. Infrastructure: Technical Innovations to infrastructure are necessary to solve business problems and enable disruption.
    1. Identity: One of the big concerns of regulators is KYC (Know your customer). In an online world, what can be done to ensure that a person is who he claims to be? With the concept of wallets which are anonymous, what can be done to ensure money movements can be associated with their owners? This is important to avoid money laundering, financing of terrorism, tax evasion…
    2. Privacy: On the other end of the spectrum of KYC, privacy is also important for end users. MIT are working on Enigma¬†which is a blockchain based, distributed computer similar to Ethereum but with a focus on solving the millionaire’s problem¬†(two millionaires want to know who of them is richer without disclosing their¬†wealth) and allow calculations to be performed by the nodes without disclosing the data (but only pieces of the data which do not give a vision regarding the whole)
    3. Security: If all my bitcoins are sitting in my bitcoin wallet, which is a file in my computer and I lose my file, or forget my password, all my bitcoins are gone forever. If a hacker was able to copy my wallet, which is just a normal file, and was able to find out my password (for example hacking my keepass by compromising my computer) he could transfer all my bitcoins to his wallet and I would have lost them forever.
  2. Money and Payments: Mankind has come a long way from the cash only world where currency was backed by precious metals. Plastic credit and debit cards are the current norm. Paypal, near touch payments with mobile devices are trying to become mainstream, but a big disrupting technology has emerged in 2008: The Blockchain. The Blockchain enables:
    1. peer to peer payments:
      1. Until now when Alice wanted to send¬†Bob money remotely, the only way to do this was to go through a trusted intermediary (a bank, a remittance company, paypal…). With blockchains like the one used by Bitcoin or Ethereum Alice can pay Bob directly, with no intermediary, and more importantly almost no fees. This will radically improve the lives of people who try to send money back to their families in developed countries, for which they need to pay exorbitant fees, wait in line and hope that the money is not lost, while at the other end of the transaction, the recipient has to go through a similarly daunting process.
      2. The peers in a transaction don’t neccesarily need to be human. M2M (Machine to machine) payments is something that can be feasible. For example slock.it¬†is building locks that will open if a smart contract tells them to open.
    2. Cryptographically guarantee that a record can not be modified
      1. Entries in the blockchain cannot be modified. The older an entry is the more time it would take an attacker to be able to forge an alternative chain. Thanks to proof of work, we can rest assured that an attack is not possible. I’ll go deeper into these fun techie ideas in future posts.
    3. smart contracts
      1. Smart contracts enable programs to be run on the blockchain allowing these programs to send payments automatically if certain conditions are met (for example Alice could bet with Bob on the outcome of a match. The smart contract could check for the result of the match and transfer the money from Alice to Bob automatically once the result is known)
    4. immediate settlement
      1. Currently in capital markets, settlement is done two or three days after the trade is done due to the complex legacy infrastructure that it must go through. With blockchain, the transaction could be settled in minutes instead of days.
    5. No settlement risk
      1. Since transactions are atomic, the transaction either gets done or it does not. Hence there would be no settlement risk. However there are some views that claim that a blockchain can never really finalise a transaction as it is theoretically possible that due to the way the consensus algorithm works, the latest blocks may be rolled back. Vitalik Buterin, founder of the Ethereum foundation argues that by that same logic, the current system can also never really finalise a settlement, since the registry could be burnt down or defaced by a malicious user.
  3. Capital Markets:
    1. In the capital markets space, disruptive technologies are emerging in the form of:
      1. Robo-Advisors: Artificial Intelligence is enabling automated investment advice. For example Betterment.com,  Robinhood.com or Wealthfront.com offer this service
      2. Equity crowdfunding: A trend towards equity crowdfunding is emerging where shares in the company would be acquired by the crowdfunders, an example of this is Fundersclub.com or equitynet.com
      3. Blockchain driven markets: Digital Asset Holdings is a very strong startup, aiming at creating a market which is settled over a blockchain. Many strong incumbents are backing this initiative which looks very promising. This platform would deliver on the promise of instant settlement. Ethereum and Digital Asset Holdings are the two fintech disruptors which interest me the most.
  4. Marketplaces:
    1. SME lending companies such as Bond Street, On Deck, or Funding Circle are enabling investors to fund SMEs without SMEs needing to ask a bank
    2. Banking the unbanked: Mpesa is a vodafone initiative which allows people in developing countries to send and receive money from their cellphones via PIN protected SMS. Users can recharge their accounts through airtime resellers and retail outlets playing the role of banking agents.
    3. Credit ratings for the unbanked: companies like First Access are allowing individuals and SME in developing countries to obtain a credit rating when applying for a loan at a bank. First Access gain permission from the client to acquire his cellphone payment history from his cellphone provider, with this history of payments they can give the bank a credit rating for a direct loan.

Figuring out how to mine ETH

It turns out to be very easy to set up a miner node. There are a few ways to do this:

  1. From the javascript console:
    1. Start the javascript console
      1. geth –verbosity 5 console 2>> /tmp/eth.log
        1. This starts the console with a new geth process
      2. geth attach
        1. This attaches the console to an existing geth process
    2. run the following commands in the javascript console
      1. miner.start(4)
        1. opens 4 threads for mining
      2. miner.stop()
        1. stops mining
  2. From the linux shell
    1. geth –etherbase ‘0xD5c55DF2Ed5320553855aB4D9C9B20448870Fbf2’ –mine 2>>geth.log
      1. The etherbase does not need to be local! It can be any wallet’s hash (the reward from mining will go to this wallet)

In order to mine, your computer’s clock needs to be synchronized to the ntp (Network Time Protocol)

If everything has gone right, in your geth logs you should see “Starting mining operation”

ethermining

 

 

 

My first ETH transaction!

I’ve done my first transaction, from my kraken.com account to my wallet! ūüėÄ This is pretty cool stuff.. from my kraken account I only needed to insert the hash of my wallet and thanks to the magic of the blockchain, the transaction was added to the next block and arrived at my wallet¬†0xD5c55DF2Ed5320553855aB4D9C9B20448870Fbf2

If I go to Etherscan.io and enter my wallet’s hash I can see the transaction details.

etherscanio

txHash: This is the hash identifying uniquely this p2p transaction in the blockchain

Timestamp: The blockchain keeps a timestamped record of this transaction which will be impossible to modify by anyone in the future. This transaction’s record is now permanent history! ūüėÄ

From: The hash of the kraken site. It’s interesting that Etherscan knows that this hash belongs to kraken. How is this possible? This could resolve many regulatory problems linked to “Know your customer” (KYC) or “Anti Money Laundering” (AML) regulations.. One of the problems today is that it’s difficult to link a wallet’s hash to a peson who owns this wallet.

To: My wallet’s hash! ūüėÄ

Value: The amount of ether transferred. I wanted to transfer 5 ETH, but I only got 4.995 ETH. Some of this missing ETH has gone to the miners who mined my block in the form of gas (see below) and the major part of this cut I believe has been kept by kraken.com to fund their business model.

Gas: 150000 this represents the amount of work that went into the operation (transfer of ETH)

Gas Price: 0.00000002 ETH This represents the price that I was willing to pay for the operation to be done per unit of gas. If you offer a price which is too low, no one will process your transaction. Gas price is measured in szabo (10^-6 ETH)

Gas Used by transaction: 21000 I think this is the actual gas that was consumed. (as opposed to Gas which was the gas estimated) TODO: investigate and update this

Actual Tx Cost/Fee: 0.00042 Ether

Cumulative Gas Used 341714

Nonce: 43556

Input Data: 0x This means that I did not add any additional data to the transaction. TODO: Investigate what data attached to a transaction can do. Is this some executable code?

 

Ethereum

I’m doing this MIT training about the future of fintech, and through it I am discovering the amazing potential of Ethereum as a source of fun. I think it could be cool to log here my ramblings with it. Maybe it can help others in their path.

Yesterday, I was able to set up an Ethereum wallet in my AWS virtual machine, and I managed to buy 3.000‚ā¨ worth of ETH (205) and¬†XBT (1,7), my bet is that in one years time these 3.000‚ā¨ will have transformed into 30.000‚ā¨. But my goal is not to make money through speculation. My goal is to learn about Ethereum and be able to program smart contracts that automate payments.

My milestones are:

  1. Open an account at kraken.com and buy some ETH and XBT [ Done ]
  2. Install an ethereum wallet in my windows computer [ Done ]
  3. Install an ethereum wallet in my Amazon Web Services VM [ Done ]
  4. Figure out how to mine ETH [ Pending ]
  5. Figure out how to develop smart contracts [ Pending ]

ethereum