Project Brief: Susu – Building a Basic Lending Smart Contract

Team

Background: Introduction to Susu

For our first blockchain project we wanted something that would be rather simple in terms of programming logic so the learning and challenges would all come from the blockchain-specific part of development. I proposed working on a blockchain-based Susu. A “Susu” is a West African and Caribbean saving tradition where a group of people come together to form a saving group (the Susu). If the Susu has 5 members, for example, then the group will meet 5 times. Each meeting, each member will contribute an equal amount to the Susu (say $100) and one member will take the entire pot ($500). At the next meeting a different member will take the total pot and the rotation continues until each member has had a chance to receive the money. Once a rotation is complete, the Susu could disband or continue for another rotation.

In the offline world, one challenge of executing a Susu is that someone has to be trusted to collect the money from each person and hold that pot of money until it could be paid out. There really is no way around this whether the entity holding the money is one of the friends, a bank, or some lawyer, some entity has to be trusted.

Blockchain tech allows for a small computer program to be written to that executes the logic of how funds should be collected and dispersed (the “Smart Contract”). Of course, this isn’t new. We’ve been using computer programs for years and creating a computer program to execute the Susu doesn’t solve our trust problem because we’d essentially have to trust whoever controls the computer the that controls the money.

However, because Smart Contracts exist on a blockchain, there isn’t just one computer responsible for the code, all nodes on the network validate the proper execution of the code. Execution of the Susu becomes decentralized across the entire network making it extremely difficult for a bad actor to run off with the money.

CryptoSusu Design

From a high-level the requirements for our blockchain version would include:

  • Having the ability to define a Susu group and group members.
  • Members having the ability to contribute money to the Susu smart contract (money-in).
  • The smart contract having the ability to transfer to a member each round (money-out).

You can see our detailed requirements document (CryptoSusu Design Doc).

While the basic Susu would be straight-forward, there are a lot of directions you could go from there. For example, with a little modification, the basic structure could be adapted to function as an insurance system with policyholders contributing regular amounts. The money-out trigger would need to be adjusted from being strictly time-based and sequential to being conditioned on approval of a claim (which may just be a vote of the majority of the members to approve the pay-out).

Development

Development of our crypto-susu took a lot less time than expected. We build the system on the Ethereum blockchain and the main contract “Susu.sol” ended up being a little more than 100 lines long. Shawn did the majority of the development work as he had a little more free time.

What We Learned

So much learning happened in this it would take pages to fill, but there are a couple items that really jump out.

1. Transferring Money is Really Easy

This should be no-brainer for a technology whose core value-proposition is transferring value, but it really jumps out when you’re developing on the platform. In the Susu code we call this method for the payout to a member:

msg.sender.transfer(members.length * contribAmtWei);

Here we calculate the size of the Susu membership (members.length) multiply that the amount each member contributes (as expressed in Wei) and send that to msg.sender (the person invoking the payment function (elsewhere we guarantee that only the correct person can invoke this function). What’s striking is that this method is all that is need to transfer value to any wallet. AND the smart contract itself can be the recipient.

To contrast this with a web or mobile development app where if I want to move money around, I’d have to set up a traditional brick-and-mortar bank account somewhere. Then find an SDK like Stripe to use with my application code to handle communication with that bank account (where the processor would take it’s 3%+ charge). Then work with various authentication and security issues to make the whole thing work. Crypto is a lot more streamlined.

2. Development is Hard

I built my first website in 1995 using something like Microsoft notepad to type HTML into a file, save that file, then open that file in a browser to find out if I had typed anything wrong. There was no development environment, no autocompletion of language keywords, or code-hinting etc. It was a tedious, slow, and frustrating process, because web development hadn’t been commodified yet and not that many people were in the game.

This is where blockchain development is now. For my development I settled on using Atom with the language-ethereum package. Add to that the capabilities of checking your smart contract in Remix and you’ve got the bare necessities of smart contract development, but it’s rough. Be prepared to spend long hours in development and deployment and not having much in terms of reference books, other local devs,  or Stack Overflow answers to help you. I’ve spent the past 7 years in iOS development. When I compare Xcode to my blockchain tools it feels like the difference between using Microsoft Word vs a typewriter.

3. Platform Wars are Real

Finally, there’s the fact that we chose to build on the Ethereum platform. While BitCoin does has some capability to handle distributed apps, Ethereum is really the first platform built with this use in mind. It has good marketshare, but it’s entirely possible that we’ll look back in 5 years and see Ethereum as the Friendster of blockchain platforms. It was one of the first, it got really big, and then got crushed by a much more robust successor. There are a lot of other blockchain systems being built and deployed and no one knows which ones will survive. That makes it hard to pitch a blockchain project using technology that is so new and has no guarantee of existing 2 years from now.

However, Crypto-Susu was just meant to be a learning experience. We learned a lot and the skills from this laid the foundation for our next project: CoffeeCoin.