The blockchain and cryptocurrencies are some of the most disruptive technologies of the decade.
On this episode, you'll meet Stuart Farmer, who is building a suite of developer tools
that speed up the process of creating new and custom blockchains and apps.
This is Talk Python to Me, episode 165, recorded May 15th, 2018.
Welcome to Talk Python to Me, a weekly podcast on Python, the language, the libraries, the ecosystem, and the personalities.
This is your host, Michael Kennedy. Follow me on Twitter, where I'm @mkennedy.
Keep up with the show and listen to past episodes at talkpython.fm,
and follow the show on Twitter via at Talk Python.
This episode is brought to you by Linode and Nerd Lettering.
Check out what they're offering during their segments. It really helps support the show.
Stuart, welcome to Talk Python.
Thanks.
Yeah, it's great to have you here.
I've wanted to do a show on the blockchain for quite a while,
and some folks from your company reached out, and I thought,
maybe this is just the perfect chance to kind of bring Python and cryptocurrencies in the blockchain together.
Yeah, absolutely. I love Python. It's like my main language.
So talk about it. It's good. It's good.
Absolutely. And you guys have some really interesting and surprising things happening.
Like you're not just building with Python, but you're actually going a little farther.
And we're going to talk all about that, but I want to sort of set the stage with some of the background technologies.
But of course, we'll start with your background yourself.
How did you get into programming in Python?
Programming in Python. I guess my programming experience started when I was a kid.
I was lucky enough to go to a school that was experimenting with teaching kids programming through Logo,
which is like Turtle Graphics.
And there's actually a Turtle Graphics module in Python, which is fun.
Yeah, that's pretty awesome.
What computers? Give us a sense of the time frame.
Were these like green monochrome computers or more modern ones?
Some of them were, but we updated. I mean, like this is early 2000s when I was learning this stuff.
So the school definitely had some old monochrome.
They were getting their mileage out of those computers, huh?
Awesome. So you started with those.
I think I remember learning on Apple IIe's with the Turtle thing as well when I was pretty young.
And then moving on to basic, like true basic, basic, you know, 10, do this thing, 20, do that.
Yeah, so where'd you go from there?
I went to basic. I did QBasic.
That was really fun.
And then from there, I was learning more like C++, C# types of stuff.
And that's when I started getting into object-oriented programming and things like that.
And, you know, I dabbled with web, but nothing crazy.
I always liked how like a computer worked.
Like I knew how a computer worked and web just doesn't seem like how a computer works to me.
So it's actually tricky for me to kind of do a lot of front-end web development versus, you know, back-end coding.
Yeah, a lot of programming you can do with one language and one technology.
But when you start writing for the web, you've got like five languages, four technologies, you know, some back-end server thing, CSS, HTML, SQL, or some NoSQL query.
Like it just, you're like, whoa, why do I have to know all this stuff?
Yeah, yeah, yeah, yeah.
And I guess the answer to that is to make everything JavaScript.
That's right.
So it's been the world around JavaScript instead of make JavaScript.
Yeah, exactly. All right.
Yeah, from there, basically, I took a hold off for a while because I was just kind of getting into music and art and things like that, my personal life.
And then I started things back up again in college.
I started doing iOS development because I had some app ideas.
And I've always been super entrepreneurial.
So I basically was poking around with Objective-C and I was like, hey, this is not that hard.
I'm done programming like this before.
And the opportunity was so huge.
I mean, if I'm like inferring from like your high school time, that's like near early, early App Store days, right?
No, actually, it was probably like four years ago I learned iOS programming.
Oh, yeah, okay.
It was mature.
It was matured at that point.
But then, you know, from there, I, you know, I get into things and I really get into them.
So I was really into iOS programming.
I got a job at the university I was working at, at the technology commercialization department.
So I was doing like prototype apps and things like that.
And then I started a software consultancy from there doing apps.
And like I said, I was entrepreneurial.
So it was part of it was consultancy for launching startup companies.
So I worked with like accelerators and things like that to work with their clients to talk about monetization strategies.
And how do you prioritize feature sets to get the maximum ROI?
Because a lot of these early stage startups don't have a lot of money to burn.
Yeah, they got to test it pretty quick, right?
That must have been an amazing experience for you to build upon to like see all of these startups try to get going, sort of be behind the scenes and see what worked and what didn't.
Yeah, yeah.
It was really cool.
And a lot of it was trying to, I guess, live vicariously through some of them, you know, like it was for me, the startup process is really cool.
And consultancies are all right, but you're usually developing on someone else's term.
So it's very exciting to work on these things.
But you always do want something more.
And so in my free time, that's when I was learning things like Python.
And the reason why I picked up Python was I was fascinated with machine learning and deep learning and a lot of stuff like just like the neural transfer styles and things like that really caught me.
And I've always really, really liked genetic algorithms.
And so like creating these like life forms and these like life simulations on screen that start to evolve to like a natural, like naturally evolve to something that looks like it emulates some like Petri dish.
Just it's in a digital environment.
Even the behaviors that are exhibited look natural is very, very, very interesting to me.
Yeah, that's super interesting.
If you pair that with machine learning AI, you know, we could get to some really wild places pretty quickly, I suspect.
Yeah.
And that's how I picked it up.
You know, it's pretty straightforward.
I was coming from Objective-C, C++, C#.
I did some Java too.
So it was all strongly typed Objective, or not Objective, object-oriented stuff.
So Python being a little looser in like their typing schemes and things like that and their class structures and being a crossroads between functional and object-oriented was pretty cool.
And I've just used it ever since because it's so versatile.
Like anything that I want to do, I can do it with Python.
At least like my scope.
I was really into like, you know, SciPy, NumPy, Scikit-learn, you know, things like that.
All like the newest, latest stuff was being developed on Python.
And so I was just super attracted to that.
That's awesome.
Yeah, it's the perfect place to be.
And there's lots of new things being built there, but especially in the machine learning space, like a lot of stuff is being built there.
So, you know, you spend your time hanging around startups, and then I think it just starts to rub off.
You're like, these people aren't that special.
I could do what they're doing.
Why don't I have a startup?
So, you know, you kind of find yourself more or less in a place a little bit like that today, huh?
What are you doing now?
Now I started a company that is producing its own blockchain, and our goal is to make the adoption of blockchain very smooth for people who might not otherwise have the same domain knowledge.
So like one of the things that I had to reconcile with a lot of startups was the tech gap between the client and me.
And I felt pretty good at communicating that with people.
As I was picking up other stuff, you start to notice these patterns, right?
How do you communicate to non-technical people?
How do you break something down in that communication process?
Why do some open source libraries strive over others, even if they are comparable or one's better technically than the other?
Like you could look at Keras.
Keras is a perfect example, right?
It's so simple and modular.
There's plenty of other building block type machine learning libraries like Lasagna was one that just never took off.
And it's really about the presentation communication, which is what I studied in college.
It's all about communication and things like that.
And so I realized that there's a problem with blockchain as well.
And just picking up on all of these kind of lessons I've learned over time, I figured, you know, I feel like I could build a toolkit and demonstrate that to people so that when they pick it up from having web development experience or backend experience or whatever, enter this blockchain world, which in a lot of ways is arbitrarily difficult.
And not have a hard time.
So that's what I do now.
We have a team in San Francisco.
We have some other teams abroad helping us with some of the other software in our suite.
Our code base for the main technology, which is the blockchain, is all written in Python.
And we've pretty much advertised heavily on being a Python platform, mainly because it's super popular language behind JavaScript, yet has a lot more compared to JavaScript, a lot more safety and access to lower levels.
Yeah, and often it's used in more sort of formal software space.
And from what I can tell from looking at what you're doing, it's kind of like, let's take this blockchain and make it like enterprise friendly.
And especially if you intersect technology space with enterprise, like JavaScript becomes much less popular than it would be sort of generally taken, right?
Oh, totally.
Yeah.
I mean, JavaScript, that's kind of the whole point behind not using JavaScript.
There's blockchain projects that do use JavaScript, but I conjecture that they're not going to or they're going to have a very hard time.
It's a hobby space.
Yeah.
Right.
Yeah.
I hear you.
So basically, we don't necessarily trust JavaScript code as much as Python code, and I don't think enterprises really do.
The starting point for any software open source project is the hobbyist.
If you can't make it past the people who are actually going to be using this, ultimately, it doesn't matter what the decision maker says.
You're going to have a lot of resentment, and it's just not really going to work.
Like, one of the examples is Scala, and what's kind of ironic is people who program Scala love Scala.
I've heard stories of enterprises developing it all in Scala because it's demonstratively better than just Java, and then having to revert back because they can't find anybody to maintain the code.
Right.
That's a really interesting example, yeah.
Yeah.
You have to take, like, both sides.
So what is the hobbyist going to use and really adopt?
And here's another thing.
Like, you look at the smart contracting languages that are out there.
A lot of them, like, I've seen ones that are based off of Pascal, which is for Cardano is based off of Pascal.
You have this project by these people called Kadena that's based off of Lisp.
You have Ethereum is based off of C++, right?
Which is, like, it's not that hard.
It's hard for someone who doesn't really know anything about it.
And these languages...
Oh, and Tezos has their own called Mickelson, which they say why...
They have a little blurb about their design choices.
And one of, like, the rhetorical questions that they begin a paragraph is, why isn't this as simple as OCaml or Haskell?
And that's like...
Those don't sound like simple things to me, to be honest.
Right.
And they're like, oh, yeah, we did not purposely want to make this easy because the harder it is, the less people who develop it.
It requires a much more technical skill set.
Therefore, it's a security precaution because you know that technical people are going to use this, which I think is ridiculous.
It's like making a car hard to use so that only people who really put a lot of time in there drive it so then there's less crashes.
Yeah, it sounds like a unicycle versus a bicycle.
Right.
Exactly.
So, it's a weird world out there.
And it's a lot of personalities that have a lot of strong opinions about the way that things should be.
But we're just interested in building stuff.
The end goal, what is the end goal?
It's really to make this cool tech available to as many people as possible and to give them a bus toolkit that isn't limiting and at the same time isn't something that's super complicated.
Yeah, I think that's really great.
This portion of Talk Python to me is brought to you by Linode.
Are you looking for bulletproof hosting that's fast, simple, and incredibly affordable?
Look past that bookstore and check out Linode at talkpython.fm/Linode.
That's L-I-N-O-D-E.
Plans start at just $5 a month for a dedicated server with a gig of RAM.
They have 10 data centers across the globe, so no matter where you are, there's a data center near you.
Whether you want to run your Python web app, host a private Git server, or file server, you'll get native SSDs on all the machines,
a newly upgraded 200 gigabit network, 24-7 friendly support, even on holidays, and a seven-day money-back guarantee.
Do you need a little help with your infrastructure?
They even offer professional services to help you get started with architecture, migrations, and more.
Get a dedicated server for free for the next four months.
Just visit talkpython.fm/Linode.
Just to be clear, the company that you started is Lambden, and you guys are doing primarily blockchain, not cryptocurrency.
Is that right?
In a way, we have a main deployment, so we went through a token sale and things like that to be primarily funded,
which is cool because we can develop everything open source and don't have external pressures from VCs that are just looking to increase your valuation over time from explicitly on pay-per-view.
Yeah.
So that's cool.
So some people have a hard time understanding that we are developing a blockchain suite, and out of the box, you get everything that you need to build a blockchain.
However, we also provide a main deployment of our blockchain, which can either serve as a premium example of what to do,
or it has a feature on it that allows you to what's called atomically swap in between cryptocurrencies,
which not any cryptocurrency is really offering to a performance level that we can offer.
So what this atomic swap allows people to do is create their own blockchain using our tools or to use a cryptocurrency that already exists
and be able to exchange them through this.
You can think of it as like a decentralized clearinghouse without trusting an exchange or an intermediary or a third party,
and knowing with complete certainty that that swap is going to either be 100% successful, the funds get remitted to both sides,
or when it fails, neither person has their funds lost.
So we can talk about either.
I think a lot of people who are looking at it from a cryptocurrency standpoint are looking at the main chain,
but from a Python standpoint, it's much more about the tools and the box and the things that you get inside of it.
Yeah, very interesting.
So what I'd like to do is like sort of just start with a bit of a historical perspective on what are cryptocurrencies and the blockchain that came out of it.
So let's just start there.
Let's just start with what is a cryptocurrency?
I know what a dollar or an Australian dollar or a euro is.
What is a cryptocurrency?
Let's go from a bottom-up approach.
A cryptocurrency is a unit of something that exists on a blockchain.
A blockchain is a decentralized database, essentially, or a lot of people call it distributed ledger technology.
And a ledger is a subset of a database that really just maps a user to a number,
and that number is how much of this cryptocurrency you have.
And using certain mechanisms such as consensus and sort of this new buzzword called trustless technology,
where you model interactions in between computers, assuming the other side is malevolent and looking to defraud you.
You can develop these systems that are thought-tolerant, robust, and are completely open.
So anyone can join and participate in the network.
Anyone can send funds.
Transaction fees are distributed equally among the users.
The introduction of this currency is introduced in the system in an equal or as equal as possible way.
And essentially what a cryptocurrency is, is some unit of that on this distributed network.
Right.
And there's multiple networks, right?
Like Bitcoin is its own thing.
Ethereum is its own thing.
Yeah.
So some interesting aspects, like it has no intrinsic value, right?
It's like not backed by gold.
You can't have a physical form of it, right?
I can't get like a five Bitcoins to put in my pocket, although I wouldn't want to carry that much around.
I think that sounds kind of crazy, but actually like almost all of my money is in the bank.
That has no physical form, right?
My house, that's a physical thing.
But a good portion of that is actually owned by the bank through a mortgage, which is just more or less digital.
I guess I have a paper copy that says who owns what.
But so that's not that crazy.
But the fact that it's not determined by a central bank is pretty interesting, right?
It's not controlled by a country.
One fact of Bitcoin as Bitcoin being the first cryptocurrency that was essentially hit success.
There's been other like digital currencies like e-gold or the NSA actually in 96 talked about a cryptographic mint, which is an interesting divert.
If you want to dive into kind of like the backbone of where this stuff comes from.
They were the first experiment really of this stuff that took hold.
And this was in 2008 and a direct response of the financial crisis.
And what they saw was a lot of financial lending and the mechanisms to make money are essentially a bank goes and borrows it from a central bank to fill out a loan or something like that.
And the rules are different.
You essentially need 10% of the capital on hand to secure a loan.
So what that means is if somebody pays you $10, you can go to a central bank and get $100.
And then you can loan that $100 out.
You can use it for your needs.
And that's how money is made.
And a lot of people think that.
They think that, oh, it gets printed.
And then, I don't know, the Federal Reserve distributes it.
And everything's hunky-dory.
But because a bank only needs a certain amount of money on hand, they essentially have a 10x multiplier of their working capital that they can create out of nothing, essentially.
And this doesn't make sense to a lot of people because not a lot of people understand what fractional reserve banking is.
In Switzerland, for example, you can borrow against the central bank.
I know in the EU, you only need 3% to 5% on hand to get whatever loan you're seeking.
I don't know what it is in Switzerland because they're not in the EU.
But you can borrow from Switzerland's central bank for 0% interest.
And so, you literally can just make money if you're in a position.
And, of course, that's what sparked the entire financial crisis was these banks were creating these loans for these bad mortgages.
And it was money being created from borrowing from the central banks and from the Fed.
And then, all of these banks had these assets that were really, they only had 10% actually there on file.
And then, when the rating agencies were essentially rating these bad loans as good, it eventually started to crumble.
And that's when it fell.
And so, what Bitcoin is solving is that that mechanism to print money is not as open or controlled by central authority.
And that's why a lot of people are interested in it.
Right.
And it's not as real as people see real money, printed money, versus, say, just like kind of created digital money.
Yeah.
But I would just conjecture that to understand.
A lot of people probably think they know where their money comes from and how money supply is introduced into the economy.
But when you start to tell people or explain to them the true nature of who prints money, it's generally the banks who borrow money that doesn't really exist, quote unquote, in a natural state.
Yeah.
That's pretty wild.
Yeah.
And so, then it's not that crazy to think that, oh, this experiment of let's create a digital currency suddenly has so much in value.
I think a lot of people say, oh, well, it's worthless.
I guess.
I don't really know.
Because at the same point, gold and silver went through similar phases of being completely overbought for speculative value beyond their use in electronics or things like this.
Yeah.
They're true.
Natural value.
Interesting.
Yeah.
So, Bitcoin was invented in 2008.
I didn't really, in my mind, tie that to the financial crisis, but the timing is perfect.
So, why don't we do this?
Why don't you walk us through the steps of what actually happens when I, say, purchase something with a Bitcoin?
Like, how does that work with the blockchain and the algorithms and stuff like that?
Like, if I walked down to, like, the restaurant and I wanted a slice of pizza, I would get out of my pocket, like, a dollar or three dollars and hand it to them, right?
What happens here?
Yeah.
So, basically, at the start, you need a wallet and the person that you're going to send Bitcoins to needs a wallet.
Let's assume in this example that you already have Bitcoins.
It's a lot easier to start at that point.
Yeah, sure, sure.
So, to create a wallet, it's really just a cryptographic public-private key pair.
So, you essentially create 256 bytes or whatever the size may be.
Randomly on your computer, the rate of collision is so small that you can assume, okay, it's like picking two atoms in the entire universe and them being the same atom.
So, I trust that enough to make a private key out of it and then there's a mechanism by which you can convert that into a public key and then into an address and that's your wallet address.
So, Mike is a string that is his public key, which he sends to individuals when they want to pay them money.
So, you have this private key and this public-facing key and then the restaurant to buy a slice of pizza has the same thing.
So, you would go into the restaurant, they would give you essentially your bill.
I must say it's in Bitcoins.
We could use the pizza example.
The first real payment of Bitcoin was way back in the day and it was 10,000 Bitcoins for a pizza.
That's got to be the world's most expensive pizza ever.
It is.
So, let's assume you're that poor soul who bought that pizza and the bill is 10,000 Bitcoins.
What you essentially have to do then is sign a transaction saying, I approve the transfer of Mike's Bitcoins to Bob's Pizza Shop.
These 10,000 Bitcoins are now owned by the pizza shop.
And you submit that to the network, which is a decentralized network of peers, very similar to the way that BitTorrent works and the fact that each peer knows about just enough peers so that not everyone's connected to everybody.
And such that messages can still get routed to anyone that they need to fast enough, right?
So, this network gets propagated and it gets added essentially.
Everyone gets known of it and it gets added to something called the mempool, which is just the memory pool.
And it's essentially a stack.
Well, technically it's a queue.
So, it's a queue.
Yours gets put on the top.
And what happens is you can think of it like a garbage chute where you throw the transaction in.
At the bottom, there's a dumpster.
That dumpster is the block.
So, what happens is when you've probably heard of mining, right?
And so, in any point of time, a block's either being mined or it's being created.
So, let's assume that before it's mined, it has to be created, which is also another strange thing.
What occurs is then you pull the lever, you open the chute.
The transactions fall into the block or the dumpster in this case.
It fills up to a certain point.
In Bitcoin, it's like one megabyte or something.
And then you close the chute.
That block has a block of transactions in it.
And now, good to go.
Become mined.
So, those transactions are in the transaction.
Now, maybe the mempool is super full.
It hasn't been garbage day for a while.
Or a lot of people are throwing garbage out.
And so, you might have to wait a while for all those blocks to be minted.
Because after the block is full, the miners get to work.
And what a miner is essentially doing is trying to solve this puzzle where they take the entire data payload of the block and they turn that into a byte representation and hash it.
And so, you hash it.
You get a good, what, 32 bytes or something if you use SHA-256.
And then what the challenge is, is to add an additional piece of data such that when you hash the block together with what's called a nonce, is the hash that is produced is under a certain numerical value.
And what this means is that, let's say you hash something and it's 1, 2, 3.
It's 123.
Now, bytes can be represented as hex, and a hex is a number.
So, that's generally how you get a numerical value out of the piece of data.
So, let's assume in this example it's 123 is your hash.
Now, the thing about cryptographic caches is you can't reverse compute them.
You can only compute them forward.
They're one-way cryptographic caches.
So, you're never going to know what the outcome is before you hash it.
And you can never undo that hash.
So, you have the block.
You give it, like, one byte.
You try that hash.
It goes forward one way.
You get the thing out there, and it's 456.
Okay, great.
You try that, and you notice that you can get a whole bunch of different combinations.
Now, the network decides what is an acceptable answer.
With Bitcoin, because there's so many miners, it's a very, very,
hard problem such that it may be, let's say in this example the difficulty is 10.
So, only hashes that are number 10 or less are acceptable,
and then that pass the mining test or challenge.
So, you start hashing, and 999, that's 1,000 different variations,
and only 10 of them are accurate.
So, it's a 1% chance that you're going to get something
are going to take about 100 hashes, right?
And so, the hash rate of this network is 100 hashes per block.
Now, you hash, hash, hash.
You eventually find something out of 100 hashes.
What happens in Bitcoin is then you submit that.
Everybody agrees that's the correct answer
because the difficulty increases,
and it also makes sense in a second.
But because the difficulty is so high in Bitcoin,
it's not like two people are going to get the same answer
at the exact same time.
And so, if somebody does,
you say, well, that's the answer.
It gets propagated.
It gets added onto the blockchain.
And then you go back to your dumpster.
You pull the lever.
Shoot full.
It's full.
And you repeat that, right?
So, the thing about Bitcoin is a block is minted every 10 minutes.
And so, the answer to that difficulty or hashing question
has to be,
by what hash rate,
given all the miners and all of their power in the network,
do we have to make this puzzle
so that one solution is found
about once every 10 minutes?
And that's why you say these things like
Bitcoin's hashing power is greater than the country of Denmark
because what I just explained isn't necessarily anything useful.
It's just a way to introduce blocks to the network at random.
And I will note that this is because
the introduction of Bitcoins to the network is fair
and distributed like such.
So, you never know what hash you're going to get
before you hash it,
and you never know what your data payload is going to hash into.
And so, it's a fair distribution.
That's the purpose of mining.
However, if you say that our hashing network is 100 hashes per second
and it's us two,
each of us has a graphics card that can mine 50 hashes per second,
that makes sense.
So, the block time is one second
because you have 50 hashes, I have 50 hashes.
There are 50 hashes per second that we can compute.
We add them together.
It's 100 hashes.
Block time is one second.
The difficulty is, you know, 100 hashes per second on average.
Now, if somebody else comes with their card and they add another 50,
suddenly there's 150 hashes per second on the network
and the blocks are going to get produced faster, right?
A third faster.
And so, what you need to do to stop that
because you don't want to over-mint the production
and introduce more coins into the network than you can over time
is to make that puzzle a little bit harder
so that it takes about 150 hashes to solve instead of just 100.
And that's what has happened with Bitcoin is that so many miners have been seeing how much money they can make with Bitcoin
and seeing the price skyrocket that they're joining and doubling down
and people are making basic miners that have ridiculous numbers of hashes,
like trillions of hashes per second.
Yeah, the computational stuff going on there is really, really intense.
Exactly.
Imagine this toy example multiplied by literally trillions and trillions and trillions of hashes
and that's what Bitcoin has turned into now.
NerdLettering makes unique swag for Python developers.
Think Python-themed mugs, mouse pads, t-shirts, and more.
Dan Bader, a previous guest on the show, and his wife Anya founded NerdLettering in 2016
to bring you uniquely designed Python accessories that will spruce up your daily stand-up meetings.
Go and check out their huge selection of Python swag.
Just visit talkpython.fm/nerdlettering and get 10% off your entire order.
That's talkpython.fm/nerdlettering.
The discount will be applied automatically on checkout.
Now it's up to you to check out all their Python swag.
You talked about the mining and you talked about the purchasing.
Is a mining operation necessary to do a purchase or like an exchange?
No.
And so what really happens is you give, miners are incentivized by Bolt,
the potential that they mine a correct block and get rewarded.
And a transaction fee by which you have to essentially pay a little bit of Bitcoin to the network
for it to get properly propagated and people to know about it.
So you as a consumer have to pay that transaction fees,
but you do not have to mine your own transactions.
I see.
So it's a little bit like the credit card fees or something.
Exactly.
You talked about the computational stuff.
Something that I thought was pretty interesting is just to give people a sense of what that means.
Right.
Like there's so much power being put into some of the cryptocurrency and more broadly,
not just Bitcoin, that like it's starting to affect cities.
So there's a city called Plattsburgh.
I think it might be in New York.
And it became the first city in the United States to ban cryptocurrency mining because it
had the cheapest, some of the cheapest electricity rates in the world.
So a bunch of people had moved there and it turned out that they had like some local sort of
renewable, probably hydro supply or something.
But once that was used up, then they had to go buy it on the open market.
And that was a lot more.
So it turns out that the average bill of just the people living in the city went up by $100
to $200 a month because the cheap energy was used up by miners who had moved in.
It's crazy, right?
Yeah.
And it's not for anything.
It's the fun part.
So it's not like you can rest easy and say, well, all that energy went towards what supercomputers
do, which is folding proteins to find new medicine.
It's just seeing who gets the next piece of money.
That's all for.
Yeah, this probably is a little out of date, but I heard that to generate one Bitcoin is
about the same energy as one U.S. household uses.
Does that sound about right?
For a year?
Sorry.
Yeah.
Now, of course, you got to put a time frame on that, right?
Per month.
Yeah.
I believe that.
Yeah.
That's pretty wild, right?
So let's talk really quickly about some of the popular cryptocurrencies.
You talked about Bitcoin.
There's Ethereum and some others, right?
Yeah.
So what would you like to talk about specifically?
Which ones are they?
Just give us a couple other examples of popular cryptocurrencies.
Everyone's heard of Bitcoin, but what are some of the others?
So there's Bitcoin.
There's Ethereum, which is architecturally different.
There's also Monero, which is architecturally different.
There's some what's called Bitcoin clones, like Litecoin or Dogecoin, which is based off of a meme, or even Zcash.
And I'll get into these differences.
Essentially, the differences between each of these blockchains can either be apparent, such as Ethereum, which is completely different,
and then has these things such as called smart contracts on them, or not so, like Litecoin.
Litecoin's really just a fork of the code base, and they modify the block time, so then you don't have to wait as long for a block to be mined,
and it's supposed to make payments faster.
I don't know about that.
But Ethereum's interesting because a smart contract is a much more complex payment.
So, for example, the pizza company could have a smart contract by which you pay a dress, which has a piece of code called Solidity Code,
and this is what I alluded to being difficult to develop earlier, is that when you pay it,
and perhaps you give it, like, a receipt ID or something, it can look up your receipt ID and see if, oh, this piece of pizza that you're buying is, in fact, how much money you're sending,
and it could credit you, like, a point, and then you could redeem those points later for a free pizza or something like that.
So that transaction style is a lot more complicated, and it really is use case to use case appropriate.
Like, I don't think that it would be possible to model all of these natively into the blockchain and then support all the complexities that Ethereum can easily.
So that mechanism is called a smart contract, and it uses code that is deployed onto the blockchain that's all open source.
You can read all of it, and it acts exactly, essentially, how it's written.
Every single computer that runs on the Ethereum network has something called the Ethereum virtual machine built in that has its own operation codes,
like assembly, and has its own instruction set that does certain things so that if everybody has the same version of the Ethereum virtual machine,
when they consume the operation code with the transactional payload that you create,
it's going to spit out the same outputs or updates to the chain.
And that's really powerful for a lot of cool things, especially if you're trying to make an automated task that you require some level of trust to complete.
Example would be, like, identity verification.
There's a service called, like, Civic that essentially hooks up with know-your-customer clients,
and what they'll do is they verify for you and put a little tag in their quote-unquote database so that if other people can then say,
oh, if the person who's sending me money has been verified by the Civic smart contract,
I'm going to continue with my smart contract and perhaps grant them access to a certain app or things like that.
Right. It's like a distributed trust verification, sort of federated identity almost on the blockchain.
Yeah, it's a really cool concept.
And the more that you get around it, the more you understand why people get so excited about it.
Yeah, pretty interesting.
So let's talk about the blockchain because I think people listening may be interested in cryptocurrency,
but I think the blockchain is more broadly applicable to everyone.
And, of course, that's where I started with cryptocurrencies because that's where the blockchain came from, right?
Yeah.
Yeah. So what is the blockchain?
So blockchain is essentially, on the initial example I said, it's a distributed ledger, right?
And with a ledger, you're mapping the address to how much you have, essentially.
With the blockchain, maybe you don't want that restriction.
Maybe you want to have really anything, supply chain proposals, ISO verification, things like that, on your network.
And you don't necessarily want to work with Ethereum because Ethereum costs a lot of money to do a transaction.
It costs a lot of money to put up a smart contract.
You could pay easily $60 to deploy a smart contract onto the mainnet.
Maybe you don't really want to do that.
You want to have a little more control over what you're doing or a little more customability where you have what's called a consortium with individuals that all have a common goal.
And one of those goals is to make sure that their interactions aren't completely public.
In the case of industry, that's where you use the blockchain.
So when everyone says that the blockchain is much more important than cryptocurrency, it's because of that.
Right.
Because it's the foundation of cryptocurrency, but it can also be used much more broadly.
Yeah.
The place I seem to hear it the most just in popular culture, popular tech culture anyway, is around like supply chain stuff.
Right.
Like there was recently a some kind of salmonella thing with vegetables.
Right.
Or if you're if you're like creating parts for cars or whatever.
Right.
You could theoretically tag them on the blockchain and like keep track of where they came from in some sort of variable way.
Right.
Yeah.
Correct.
Yeah.
So how would that work?
Like just because it has something on the blockchain.
How do I know that that means anything?
Right.
Identify where it comes from.
Yeah.
Yes.
I mean, like every system has to have some level of trust.
So you trust the Bitcoin developers.
Right.
They didn't screw something up.
So similarly with, let's say, supply chain.
Say you put out an RFP for a bunch of potatoes and you're going to make sure those potatoes are really potatoes.
You do have to trust that the sampling of people who get to see and respond to your RFP are, in fact, potato suppliers.
And somebody makes that judgment call.
Now, usually in systems, it's procurement department, which has a list of potato suppliers and life is good.
They might have some certifications.
Right.
And so those certification departments are the ones that make a judgment call that they are, in fact, decent enough potatoes for you to eat.
And it becomes a web of different certification agencies and certain bureaucracy and all this other stuff.
You really just want to know, can the guy send me potatoes?
It shouldn't be that hard.
With blockchain, it's similar to the identity verification that we just covered, where you do have entities that verify these things.
But that information is essentially looked up upon.
Like ISO is a perfect example.
We already have the people who go through and inspect for ISO standards.
They should be able to publish that to a network that can easily be integrated automatically with other applications so that you can put an RFP out and you can instantly filter across the entire global world of all ISO individuals who can supply you a part that complies.
You do then have to trust ISO.
But most people already trust ISO.
So it's generally what they mean.
Yeah.
So how does it work in reverse?
Like, let's suppose I find, like, some lettuce in my grocery store and it's bad, but it's been tracked with a blockchain.
Like, how do I go and, say, use that to unravel?
Well, these are all the things that have to be recalled and nothing else.
Yeah.
So I guess, like, the RFP example, right?
So we had this transaction occur where the lettuce supplier or potato supplier or whoever has responded to the RFP to send these heads of lettuce to this grocery store.
And that is a transaction upon this ledger.
Now, the ledger can never be changed.
That's a very important aspect.
It's a linear ledger in time.
So no one can go back and erase that that didn't happen.
So they're always on the hook for sending that grocery store that lettuce.
And they know that.
Now, you can get as low as, say, on the rubber bands.
They each have a little RFID tracker that bundles all the lettuce.
So then at every point from delivering that from California to New York, you have the people unloading it at different supply chain stops, scanning it, and then doing a transaction on the blockchain again to say, yeah, this lettuce came here.
And that lettuce references the original transaction that says, yeah, this lettuce is in response to this RFP from this supplier to this grocery store.
And so by the time it gets to the grocery store, there's been a transaction law that cannot be changed by anybody in the system.
Okay.
Yeah, I see how that works.
That's pretty interesting.
I think it's really valuable in the sense of sort of accountability.
I guess maybe tying it back to our previous conversation just a tiny bit.
One of the things that seems really interesting to me around the cryptocurrency stuff because of the blockchain is in some ways it gets you outside of the country's controlling currency.
And in some ways it gets you outside of banks and credit card companies.
And it gives you this like privacy of it's like just me and my coins and I can exchange them just like with numbers.
And in some sense that's great.
But then every record of every transaction I've ever made is fully public.
Right.
And so in some other sense, it's kind of almost like a loss of privacy.
Like if you ever learn what my wallet ID is, you've learned what every purchase I've ever made is.
What are your thoughts on that?
Yeah.
I mean, that's why I kind of poked in this.
Oh, the NSA is described.
We would love this.
Yeah, exactly.
They did subscribe to e-currency since 96.
So there's a lot of speculation that like why would a security agency that has been essentially called out and it's well documented has been spying on citizens in a dark network of intelligence services.
Why wouldn't they love Bitcoin?
And why wouldn't they be pursuing a technology that makes all the transactions completely available in public?
Because you can easily spot criminals that way.
And you can easily track.
And here's the fun part.
If you've ever gone through an exchange like Coinbase or something, Coinbase is legally obliged to tell the NSA or the FBI or whatever what your wallet is.
So it's already done.
Right.
So you're like you're saying your privacy is already scooped up and taken apart.
Like there's no way for me to buy a Bitcoin unless you mine it, which is extremely hard to do without going through some sort of fiat gateway, as they're called, which leaves a paper trail to your address.
And if there's a subpoena and there's a reason for you to have your wallet address disclosed, it will happen.
So, yeah, my thoughts on that are that it's flawed to think that Bitcoin is anonymous anymore.
It's anonymous until it's like extremely not anonymous.
Like as soon as it like the veil is cracked, it's like fully, fully open, which is pretty, pretty wild.
Okay.
So back to, back to blockchains more broadly.
So I did a little poking around and found some pretty interesting startups based on this.
Let me just give people a little bit of a sense of some of these.
So they get a sense.
So there's Elastos, which is trying to create a new secure operating system to make digital assets scarce, identifiable and tradable.
Like they have these things called D apps that run on a peer to peer network, which is kind of funky.
Ubicoin, Ubicoin, yeah, Qoin, coin.
I don't know.
Decentralized global currency for everyone.
That's, that's pretty wild to make it a two coin ecosystem to make it immune to volatility.
There's audit chain for like decentralized auditing.
There's a XSUL coin for solving refugee crisis issues.
Pure gold.
I was trying to make a cryptocurrency backed by gold.
Pharma trust for counterfeit drugs.
Just all these types of things.
It seems like there's a lot of interesting stuff, but it's ultimately the theme is kind of around distributed trust or trusting things you only sort of should have limited trust of.
What are some other examples that, you know?
Exactly.
I mean, supply chain is a perfect example or like a clearing of contracts, whether those be financial contracts, which generally are cleared through completely centralized standpoints, which like synthetics and things like that.
The things that the regular people like us would not be able to get our hands on.
It's a really massive issue.
Same with like ACH settlements and things like that.
Banks don't necessarily trust each other.
Yeah.
Well, and there have been like a few extremely high profile ACH transfer failures of the SWIFT network over the last couple of years, like hundreds of millions of dollars type of failure, right?
Yeah.
And it's actually pretty easy to commit ACH fraud because ACH is from like the 70s and you go through a process where you can obviously send ACH wires to people, but some companies have the ability to take money from you with an ACH.
And you basically go through this process and you get approved and then you have a license to essentially take money from anyone in the world with an ACH account.
That obviously leads to a lot of bank fraud and that's a problem.
Yeah.
That's, yeah.
Just put it politely.
That's a problem.
But that's the world we live in.
It's like pretty archaic around the banking stuff.
Hopefully that gets fixed.
And I think that's why things like cryptocurrency and stuff like are appealing because in general, the banking system is like super curmudgeon-y, rarely in the modern world, right?
Oh yeah.
Ironically.
They have the money to get around it, right?
They just don't.
Now that we've talked about the blockchain, we've talked about cryptocurrency, let's talk about what you're doing at Lambden because you guys are building some amazing tools for building upon the blockchain, right?
And apps that, like some of these startups I talked about, using Python or Python-like tools, right?
Yeah.
All right.
So what is Lambden?
Tell us about what that is.
Let's start there.
So Lambden is a suite of tools.
It allows you to create as much or as little of a decentralized application that you want.
So that can be your own.
And I'll preface this.
We expect people to be picking up this and be completely technology agnostic.
They don't want to use Bitcoin.
They don't want to use Ethereum.
They don't want to use really anything that's a main network because they're limited.
Their needs of like Ethereum's needs and features and support is tuned towards Ethereum's users, not necessarily your users.
Right.
So let's say, suppose I'm like, let's say I'm Chevy, okay?
And I want to make a blockchain just for internally for controlling and tracking my stuff.
Like we could so go to Lambden and use your APIs and your infrastructure and we wouldn't have to like deal with any of the public blockchain stuff, right?
Okay.
Yeah.
And so like what are called main networks really focus on a main network, a single distribution.
So Ethereum has abilities for you to create private networks, but there aren't really the resources to support that because they don't necessarily care or that's not their main priority.
Their main priority is a world computer that's trustless.
So the motivations don't align.
With Lambden, we provide the tools for you to build first and then later kind of solidify that.
And so what I mean is that we have an automation tool that allows you to build, it can be a Lambden-based blockchain or maybe you want a private Ethereum-based blockchain and then start installing things on that like you do with packages.
So like in a Chevy example, let's say that they do want to use Lambden's blockchain, which is developed from the ground up in completely Python.
They would use something like our tools to create a Docker container and then be able to install smart contracts on them like they do just regular pip install packages.
And that doesn't really exist in blockchain right now.
There are smart contracts, but they are kind of sprinkled across the internet on GitHub and really left you to copy and paste them in most cases.
And it's very obtuse.
So we're cleaning that up.
And in terms of like our tech, it's performing.
There's a lot of things wrong with Ethereum and Bitcoin.
The transactions are slow.
I've never bought anything with Bitcoin or anything like that.
For a little while, there was a possibility.
I use Stripe for my course site and stuff like that.
There was a momentary time where I could have accepted payment for courses in Bitcoin via Stripe.
But they actually canceled that because it was too volatile, the price.
And they couldn't deal with getting the money back around before it was a different price, basically.
So when people say, I've heard that it's slow.
Does slow mean one second, five seconds, a minute, 10 minutes?
What does it mean?
45 minutes, about.
Okay.
That's pretty slow.
It's pretty slow.
Yeah.
PayPal's fast.
That's slower.
Yeah.
PayPal is way faster.
And credit cards are way faster.
Okay.
So you're trying to solve this slow problem.
Yeah.
Slow problem.
It's that PayPal, if they charge you, they charge you a lot less than a Bitcoin transaction.
Like, depending on things, it's usually about 30 bucks.
And it's come to the point because Bitcoin prices are so high.
I mean, two years ago, it wasn't a lot of money.
But now the transaction costs, which is in Bitcoin, is about 30 bucks.
So it's ridiculous.
But for us, yeah, our mechanism is that instead of having mining on this enclosed end with all these miners,
is that each transaction, you do that mining proof and the difficulty is much, much, much lower.
And what that allows us to do is get rid of mining altogether, which is the block of all this.
If difficulties were lower and we weren't necessarily worried about introducing currency at a distributed rate,
we can speed it up as fast as we want.
Because dumping the garbage into the garbage dumpster doesn't take that long.
It's very fast.
But what takes long is the mining.
So if you have to mine your individual transaction, which is slow from a user-to-user standpoint,
you know, like a second or two, it actually makes more sense.
So myself as an individual can only send about one transaction per second on my MacBook
because I have to generate that proof.
What that means is that I can't send a million transactions per second and clog up the network,
which is one of the reasons why mining exists, too, is an anti-spam mechanism.
So we're one of the few blockchains that looks at it this way,
and that allows us to have free transactions because we know that our system is performant enough
to be able to process large amounts of transactions.
What you really have to worry about is spamming mechanisms, like anti-spam mechanisms.
And you can't really do just DDoS protection on a decentralized network.
Yeah, of course.
Interesting.
And so one of the ways that you program these is with this thing you've created called Seneca, right?
Tell us about that.
So Seneca is essentially restricted AST, our abstract syntax tree of Python.
So it's Python, but when we run it as Seneca, it's extremely restricted in what you can do.
And the reason is that you need to lock down smart contracts so that there aren't gaping security holes.
One of the classic examples is let's say you create a smart contract with a wallet true loop in it
that just doesn't do anything.
You submit that, and then you push a transaction out to it.
Now all of the miners which are trying to figure out what the end result or output of the smart contract are,
are all locked.
And so that's a really, really big, glaring security hole because now nothing can go through
until they figure out how this contract ends and it never ends.
So we restrict things like that so that it makes sense from a programmatic standpoint
because it's Python and it's simple to use, but also so that it doesn't have these security holes.
When you guys described it on the GitHub page, you said it's not true.
It's true.
Right.
And that's because you're trying, it's still restricted that you can't do things like,
well, let's just go around forever.
Or, you know, if you limit it enough, it's basically safe to use.
Exactly.
And that's because transactions are, they exist in a domain that can be turned incomplete.
They're not games.
They're not simulations or really anything that could have these extremely complex long-running processes.
And so they're light source of transactions.
One of the reasons why we chose that is because Ethereum's system is turned incomplete.
And that essentially creates a ton of errors.
And there's been like million-dollar hacks where people can take advantage of the security holes in Solidity and just, you know,
ping a small transaction that the developers didn't think was going to happen or that's a previously undiscovered hole in the compiler.
And then blow up the contract.
Freeze everyone's funds.
In some cases, steal people's money.
And we don't want that to happen.
And that's one of the reasons why we lock it down.
Yeah.
Is there any special interpreter or runtime that runs it?
Or is it just that you restrict what is valid code by limiting the operations and stuff on the AST?
Yeah.
So that's also an interesting point is that we don't have a virtual machine like Ethereum does.
We have this interpreted subset of Python, which is just a parser of the AST.
And the way that we say, okay, this is valid and this will work is because every single computer on the network has the same rules to parse the AST.
And the outputs of the contract are database reads and writes.
They aren't necessarily strange bytecode like it is on Ethereum.
It's instructions to update your database, which is the state of the blockchain at that particular point in time.
So actually, by taking a high-level approach, which is what Python does as a language as well, weed out a lot of the security problems from an obscure standpoint.
Because most of the Solidity errors are user-generated.
They write this code and it looks like it's going to behave one way.
But then when they compile it into a machine code that they can't humanly read, it does something else.
Yeah.
That sounds like such an incredibly tricky problem.
It's almost like let's take this super complex thing and blacklist the stuff you can't do.
And then there's always creative people that are like, well, but they didn't blacklist this one.
We're going to do that.
Where as you're almost whitelisting and saying these are the things you can do.
So go with that.
Yeah.
All right.
So we're just about out of time.
But let's just do one really quick thing.
Let's suppose in just a minute or two.
Suppose I want to take Seneca and build my own private blockchain to verify stuff.
Maybe run with the car, for example, and parse or something.
Could you just step us through the major...
What do we got to do along the way?
Yeah.
So, I mean, you can pip install most of our tools.
What you're going to want to do is get some sort of environment that has our blockchain on it.
So, Lambda comes out of the box with a setup that works for smart contracts.
I will copy it that this is still a project in development.
So don't expect to be able to pull all this stuff and be able to go right away.
But, you know, our main goal is by Q3 or Q4, all this is ready to go.
So you pull this in, you have this Docker container or this container, which you can then write Seneca contracts with in a way that feels like a database, like SQLAlchemy, right?
And that the blockchain is running in your container.
But really what that means is that it's a database that can be open to decentralization and consensus.
So you start to write these smart contracts, you start to deploy them, and they have certain locations on the blockchain, which they accept transactions, and then they update the state in the blockchain.
So let's say you start writing these contracts.
You have different ways to verify different parts are coming through.
Everything's working good on your single node.
What you then do is want to decentralize that and start having other people spin up these blockchains, obviously copies of your blockchain.
But you start to have people install it on their computers.
Everyone's computers start forming a cluster together.
And then suddenly when you start to change something on one computer or send a transaction, all the other computers automatically say, okay, we just ran the smart contract.
It's supposed to update this record, right?
And as long as the majority says, yeah, then they run that SQL query.
They spit it back to a special node, a special group of nodes that holds the cold storage of the blockchain and the system continues.
So you would essentially, after the point that you are ready to go and you have the functionality that you want, you would just have enough people to support the network such that it's decentralized and you could really just run from there.
Yeah.
That sounds really cool.
And the fact that it's in Python is pretty awesome.
Python and Docker.
Awesome.
All right.
Well, Stuart, I think we got to leave it there for all the blockchain stuff.
But let me ask you the final two questions before we go.
So if you're going to write some Python code, what editor do you use?
Yeah.
So I use Sublime from if I'm trying to be more serious.
My personal choice is Sublime, but I will use PyCharm in a more enterprise setting that has all the testing and coverage and all that stuff automatically in.
Right on.
Sounds good.
And how about notable PyPI package?
Yeah.
I did say Karis, which I really enjoy.
Requests is good.
But I don't, you know, I like stuff.
Yeah.
So something that maybe you like ran across and people are like, you're like, wow, this is awesome.
This is maybe not the most popular one, but people really should check out something.
I've been looking at a lot of quantum stuff.
And of course, if it's scientific, it's going to be on Python before anything else.
So this is interesting.
I know nothing about quantum at all.
But I found this.
I want to get into it and kind of try to understand it.
I'm nowhere near ready to really go for it.
But it's this thing called Strawberry Fields by this company called Xanadu that is looking to create hardware that works with optical quantum processors rather than right now you need to super cool it in like liquid nitrogen.
And so if they can do optical, then it can be in your computer or your phone.
And so I'm looking at their library called Strawberry Fields to start to make sure I'm like, got my ear to the ground about what's happening.
Because I think quantum is really going to do a lot of crazy stuff in the next 10 years.
Yeah.
It's going to be really interesting.
And the whole like, if you had a quantum computer, you could do this mining like differently.
That would be that would you have your own island.
Oh, yeah.
Yeah.
It gets into also pyro.
I don't like Uber as a company for their ethical concerns.
But it pains me to say this, that they have a probabilistic library called Pyro, which is very cool.
And there's one called Edward as well, which is another probabilistic computing library that is very, very neat.
And I think that the crossroads between quantum is a probabilistic computation and machine learning that's going to Bayesian sort of stuff and probabilities is going to be massive.
Or just soft computing in general.
And how do you make a distinction between hard choices and things like that?
So those are the types of libraries that in my free time, you know, I'm trying to like not chill.
I'm trying to do something productive.
I'll poke around it.
Wow.
That's yeah, those are really awesome and quite interesting and out there.
All right.
Final call to action.
People want to get started with blockchain.
What do they do?
I want to get started in blockchain.
I mean, go over to Lambda.io or read our blog, blog.landa.io.
Start to situate yourself with things and then start to start to play with it.
I actually would conjecture that Solidity is a good starting point, even though I have criticized aspects of it.
Does not make it a bad starting point to get into smart contract development.
And that's where you really should take your first steps into things.
All right.
Sounds good.
Well, people are interested.
Go check it out.
We'll put some links in the show notes and thank you for being on the show.
Absolutely.
Thanks for having me.
Bye.
This has been another episode of Talk Python to Me.
Today's guest has been Stuart Farmer.
And this episode has been brought to you by Linode and Nerd Lettering.
Linode is bulletproof hosting for whatever you're building with Python.
Get four months free at talkpython.fm/Linode.
That's L-I-N-O-D-E.
Make your day more Pythonic with Nerd Lettering's Python-themed mugs, t-shirts, stickers, and more.
Visit talkpython.fm/nerdlettering and get a 10% discount on your entire order.
Want to level up your Python?
If you're just getting started, try my Python Jumpstart by building 10 apps or our brand new 100 Days of Code in Python.
And if you're interested in more than one course, be sure to check out the Everything Bundle.
It's like a subscription that never expires.
Be sure to subscribe to the show.
Open your favorite podcatcher and search for Python.
We should be right at the top.
You can also find the iTunes feed at /itunes, Google Play feed at /play, and direct RSS feed at /rss on talkpython.fm.
This is your host, Michael Kennedy.
Thanks so much for listening.
I really appreciate it.
Now get out there and write some Python code.
I really appreciate it.