Hex’s Design & Early History: A Developer’s Perspective

By Kyle Bahr
Transcribed By Crypto Vince

Hi, my name is Kyle and I have been a community member of the Hex community since early 2019. I’m a software engineer by trade, formerly of Netflix and currently with another large tech company.

I wanted to talk today a little bit about my involvement in the Hex project and a couple of its features in some depth, in the hopes that people not only understand it but also feel like they can totally trust how the system works, and feel confident in telling their friends about it.

My role in the project grew over time. I started as just an active community member. I made a point to learn the ins-and-outs of the system and how all of the marketing points were fulfilled by the contract. I wrote a lot of the documentation that you’ll find linked either through the Telegram channels or through the website.

I ultimately helped design and validate some of the underlying systems that power the Hex contract. I also helped the auditing teams understand the contract, the properties that we wanted them to certify, some of the verbiage of the contract, the business rules that weren’t super clear to them, and what the point was.

It was a great process. I was very happy to have been able to work with Richard Heart and some other very sharp people in coming up with these things. I didn’t know Richard from videos or even as a persona in the crypto space before this. He’s really been the genuine article. He’s exactly in private with me as he has been in public with others; really a delight to work with.

I want to talk about a couple of the guiding principles of the Hex project:

  1. A couple of the details of the marketing points and how they are fulfilled by the contract

My hope is that you’ll come away from this with a deeper understanding and appreciation for the effort that went into crafting the system, and full trust that the code can live on the blockchain indefinitely and will always perform as intended. That way you’ll feel empowered and totally confident in pitching it to friends, family, confidants, and anybody you meet.

Hex has a core principle: that more people should want to buy it than want to sell it at any given time, and that this should create an upwards price pressure, thus increasing the value of all the Hex in existence, making it a good store-of-value product.

You put value in, more people come after you who want to buy it then want to sell it, the price goes up and your value is protected. If you participate in the restriction of supply (meaning you promise not to sell your coins) then you should be rewarded with more coins.

That function within the Hex contract is called staking. You stake, or commit your coins for a period of time which is the blockchain equivalent of promising not to sell them in a way that is trustless — meaning it’s data that’s written to the blockchain — and nobody has to take your word for it.

You pick a period of time and are rewarded a share of the inflation during that window of time for your commitment. The fewer people that make those commitments, the fewer ways that inflation is split, and therefore your effective interest rate is higher. As more people commit, the effective interest rate is lower.

Specifically what I want to talk about is the promise that in the original marketing material:

Longer commitments should always earn more Hex through the contract than shorter commitments.

This was summed up as “LongerPaysBetter”. Richard put some numbers on it, even from the very beginning, that from one day to ten years you should earn more and more interest, up to a maximum of three times whatever the instantaneous interest rate is for a one day person.

And oh boy, did that get complicated. For folks that didn’t get this far in arithmetic and mathematics there is an effect called compounding interest. This should be fairly common nomenclature, but a lot of people don’t really understand what it means. Compounding interest is earning interest on your interest. If the effect is applied in all sorts of contexts, viral spread is one of the things that this models.

What this means is: whatever your growth rate is, say 5%, it’s applied to all the previous 5%’s that you’ve already accumulated. If you accumulate 5% every year, then at the end of the first year you’ll have 105%. At the end of the second year you’ll have 111% because you’re earning 5% on the 105%, not 5% on the 100%. Simple interest is on the 5% on the 100%, so you don’t earn interest on interest.

The way that this was applied in Hex:

This was discovered before my time in the community, but it was around my time that we actually convinced the developers that this was a problem. The original way that Hex issued your share of inflation for the period you were committed, is that it just converted your committed coins to shares, which was just an internal accounting label. They weren’t coins; you couldn’t trade shares. They were just bound to your stake, or to your “commitment”, so If I commit 1000 coins, I get 1000 shares, and if you commit 1000 coins on the same day and two other people do the same, then I have one quarter of all the shares and therefore I get one quarter of all the inflation. (¼ + ¼ + ¼ + ¼)

If your friend commits for 10 years and gets triple the shares: He has 3000, I have 1000, you have 1000, and the other friend has 1000, then I get 1/6th of the interest and the 10-year friend gets half because he has 3000 out of 6000, and the rest of us have 1000 out of 6000. (3/6 + ⅙ + ⅙ + ⅙)

The compounding problem that was discovered is that if I then pull my coins back out after one day (and say my share was nearly 1 coin and now I have 1001 coins), I can recommit them and get 1001 shares. Then I get them back out and only get 1 more coin and have 1002 coins. Then I recommit 1002. It doesn’t sound like much, but because of the nature of compounding, accumulating these little share advantages very quickly ramps up to where I’m getting way more for my series of short commitments than even the 10-year person is getting for their very long commitment.

Frankly, this just breaks the pitch: The pitch is: you commit for a long time, you’ve taken your coins off the market, you’ve made a commitment that is written to the blockchain, and so you should be able to forget about this, go live your life and then come back in 10 years and collect an enormous pile of coins and you should have confidence that your commitment really meant something.

If you do that and then five days later somebody discovers this compounding trick and then you find out that they blow away your earnings, it completely undermines faith in the project.

This was a complete show-stopper once it was discovered and believed to be a problem because it literally makes the coin no better than any of the ICO pitches that say “Yeah, just give us your money and forget about it”, and then somebody comes along and essentially hacks the system just by exploiting this behavior.

A huge amount of effort went into figuring out how to overcome this problem. We came up with a pricing system, such that instead of exchanging coins to shares 1-to-1, there was a price put on the shares and the price moves in this compounding way discussed earlier. You compound price rather than compound coins, you can get the same effect as compounding coins for the person who has committed earliest.

It’s kind of complicated, but the visualization that you can probably use is that if I have 1000 shares for a 1000 coins and then in a year, some new person comes in with their thousand coins and they only get 500 shares they’re earning half the interest that I am, and we have the same number of coins as input. So if they’re earning half the inflation that I am, for half the share of inflation that I am, it’s the same as if my coins had compounded and doubled, as if I had 2000 shares to their 1000 shares. As long as that ratio is maintained, then it’s the equivalent and it’s very low-touch: I don’t have to think about it because the system automatically compounds the price on future people so that I’m earning as if I’m compounding my interest.

The question came up in late 2020, whether Hex is a simple interest system or a compounding interest system because this mechanism of compounding is somewhat hidden, and actually the answer is that it’s sort of both. I think this is among the many amazing properties and discoveries of Hex and goes to one of the other core principles of the project which is: Nobody should feel like they missed the boat. There should always be — as Richard liked to say often during the design phase — meat on the bone for the next guy who comes along.

The behavior that we were worried about was that somebody would pull their coins out and put them back in continuously, so the price compounding actually only has to happen when coins come out, because that’s the behavior that you want to curtail. You want people to know that pulling their coins out ratchets the price for them, and everyone else, but especially for them because people can have multiple addresses.

It has to be a global price for a lot of reasons, but specifically if you think of people who are trying to do this: cycle their their Hex through very short stakes even across a whole array of addresses; as long as the price keeps moving up to match, they can never gain ground on longer commitments. By doing it on-demand and the fact that everyone ought to know that it’s on-demand removes the pressure to try and do that. There’s nothing to be gained by doing that, and you can truly believe that the system will always compensate to make sure that your longer commitment out-earns a shorter commitment.

Regarding the auditors that were tapped to do this: one of the things that won them the contract is that they had someone with a math Ph. D who agreed to analyze the business rules and write this up as a formal math proof; that no two sequential stakes could out-earn a single stake of the same combined length. That’s the core principle or property that we needed the system to have to guarantee that the marketing point that longer always pays better is true. Longer always pays better.

We had to explain this to him over a lot of conversations, because it is fairly complex. The system is so complex that it’s hard to tease out this single property as being one of the critical things to verify, but we did get there and it is in the Economics Audit. We proved it to ourselves long before we ever presented it to them, but it is formally documented that in fact longer stakes will always out earn any sequence of shorter stakes so you can feel secure in that.

Jumping back, there was this idea of compounding the price. You only compound on demand so that there’s always meat on the bone, and so all pressure should be removed. People know that the contract will always pay longer stakes a larger share of inflation than shorter stakes. Ladders or staggering your stakes, or having a mix of lengths is entirely an individual decision.

It’s actually quite liberating to know that the contract only increases the price on newcomers as required, so if everybody agreed to do long stakes, newcomers could get in every day at the same price that was today’s price. It gives a true smooth on-ramp so as adoption ramps up, and as people come to understand the system better, we’ll hit this nice equilibrium where everyone is making longish or longer time horizon decisions, because there’s no incentive to go shorter.

An exception may be degenerate gamblers or traders who want to be earning a little micro-interest here and there and then be playing the trading game. There’s very little use case in Hex for that; there’s very little to be gained unless you think you’re really good at market-timing, in part because the contract guarantees that that’s not a winning strategy and in part because so many other people have committed for the long haul that you’ve diluted the earnings of short stakers.

We ended up kind of accidentally achieving a few goals with one very elegant solution for pricing everybody can can interact with the contract with full faith that it will pay proportional to the length of your commitment, so you are free to make long commitments with no concern that you’re going to get outplayed or out-competed by people doing sequences of short stakes.

You are free to interact with the contract now-and-forever because it’s:

  • Trustless

This last one was actually a bit of a sticking-point with the auditors, but oh well. We issued some standard techniques and libraries just to have no dependencies on external systems. It will always work and no one can change it. It’s on the blockchain eternally, the state can all be read, lifted, air-dropped, put on its own chain, or whatever it needs to do. It’s fully encapsulated and self-sufficient. Because of this, people are free to use this as a nest egg or as a long-term income strategy. You also end up washing out the day-trader types or the short-commitment people, which is fine. If they have reasons to want to do that, they are also free to do that, but the system we designed doesn’t encourage it.

With the incentives aligned, the system only ratchets the price when it needs to, so that new people can always get in at the best price. Yet once they do, and they tell their friends, their friends are bitter already because the best price they’re going to get is always today’s price and you don’t know how long that’s going to last.

Getting to the rest of the audit process: there was this math part that was very important. There was quite a bit that went into security analysis and to make sure some of the other properties held, but ultimately the thing that I was most proud of was the math part. The fact that we came up with a system that elegantly solved the compounding problem (where one could not gain advantage by compounding and that by doing that you remove the pressure to even try) was really a eureka moment for me.

Over this last year I’ve noticed other people have that “aha!”-moment, that it’s always going to work — that it serves these dual purposes of freeing you to think longer-term and preserving the meat-on-the-bone for the next person — because by not turning over commitments regularly you’re not moving the price very much day-to-day.

You’re still earning quite a bit of interest for your enhanced shares versus new people that come in, both because they pay more for the coins and also because you’ve earned interest from the inflation that they weren’t present for. They still get a good price and can still tell their friends and their friends can still get in at a good price.

Let all of that sink in. The system that we put out there is really a thing of beauty and it solves a few problems in incredibly novel ways such that I don’t know why they don’t exist elsewhere. Sometimes it’s good to be first. It’s a little scary because it’s untested ground, but I think we’ve proven to ourselves and we’ve gotten some outside parties to prove that what we’ve done is really something special.

For some closing thoughts, recently there’s been a little bit more attention something called the Marshmallow Experiment. This was an experiment done by some psychologists at Stanford back in the early 1970s, in which they present kids with a candy or marshmallow, and say, “You can eat this marshmallow now, or you can wait 15 minutes and when I’ll come back I’ll give you two marshmallows”.

It was supposed to be a test of willpower and ability to delay gratification for a better reward. They did the experiment, then they followed these kids through their high school years and found that the ones best able to delay gratification had the best outcomes, and there was this celebration of “Oh look, there’s this great quality that even four-year-old kids can have of delaying gratification”, and as the saying goes, “good things come to those who wait”.

There was some doubt about the genuineness of those results, and so the experiment was repeated a couple more times. One of the criticisms was the economic background of these kids. If you can imagine being very poor and not having a lot of food security, a marshmallow now is better than maybe two later. This can raise some concerns: Do you really believe that you’re going to get two later, or do you just need the calories now (and you’re so habituated to taking food when it’s available that you just take it now)? Do you just not trust future rewards because things haven’t worked out for your family?

The other aspect, which even the original experimenters knew was: how much do the kids trust the adults? Do they believe that the adult will give them two? If they don’t believe the adult will give them two, why wait? Just have one.

The follow-up experiments also followed these kids, and when they controlled for the economic background of their families, they found about half the effect of the delayed-gratification ability could be chalked up just to their economic situation.

So maybe it’s not a totally intrinsic trait; maybe it does have something to do with life experience. Then the third experiment happened, where they tested for trustworthiness of adults.

What they found was: if the experimenter lies to the kids right before giving them the test or the experimenter makes a promise and fulfills it right before giving them the test — unrelated to the marshmallow part — just to establish a single event where you can say this person is not trustworthy, or this person is at least a little bit trustworthy, rather than half the effect, they found that the kids who got the trustworthy experimenter were able to wait four times longer than the control group of kids who weren’t given an experimenter.

The kids with the untrustworthy adults basically all just ate the marshmallow right away.

What does this tell you?

It tells you that sure, both inherent traits of the kids and economic background matter a little bit, but the ability to trust that future reward is vastly superior to anything else. If you have a reason to believe that the reward that’s coming in the future will really come, anybody can go to much greater lengths to delay gratification.

That has really played out in the stories that people have shared about how Hex has changed their lives in big, impactful ways: pay off debts, buy houses for their folks, pay off cars, free themselves, and plan for the future. It’s because they believe those future rewards are coming, and I get a little misty when thinking about it, because this is a beautiful thing.

The one thing that we can provide other people is the ability to trust us and for any other points aside about this idea of delayed gratification: if you can give the world or give other people anything you can give them the ability to trust you. Show them that you’re trustworthy, then they’re empowered to rely on you, delay their gratification, and not demand things now, but be able to wait until later because they know that you’re going to deliver.

What we came up with in the Hex contract that we proved to ourselves — and we got an external party to also prove — is that the contract in the system can absolutely be trusted to do what it says it will do. It removes the need to trust because you don’t have to trust it.

It’s proven.

We proved it will do that, and we’re seeing that bear out in how the community shares its stories about what they’ve done with this project, and with their lives as a result of it.

To the Hex community:

Keep sharing stories, and broadcast them as widely as you can. I know that we have some really touching ones, and we have some people who’ve been empowered in a way that they maybe never have been before in their life.

It’s been a real pleasure and honor to be part of the community, and to be trusted with such a significant part of the design. I love continuing to engage with folks as I’ve been able to. Hit me up with anything you need. I’m on Telegram pretty much all the time, though I am quite busy and I might not get back to you immediately. Just ask around for Kyle or hit me up at @RapidProtoTripe and hopefully, see you on the other side.

Original YouTube Video:


Crypto lover, headphone audiophile, freelance musician.