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