Blockchain takes over — from the programmer’s perspective in 6 lines of code

Let me say that I believe that blockchain will take over the financial sector as the underlying technology in time. It will take some time, but it will happen.

It won’t eliminate python/java/c#/etc. apps that are UIs or bots doing xyz tasks, those are easy to write and flexible. But they will be using blockchain as their underlying technology, requesting commands on the blockchain level.

Why is that?

You want to transfer $100 between two banks.

When a bank transfer happens, these are the parties that are involved (sometimes more).

Bank1 -> CE* -> Bank2

*CE — some centralized entity, such as SWIFT, that banks use to communicate

These parties will need something like this at their infrastructure level (and this is not all)

  • Webservers for user interface (web/app/api)
  • Database — user & account information
  • Message queue
  • Caching servers
  • Authentication & authorization
  • Backup
  • System administrators

The user wants to transfer $100 from his account to another account. These would be the steps.

  • The user submits the request to Bank1
  • Bank1 receives the request and writes to db
    If db write fails, we can notify the user. Good result!
  • Bank1 creates transfer request in a queue
    What happens if it fails to create a queue?
  • The queue is processed, sending a message to CE
    If message sending fails, write logic to retry
    What happens if the message always fails?
  • CE receives the request and writes to db
    What happens if it fails, can it give an error to Bank1?
  • CE creates a queue to process payment
    What happens if creating a queue gives an error, how to handle it?
  • CE processes queue
    What happens if processing fails and can never be processed?
    Do we need a person to manually do something?
  • Bank2 receives request & writes request to db
    What happens if it fails, can it give an error to Bank1?
  • Bank2 creates a queue to process payment
    What happens if creating a queue happens, how to handle it?
  • Bank2 processes queue
    What happens if processing fails and can never be processed?
    Do we need a person to manually do something?

This is an estimated path of how payments work in the banking system. There are other contractual issues that also need to be 100% (insurance, lawyers, contracts, etc), but that has nothing to do with programming.

In almost all cases this pipeline works, in those cases where they fail, a person needs to go and do something. But look at all those italic lines. Those questions (and there are many more when going into the details) will cause programmers issues.

I put up 11 questions. For each of these questions you need to decide what needs to happen, this means meeting with those people and creating some process. This then needs to be programmed and managed. As I said, those are not all the questions, it takes years to find them all, and most of the time, only after an issue has happened do you see the question.

Developers will need to write logic to handle all those cases, they need to notify systems if something goes wrong

System administrators need to monitor servers that run the database, message queue, and caching, make sure the operating systems are up to date, if there are any security flaws on my dozens of servers, and that there is space on hard drives(this actually happen unnecessarily often), handles firewall to protect all that data, makes sure only right people have the right access to those machines.

This ends in hundreds of thousands of lines of code and huge system administration

What blockchain gives you and why it’s simpler

  • User interface —web/app/desktop
  • Deploy contract on blockchain

That is it. The best part is, logic is all on the user device, it’s just javascript in a html page, so you don’t need any server-side processing.

There is…

  • No web server (deploy on Cloudflare pages or IPFS)
  • No authentication or authorization (wallet does that)
  • No database (because blockchain is our database)
  • No need for caching or a message queue (complexity created this).
  • No backups are needed (blockchain is always backed up)
  • No system administration (well probably need some)

And we go from hundreds of thousands of lines of code to 6 lines.

Yes, 6 lines of code!

You can see it here for USDC https://polygonscan.com/address/0xdd9185db084f5c4fff3b4f70e7ba62123b812226#code

See line 800 for the _transfer function

function _transfer(address sender, address recipient, uint256 amount) internal virtual override {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}

The developer can really just think about the logic and not about scaling and error handling because of failed execution on some unrelated service, or any other million things.

If the transaction fails, everything fails, not just part. This is really good.

In fairness, if the bank is transferring money within itself, it would be something similar. Minus from one account, plus on another account. And there is other logic to handle, that is why the USDC contract is not 6 lines, but we have eliminated 95%+ of the code and the whole operation(db, backup, etc) is gone.

What happens when you eliminate 95%+ of the code, from my experience

  • Securer platform
  • Fewer errors
  • Less cost
  • Less time spent in debugging failed process
  • Easier maintenance
  • Easier to add features
  • Easier to understand code

Free benefits

  • Fraction of the system administration
  • You have more time to secure things
  • The attack surface has been lowered to a fraction
  • With more time and less attack surface, safety wins
  • Better uptime than the largest companies with unlimited money can do

So as a manager, being a technical manager, this is obvious. It’s just a question of time.

Let’s take a bank loan

What happens behind the scenes is the process of multiple parties being involved. Your bank actually issues bonds on the market (grouping multiple loans into one bond). This has multiple people involved and far from automatic. It also connects multiple computer systems and some are manual. The overhead is huge. The code line count is in thousands. Man hours in decades. Let’s not forget, it can take days to get the loan.

Let’s take a loan - in 3 lines of code

https://docs.aave.com/developers/v/1.0/developing-on-aave/the-protocol/lendingpool#borrow

LendingPoolAddressesProvider provider = LendingPoolAddressesProvider(address(0x24a42fD28C976A61Df5D00D0599C34c4f90748c8));
LendingPool lendingPool = LendingPool(provider.getLendingPool());
lendingPool.borrow(address(0x6B175474E89094C44Da98b954EedeAC495271d0F), 1000 * 1e18, 2, 0);

That was easy, I just took out a $1,000 loan.

Works as one computer and one transaction

For those who need it, a contract is like an app. Each app has some capability and you can use it in your app.

And since this is always transactional, it either works or it doesn’t work. Nothing breaks in the middle.

I cannot tell you how often I have spent hours digging through code to find where it broke because some processes ran just half of the way.

This is why I believe blockchain will take over as the underlying technology, and that is why I’m building Liminal.market, just instead of transfers and loans, I’m doing stocks.

Stocks on chain or tokenized securities

Now that you have seen how simple transfer works, you can imagine how it works with liminal.market. In the same way, using even the same interface as USDC (this is called ERC20 standard), you can simply call the transfer function.

Now imagine creating a product that is using the aUSD contract (this is your dollar amount at the broker), it takes 3 lines to execute a trade order.

What this code does in essence is, transfer dollars to a stock symbol, telling the system you want to sell your dollar for a stock symbol.

Note: This is how you use the transfer function, the code before was how the transfer function was coded in the USDC contract. Here is aUSD transfer function

address symbolAddress = 0x9BEFB4F05c75664485A2d56130DaEBBb6631f29a //GOOGL
aUSD ausd = aUSD(aUSDAddress);
ausd.transfer(symbolAddress, 1000 * 1e18)

To give your customers access to the stock market in whatever form it will be in, will it be a bot, website, wallet, app, or ruled-based trading dictated by a public smart contract or index fund, implementing the service is easy.

That is it! Well and then you need to build a product and brand, get customers, and all the other things.

Conclusion

But what is not debatable, any 15-year-old kid in his bedroom can create magic at no cost except his time.

What can happen when smart educated people with experience come together?

Please check out our documentation and our Discord server if you find this interesting.

Our Twitter is @liminal_market

--

--

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