Muneeb Ali: Stacks – Building Decentralized Apps and Smart Contracts on Bitcoin #379
17 Feb 2021 · 1:11:22
Muneeb Ali, CEO and co-founder of Hiro Systems, joins Epicenter to discuss Stacks, a Layer 1 blockchain that connects smart contracts to Bitcoin. He explains the Proof of Transfer mining mechanism, the design goals behind the Clarity smart contract language, and how Stacks 2.0 differs from other approaches to building decentralized apps on top of Bitcoin.
Speakers
Topics
Transcript
this is epicenter episode 379 with guest muneeb ali hi i'm sebastian cuccio and you're listening to epicenter the podcast where we interview crypto founders builders and thought leaders on this show we dive deep to learn how things work at a technical level and we fly how to understand visionary concepts and long-term trends if you like epicenter the best way to support us is to leave a review on apple podcast if you're on a mac or irs device the easiest way to do that is to go to epicenter dot rocks slash apple and if you're new to the podcast be sure to subscribe
on apple podcast spotify or wherever you listen today our guest is muni ali we had mooneeb on over five years ago on episode 101 and back then he was working on a project called one name which was a sort of decentralized identity system where one could register usernames and domain names that project has evolved in a pretty drastic way to become stacks and stacks is a smart contract platform that is built on top of bitcoin it is powered by bitcoin in the world of smart contract platforms there are just a handful of projects that leverage bitcoin for security and stack positions itself
not as a side chain but as a layer one chain that shares the bitcoin compute power for security they just launched stacks 2.0 which introduces full smart contract capabilities with their native programming language clarity and as you'll learn in this conversation clarity has some interesting design differences to solidity and the way that we think about code execution on ethereum so i really like to see platform projects building on bitcoin there's an enormous amount of value and capital in bitcoin that just isn't productive it's sitting there and it's hodling projects like stax makes it possible for bitcoin to finance ecosystems in a way that feels much more native and intuitive than rap tokens on ethereum and in the case of bitcoin that's like
a trillion dollars of capital that could potentially finance an ecosystem of d5 and web3 apps so i'm hopeful to see projects like stacks gain traction and become successful because it can just grow the d5 ecosystem in a pretty exponential way if you need to make a swap look no further than one inch it's my go-to dex aggregator and i know that when i use one inch i'm getting the best price across all dexes and amms they recently did an airdrop and the one-inch foundation has distributed more one-inch tokens you can learn more about that on their blog or if you want to use one inch you can go to epicenter dot rocks slash one inch and with that here's our conversation with mooneeb alley we're here today with madiba ali he is the
one of the co-founders of the block stack or stax project and the ceo of a company called hero when he was on the show quite a long time ago over five years ago worked on talking about the same project actually but you know on many iterations ago and back then it was called one name and so you know it's really great to have you know have a lot of the old veterans back on the show to give updates on you know the state of what they're working on so uh but it's great to have you back on again thanks thanks for having me so yeah can you give us a little bit you know maybe give us a little bit of a recap of your background because you know i'm not sure how many of the same listeners we have from five years ago so
uh for those who haven't watched that previous episode how did you sort of get involved into crypto and this whole blockchain thing yes so my background is actually in computer science um i did a phd in distributed systems at princeton university and this is where the project kind of like started as well at the computer science department at princeton and we were actually focusing on building kind of like you know more secure uh more decentralized internet infrastructure like internet protocols not nothing to do with crypto uh in in the beginning right and and my personally i've just been doing research work in distributed systems
like for 10 15 years before starting the project and for people who are not that familiar with distributed systems think of that as the the computer scientists who work on internet protocols or operating systems or these large-scale network systems like data centers and so on so i i i was pretty much working on cloud computing effectively uh during the early part of my grad school and then uh got got pulled into kind of like this really ambitious idea of not just um you know a clean slate next generation internet design but not doing it in academia so we have actually seen a bunch of efforts in academia
where you know at stanford for example there was a project called clean slate internet design they would build prototypes they would write research papers about it but it would never really get commercialized or adopted in the real world and i i always felt that the real challenges are uh in that step like how do you actually take some of these ideas and get you know millions or billions of people out in the world to use it otherwise i think it just feels like you're just you're just sitting in a bubble and you're just in a research lab trying out different ideas so i think that was that was kind of like the motivation that let's try let's try to uh take a stab at this very ambitious thing of trying to upgrade the internet but do it in the industry right so raise venture capital and interestingly
in the early days uh we are very very fortunate to have people like you know naval review y combinator and union square ventures who effectively funded us perfectly knowing that that we are hacking on open source technology and we have no business models in mind for like 10 plus years right like this is this was the pitch right like we're we're building like this technology in a completely open source way and if it's successful like it would uh likely have an ecosystem around it uh but you know it's not like you know we have any sense of any business models we're not not it's almost like a r d project at that time and they were they were
very supportive in even funding that from a from a venture uh perspective how long ago ago did you guys start the project so this is summer of 2013 uh for people who measure time in bitcoin uh if bitcoin was at 90 dollars at that at that time so we last had you on five years ago which is 50 years in normal time tell us about what happened uh since 2015 yes so i think um to continue the story a little bit um we we quickly discovered blockchains and the and we discovered blockchains as a very
elegant solution for some of the problems that we were trying to solve right so imagine if you're trying to build like a more secure more decentralized uh dns system domain name system right or you're trying to figure out uh more secure ways of distributing uh your cryptographic keys on the internet uh like see blockchains have very natural elegant solutions for these things and we we discovered blockchains and we're super excited about it uh kind of like started digging deeper into how blockchains can be used for for solving some of these problems and interestingly uh at that time uh we we obviously you know there was bitcoin but then there were some bitcoin
forks as well this is this is pre-ethereum right ethereum did not exist at that time i i read the white paper it was not public public the white paper at that time but i suddenly someone sent it to me privately and there was a fork of bitcoin called namecoin which is still around it's it's like a semi-dead project at this point but you know it's still around but it used to be kind of like the number two or number three altcoin on on coin market cap back then and interestingly uh the choices in front of us were should we directly use bitcoin should we build a separate network which is which is what ethereum did or should we uh build on something
that is kind of like sharing the compute power of bitcoin which is which is like what namecoin was doing with merged mining right and there are different design tradeoffs uh for these approaches and the way we kind of like thought about it is interestingly it's actually easier to build a separate network right so we're seeing a bunch of blockchains being built out and and you know it's amazing i'm not saying building a blockchain is easy building a blockchain takes takes a lot of effort and careful designing and there's consensus problems to solve but connecting two different blockchains together in
consensus is actually a harder problem especially when one of them uh cannot be changed at all so that's bitcoin right so bitcoin has this very uh it's a great property that bitcoin has the bitcoin is not going to change right so if you want to work with bitcoin you need to figure out how to work with it without changing it right and that actually makes things much much harder so at that time we were exploring uh effectively merge mining type techniques but can we start building these uh domain name systems or pki systems uh but still somehow share the compute power of bitcoin and they were like we can go into some of those
challenges but at a high level there were many uh technical challenges with with that approach and we the second iteration the first iteration i would say it didn't last very long right we quickly discovered uh the problems with approaches like namecoin or or merge mining and the first real iteration which was tax 1.0 was actually directly built on top of bitcoin we actually knew that this is in the grand scheme of thing not a very scalable design because every stax transaction is a bitcoin transaction right so if a million domain names get registered on stacks a million bitcoin transactions happen
right and then the bitcoin uh core developers weren't like truly kind of excited about it we at one point we were the largest consumer of uh op return uh transactions operation is like you embed this additional data in in bitcoin transactions so you're basically using bitcoin for other purposes right you're not really doing uh bitcoin bitcoin to bitcoin transfers you're actually just using the additional embedded data and we we built like sax one pointers like think of it as a virtual blockchain like it's a blockchain built on top of top of bitcoin and that that has limitations like it did not have a full a full smart contract language it obviously had scalability limitations because it's tied with bitcoin
and but back then like back when this was launched in like 2015 or so it wasn't clear how bitcoin is going to scale right like this is pre the fork wars right even though we thought that bitcoin would always be used as a settlement layer that was the camp we were in it was kind of like still a question in the industry that uh can bitcoin actually take more data right at the base layer and now it's abundantly clear that no bitcoin is not going to take additional data so i would say around 2017 or so we started uh working on the stacks 2.0 design so it's actually been like three years in the making and interestingly i think this is this is where this becomes very fascinating
it goes back to the original design decision of 2013. do you build a separate network do you build on bitcoin or do you somehow share the compute power of bitcoin and i think that we've cracked the problem uh this time around with stacks 2.0 where it shares the compute power of bitcoin but it is not dependent like the scalability is completely disconnected uh from bitcoin it can scale independently of bitcoin and uh it can have full smart contract languages so when you when you say that it's built on bitcoin what you mean is that it's kind of it's a separate change it changed that kind
of checkpoints into bitcoin for finality purposes yeah the there's a little bit more than that right so think of that as it's not a side chain like from our traditional definition of a side chain but we we one way to think of that is it's like a layer one blockchain that directly connects with bitcoin right so what i mean by that is there's actually consensus between two blockchains right uh sure our stax blockchain has consensus internally as well but it has consensus between bitcoin and how that happens is that in terms of you're right about the checkpoint thing
but the the way it works is that you can do thousands of transactions on the stacks blockchain and they automatically settle on bitcoin every bitcoin block right so for people who are familiar with uh with lightning think of that as uh lightning channels that are settling on bitcoin every bitcoin block automatically and and the way they the consensus works is that the miners of the stacks blockchain they actually view the state of both bitcoin and stacks they're competing to become a miner using the bitcoin blockchain but if they win so there's a verifiable random function on bitcoin
they're sending transactions on bitcoin to participate in leader election right so they're actually bidding bidding in bitcoin to to win a block and the miner that wins a block writes a stax block right because they have visibility into both right and there there's consensus in between both so the interesting thing that happens is that uh let me let me share some stats here i think in the first 2000 uh blocks of uh of our blockchain so it launched around january 14th what we've seen is miners have sent something like you know close to 25 000 transactions just for these bitcoin commits
right they're they're competing they're trying to commit bitcoin and they have spent something like 43 bitcoin which is like around 1.5 million dollars in that competition right and in in it what's happening is that the value of a stacks block it they're bidding on that value in bitcoin directly on the bitcoin chain right instead of having hardware and asics and burning electricity to compete for for mining a block right and and that's that's super interesting because what that does is it says that you don't need a separate proof of work chain you can reuse you can actually ride on the the bitcoins uh proof of work if
you we're using bitcoin uh the asset as a proof of computation right and we shared the security of bitcoin because the way our consensus works if someone wants to come in and change the history of stacks they would actually go and attack bitcoin and re-org bitcoin which you know the good luck with that that is by far the most secure secure system out there so that's that's that's kind of like this works and there's more to it and we happy to help you dive a little bit uh more into the algorithm one inch is a decentralized exchange aggregator that sources liquidity from the top dexes and amms to save you money and time on swaps one inch finds the best possible trading
paths across over 20 supported liquidity protocols and splits them up across multiple market depths i started using one inch last summer and since then it's become my go-to aggregator i use it every time i need to make a swap they recently launched v2 which has a brand new api it greatly improves their routing algorithm and my favorite part about the v2 is the new ui it's super clean and easy to use these improvements ensure that you get the best rates on your swaps with the lowest possible response time so the next time you need to make a swap forget about getting the best rate or optimizing your gas fees make it easy on yourself just use one inch and you can let them know that we sent you by go to epicenter dot rocks slash one inch that's one inch we'd like to thank one inch for their
support of the podcast how exactly do these bids work like so let's say i want to be a block producer and like create stacks blocks how do i become the leader for this round so the way this works is that you're effectively you can look at historical data to see you know what at what level of bidding are people actually winning blocks right because and and then uh there's also a smoothing function uh in the sense that we don't want uh miners to
uh come in very quickly and then stop mining very quickly we want there to be some sort of smoothing function because in the bids are actually going to depend on the stx btc price pair on exchanges some of the miners i can tell you that they model mining as a uh almost like a dex where they're looking at uh the ptc stx price pair and they want to mine if they can get a cheaper rate than the binance stx btc price or you know some other exchanges bdc price so they view this as an arb opportunity so miners will only mine if they can get cheaper stx from mining
then whatever is the ongoing real time trading rate outside and plus obviously there there are more details there because you're not there's some delay in them actually getting the stx and their other other complexity involved but at a high level you can model that as a as a dex running on bitcoin right and in the process of trying to uh buy up the sdx that's being released the consensus is a byproduct of that but so how how does the bid actually work like do i send bitcoin to a particular address and so and if so if i don't get if i'm not the winner of the auction how do i get my bid back so first i'll explain
the concepts with just a burn address right so imagine that all the bids are going to a burn address and and bitcoin is being burnt and what's happening is that there is a verifiable random function and it effectively looks at if you burn more bitcoin your probability of winning goes up but it is it is still a vrf right so it's you're not guaranteed your probability goes up but you're not guaranteed to win so with an n is over a window as well right so what happens is in any given block the the verifiable random function basically spits out
who the winner is right and that winner gets to write the the tax block and collect the coinbase fees the newly minted tokens from stacks and the clarity smart contract fees and the transaction fees uh from stacks so that is the value of the block uh for for the miner but then this is a lot of bitcoin being destroyed right so we worked on a improvement where you're like instead like for example just in the first 2000 blocks like 1.5 million dollars worth of bitcoin would have been destroyed so we worked on a improvement where the miners can actually agree on a set of bitcoin addresses which are the reward addresses
and these are people who hold the stacks cryptocurrency on the stacks blockchain and they also want to participate in consensus right so they are participating at a lower level right they are effectively locking up capital on the on the dominant fork right and when they send out this transaction to lock stx they're broadcasting useful uh network information right so these people become like active participants in consensus we're basically saying here is the state of the blockchain that i see and i want to lock my capital on the on what i think is the correct fork of the network right and they and they give out the bitcoin address as
part of that it's very interesting because the mechanism itself is written as a clarity contract so people can actually see it it's a call to a clarity contract where you are locking stx and then every cycle is a cycle is roughly two weeks is 2000 bucks so the minimum time to lock is 2000 blocks and now the bitcoin uh so based on kind of like the last almost like the registration period we get a set of addresses and the miners are now sending transactions to those addresses right and interestingly the load on bitcoin is in the order of the number of miners right so if there are let's say
20 miners who are competing bitcoin is going to see 20 transactions per block right independent of if stax is doing a thousand transactions or 5000 transactions the the load on bitcoin is in the order of the miners right which which is a very very interesting property to have and in some ways the the hash power of the stax chain is represented in bitcoin and these tax holders are getting that bitcoin right so we were actually seeing when people started getting bitcoin directly from miners like people were like this is a magical experience right like there there are some tweets out there where people are have have posted videos of
small bitcoin transactions just showing up or you know there were there were some people who were like i woke up to like 10 emails from my coinbase account that you have received bitcoin you received bitcoin and it's it's a it's a very interesting experience because because all you're doing is giving a bitcoin address it's compatible with every bitcoin wallet and exchange in the world already uh and and that's how you're kind of like earning bitcoin from from consensus i just want to understand so the stax holders how so what they're basically putting locking coins and saying that hey i think that this fork is the valid one that part doesn't happen on the bitcoin chain that's happening on
the stack exchange so but in that case if there's a a fork of the stocks chain wouldn't the same people be able to say well i don't know which one i mean this comes back to like the traditional proof of stake like nothing at stake problem where it's like well i might as well just lock on both sides of the fork meanwhile if there's a way to lock on bitcoin then that would be yes so this this is um this is not a critical part of our consensus right the miners are only responsible for consensus what this is think of that as a additional information where that helps is it actually helps honest minors right people who are honest minors they can actually tell
where the majority of the users of the blockchain are right but it it from a from a pure consensus point of view like it it actually you know does not impact consensus in that sense other than giving additional useful information to the honest minors i would also like to backtrack here a little bit so you said if there's 20 minus there'll be 20 transactions on the bitcoin chain so how many concurrent miners do you expect there to be because basically on on bitcoin and ethereum and other large chain there's much many more than 20 concurrent miners right yeah so we've actually seen um you know quite quite a large number of miners as
well like on the test net we got like 800 miners and and so on on the on the production network we've seen 80 plus miners i think 46 have successfully mined or something like that but interestingly just just like how mining typically works even bitcoin our expectation is that a handful of really sophisticated miners will control you know some percent of of of mining rewards and then there might be mining pools as well right and then there a long tail of small miners so i think in in that sense like if you look at that distribution for bitcoin let's say you ignore the ignore the the very very small folks you just look at who the big miners are or who the big pools are
like it you you basically get a handful of of miners in a in a in a steady state right and which is which is something that that might happen on saxophone this is effectively model model after after bitcoin and the block rate is larger for stacks than for bitcoin right so basically you have you have many more blocks each bitcoin blocks corresponds to many stacks blocks so um how do i bid do i bid on a specific block or do i bid on the right to mine the next 15 minutes worth of block so how does this work yeah so we have this concept of micro blocks
so to keep things simple stacks blocks have a one-to-one correspondence with bitcoin right but we have further divided the stacks block into micro blocks and in you can so micro blocks interestingly also get confirmations these confirmations have nothing much to do with with bitcoin basically think of that as you're a user you broadcast a transaction on stacks it will very quickly get picked up by a stacks miner and get included in a micro block right and then you know and and microblocks are a little bit different only the winner of the last stacks block can produce microblocks and
so a micro block is like you know the last winner is just going like boom boom boom and they keep producing blocks let's say six seven eight depending on you know how long bitcoin is taking to produce a block let's say a micro block is every call it 30 seconds but once i'm in the micro block am i in or is it kind of like a snapshot of the mempool yes so so that that interestingly is a how you can we can display that information to the user as basically other miners can include the micro blog in their bitcoin commits as well so what what's what's happening on bitcoin is that people are very quickly doing replace by fee the miners are
doing replace by fee to always have the updated information and the updated micro block in there but you can actually just look at the bitcoin mempool and know that the probability of of your transaction getting confirmed is actually close to 100 because all of the of these tax miners have you in their micro block and then there are incentives there where a percent of the rewards are based on including micro blocks in your transaction like for the for the other miners for the miners who don't even win the the main block they are incentivized to include as many microblogs in there as as possible
right so we it's a little bit of a game theory there but it's it's pretty interesting like i would say like in 99 of the cases like as soon as you get a single confirmation on a microblock like your transaction is getting in because every single miner is incentivized to include it on the whoever wins the bitcoin block like they would have you in in in their micro blocks let's say uh okay so let's say half the miners end up not seeing one of the micro blocks on time and so half the miners with their bids they included up to microblock number 100 while half of them included microblock 101 which one now so now a new leader is selected
uh they continue to build off of the one that they saw off of the bid that was in their thing or do they have to like take you know whatever the majority of the miners picked or how does that work so this is this is where we separate kind of like confirmations from finality finality is only driven by bitcoin so whoever was the miner who wrote the bitcoin block basically you will you will see one finality effectively right and then bitcoin confirmations are kind of like finality numbers once they reach high enough like there are guarantees that nothing nothing can roll back on on stacks so if you if you have someone determined who is allowed to mine your next block
how do you deal with them the threat of them censoring transactions so interestingly we when thinking about censoring transactions we have this really cool feature where people can actually send stax transactions on the bitcoin network as well so uh transfer transactions and uh locking up uh we call it stacking so if you want to lock up your uh your sacs to participate they're supported in bitcoin and more uh forms can be supported as well so if you're afraid that hey someone is not going to let me transfer my stacks are not going to let me participate in stacking you can actually just broadcast transactions on the
bitcoin chain and they will get picked up in consensus and i think that's actually pretty beautiful because it's bitcoin as a backup communication channel if you are afraid of censorship what about from the other direction uh bitcoin miners basically censoring all stacks bids so that way like as a bitcoin miner i can guarantee that i win this stacks bid as well yes we we did a bunch of work there like i think there's a very interesting um game theory so think of it this way that first of all the transactions are bitcoin transfer transactions right so it's it's it's unlikely that uh these types of transactions would get banned on bitcoin all together right
because we're just doing transfers on on the bitcoin chain and then uh if a miner let's say wants to play around with the stacks chain and say hey i'm gonna i'm gonna censor other people and just have my own bid in there i think a that's where the rolling window comes in that miner would actually have to try and control things for several blocks right to have a real shot at winning the block and secondly it then it starts getting into collusion with other miners right because if other bitcoin miners are not not doing the same thing what would happen is that uh you will see one block in which a miner was actually not
letting in other stacks miners but because of the the window that even that block doesn't really impact how the uh the vrf works that miner would have to control a long number of consecutive blocks which is a very hard thing to do on on on bitcoin right and interestingly uh another version of of this is that what if you know bitcoin miners think that this is very profitable why don't we mine the the uh stack chain right and not let anyone else mine so the worst case scenario here absolute worst case scenario if you work out kind of like the game theory is uh every bitcoin miner is also a sax miner
you turn into a merge mine chain essentially it it turns into uh a condition where a 100 of the bitcoin miners are the sax miners and they're not letting anyone else mine but which is fine because big if you consider bitcoin mining to be decentralized it's basically like a additional requirement to mine the stack chain at that point that to to mine the stacks chain you also need to be a miner and bitcoin right but that is the worst case scenario which which i'm i'm very very comfortable with but that is like basically a similar security as like merge mining right it would essentially turns into merge mining in some sense yeah so how does the stacks chain deal with re-orgs on the bitcoin
level so i think in in general bitcoin dictates the the finality right so if bitcoin forks stacks works with it and whatever fork wins on bitcoin is the source of truth for stacks then that's how it's designed right like it's basically it's designed to use bitcoin as a settlement layer and as a source of truth cool yeah i think that's a very clear-cut answer and uh i appreciate that so the stacks blockchain can do more things natively than the bitcoin blockchain so it i mean you have a smart contracting script can we talk about that for a
while the language is called clarity um so what uh it's list based as far as as far as i know and so what are the benefits of clarity over something like solidity yeah so i think this goes back to again uh fundamental design decisions like just like there's a fundamental design decision that do you want to build on bitcoin and use bitcoins for work or do you want to build this separate network right like once you make that decision it's a type 1 type decision same with the design of the language right if you decide that you want to have a turing complete language like like like civility you know it's it's very hard to roll
that back when you're going to live with it for for a very very long time and we have always been in the camp just like we've been in the camp that the broader thesis here is bitcoin has network effects any experiments that we are seeing in other blockchains will eventually get created on top of bitcoin right so just like the early internet there were a bunch of separate networks but in the end you know tcpip and the internet ended up taking all the all the traffic we think bitcoin is like tcp and all these other things will end up getting built on top right like maybe not in that extreme of a forum that you know everything else disappears and there's only bitcoin and things on
top of bitcoin but i'm talking about the bulk of the market right okay that's our thesis so on the on the smart contract language side we are in the camp that the only thing that matters for small smart contracts in the long run right in in the long run is the security properties of the language because the unique thing here is that the smart contracts run on a blockchain you know they cannot be modified once they're deployed and you get people are keeping hundreds of millions or billions of dollars of crypto assets on these computer programs right so being able to reason about the security models and give formal verifications uh for for the the smart contracts and
basically just just optimize for security don't optimize for anything else other than security like that that that is really the thesis so uh yes it's a lisp based language but that's more of a syntax thing the design principle is we don't want a turing complete language but we want to have a language that's general enough that most of the programs can can be written right that's where we started then we took pretty contrarian decisions like for example we don't even have a compiler we don't want to have a compiler we explicitly wanted to avoid having a compiler because even a compiler can actually introduce unwanted bugs into your code
right like what because what you're publishing in in blockchain is like code is law but what people are publishing is actually compiled code so they don't even know if the thing that they think is law is doing the the thing that they they want it to do right yeah very few people can read by code yeah and so we we actually publish uh source code which is which is interpreted instead of compile you can you can even compile it locally for performance reasons or whatever but it's it's interpreted which means that in the blockchain like if you go to our explorer you can actually see and read the code and the comments in there as well which i think is a much better ux experience as well other than other than the benefits of knowing exactly what it is
but then the the interesting part and most of the work behind clarity was to ensuring that we don't introduce turing completeness by mistake right because because you can do that in in a design of a language so you have to be very precise about everything like how are you even mapping out you know uh some some storage internally uh and and and effectively what that translates into is just like in ethereum or solidity there is a gas estimate it's an estimate because you don't know what the program is going to do right and and what what is exactly going to execute and when it executes then you know what the fee was in clarity
there's no estimate there's a precise fee because you know even before executing the program exactly precisely what the program is going to do right and that i think that is the night and day difference in the two designs where uh in the industry right now what's happening is people realize that hey smart contracts are important let's just get a lot of manual audits on the code or they would try to have some sort of a formal verification by writing additional code additional syntax and then doing partial uh verification on that code base what we are saying is yes obviously you know manual audits are great but you get formal verification out of the box just based on how the programming language is
designed and i think that's a that's a major major win for developers who care about the security of the office smart contracts so this this is like some middle ground though between like the language is not can be non during complete but you're saying that there's like no need for gas estimates but don't you have can't you still have cases where there's like race conditions and stuff that like you know basically you know you make a transaction expecting it to do one thing but maybe someone else did a transaction that changes how your transaction acts do you not have that kind of situation happening on here or do you avoid that as well using like i don't know utxos or something like that no it's a it's a account based
system but i think we'll we'll have to dig deeper into like what what what that example is but think think of this way that it's about execution paths right so you can calculate like the exact execution paths for what the program can potentially take right so you know let's say let's say that you are attaching the precise fee for the longest possible execution path okay you can still have different potential execution thoughts but at least we can bound the potential paths but given given the given a state given an input state you know precisely what will happen with the with the program right yeah the problem is we don't always know what the input
state is because other people can make transactions before you i mean that's exactly the same problem as on the theorem right i mean because it's a stateful chain you don't always know what the state is that your your transaction is going to act upon right but i think i think over there uh the the turing completeness actually adds a lot of ambiguity right because it in theory like you were it's a tiering complete language so it's very hard to actually do formal formal verification on impossible to upper bound the gas costs while here at least you can by you know you can take
all the different code paths and you can at least say here is the like upper bound by like this like you know provably this is the upper bound which is i guess not possible in a true and complete language right can i go back one step seeing that clarity is not a during complete language what are the sort of computations that clarity cannot do when compared to something like solidity yeah i can give a very simple example right for example it doesn't have loops but interestingly you can write most programs without loops like you can just write the same type of logic without without using loops and then we get a lot of questions around hey can you actually call other contracts and the answer is yes
you can call other contracts but there's no re-entrancy right re-intensity does not exist so it's a little bit like you can even like if you really want quote-unquote loops you can actually write a separate contract and then just like call it a bunch of times right so it's a like the developers need to like get into the mindset of like how to write this code but once you pick that up like uh we actually ran an experiment right like for uh four months before launching stacks 2.0 uh we are doing a bunch of hackathons with the goal of like let's try to get developers to build like some of the more popular smart contracts on ethereum
mostly from the lens of like do we need to change clarity in some way or add certain features and so on and interestingly the developers were actually pretty easily able to build literally every every major uh solidity contract right and yes it was informative like we wanted to add certain changes and in fact we we ended up doing something pretty interesting uh because a change to clarity language is actually a hard fork to the stacks blockchain so we don't expect clarity to change that much but we were able to figure out this this very interesting way where you could implement a clarity feature or enhancement in clarity itself
which is not a hard fork it's just that that function will be slow and if that that thing is getting usage then in a future hard fork you could have a native implementation right so one of the learnings from this this hackathon process was that okay maybe maybe there's something that clarity doesn't have right now and people feel the need for it or maybe they can just write it in clarity itself and down the road you can optimize it by making it faster do you foresee that like clarity will become like the language that people write in or do you think that there's going to be higher languages that then compile down to clarity because i notice in your github you have a language called clarityscript which is actually like a
like a javascript yep javascript-esque language that compiles to it i looked at clarity and it seems to be like lisp language which is like you know has all these nice properties but at the same time it's like definitely much harder for like beginner developers to approach and so what's the strategy there my preference would be that people people just learn it right because it hits it it takes a little bit little bit of time but i can see why um there can be a learning curve as well like the way i'm thinking about this is to write smart contracts you have to go through a learning curve like you have to understand what the smart contracts are right i know that there are approaches in industry where they're just trying to use like rust as a programming language or even
even c as a smart contract programming language i just i just disagree i think people actually in the process of learning why clarity is different like they would actually learn the reasons for how smart contracts are different from normal programs but realistically like so clarity script is not the only only one i think there were some people in the rv community who are actually trying to write similar like javascript to clarity uh trans trans compilers and so on so i think that's already happening right people people have their preference for what language they want to use and there might be like these these in this compilation step right like you go from that language to clarity but i think in terms of what i would like to see is i would like
to see more education material of when someone is just learning how to program like telling them that why doing things this way is different from from from doing things in the other solidity type world now going back a little bit to architecture of the chain itself one of the main sort of taglines that's used here is it's like that it's built on bitcoin stacks is built on bitcoin and so after going through this whole discussion about the consensus protocol i i definitely see in what why this is sort of inherits its consensus security from bitcoin in more in a way that like something like a a separate network like ethereum does not
but from an application perspective does a stack smart contract have any different relationship to bitcoin the asset than an ethereum smart contract might because you know with ethereum we have we have like wrapped bitcoin or like tbtc on ethereum and we've had btc relay for you know number of years at this point and so from that application level perspective how is this more bitcoin native than something like bitcoin on ethereum so that that's that's the second biggest thing of clarity right that that i was going to get into and that is that clarity has uh full visibility into bitcoin state
right so clarity has native bitcoin sbb proofs and it has just like i mentioned earlier that we can use bitcoin as a backup channel to even do transactions like stax transactions that show up in consensus on the sax chain through bitcoin similarly whatever is happening a bitcoin is available to programmers in clarity right so let me let me walk you through a very simple program where you know let's say i want to do uh donations to coin center and i say that you know uh here's like 20 000 stacks i like up to 20 000 stacks i want to donate to
coin center and uh based on how many bitcoin donations go to this bitcoin address i will match an additional amount and i can write that as a clarity smart contract people are sending transactions to bitcoin address for for coin center right they don't even need to know about clarity or stacks this tax contract automatically knows the state of that bitcoin address and if it triggers like hey now you know x amount of bitcoin has been donated it can send a transaction on on stacks for the additional donation to coin center right so
you could you're writing logic that is triggered by changes on bitcoin that's i think super interesting and then you can you can look at the reverse of that as well right so this functionality that i described like it's it's live today right like you you have full visibility into bitcoin you have bitcoin sbb proofs natively available in clarity but the reverse path is actually even more powerful where a clarity contract can trigger a change in the bitcoin state right that work is more in the r d stages and we are looking at various bitcoin uh scripts where you know let's say an ideal example would be you lock up your bitcoin and name some
part of a time lock and there's logic that executes on the clarity side that when that program clarity program basically finishes executing it can actually trigger where the unlocked bitcoin on the bitcoin chain is going to go once you have that now you have right capability to bitcoin as well that is super powerful and so what are some of the like techniques being used uh you know even in the r d stage to like do that yeah i think i think that that's super early we were uh we were focused on the link building out this tax required to uh mean that at this point but you know we will look at you know hashtag logs we look at taproot we look
at you know all there are a bunch of like interesting other new newer projects as well i know i know uh jeremy rubin has been working on like some some sort of a more advanced scripting language on the bitcoin side so we are exploring all of that basically see what can be done to in a way kind of like connect clarity with um with state changes on on bitcoin and and and then going to the example of kind of like you know ethereum and draft assets there it's a little bit like if you are moving a wrapped asset on a disconnected chain like it has nothing to do with bitcoin at that point right any asset that you're creating on stacks is effectively secured by bitcoin like let
let's take the example of a nft there's an app called boom people are creating nfts there those nfts are actually literally secured by bitcoin like you can see that here is the stax transaction here's how it got packaged up and here's here the hashes on on the bitcoin chain for it so so i think in my view a nft issued on on bitcoin is more valuable because it's more durable and similarly other types of digital assets issued on the stack chain they're they're they're directly getting uh secured by bitcoin as well but so that means though at the moment there's no way of transferring bitcoin onto the stocks chain because it
i think one of the main like things that people are want right now is the ability to use bitcoin in d5 use it as collateral in different d5 things and so right now stacks doesn't enable that yet until the work on like having the other direction is completed right yes so i think what's happening there is there's a spectrum of solutions right one is the custodial approach like just like you have wrapped bitcoin on ethereum uh tokensoft and anchorage have announced that they plan to have a wrapped bitcoin asset on stacks and again the only like real benefit you're getting is that asset itself is secured by
bitcoin right so if you don't trust the consensus or security of other chains at least you have the peace of mind that this this thing has been being secured by bitcoin the next level from that is uh keep network type approaches right where there's there's some sort of a more decentralized way of moving an asset into the chain but the the extreme end of the spectrum is the ideal world where the user experience says you just lock up bitcoin on bitcoin and use it on stacks and then when you're done using it on stacks they just unlock on bitcoin right like that's the that that is the dream world right like where that's the thing that everyone wants where it's like a more seamless kind of
like i just locked bitcoin on bitcoin used it in the in the section took them back or they they go to somebody else if you know the ownership of bitcoin has actually changed hands on during during the time it was in this action so the other offering that builds a similar offering on top of bitcoin is uh rootstech right um so how does that compare to stacks yeah i think first of all i'd love to see uh innovation around bitcoin other people who are trying to do different things on bitcoin that's always great great to see the two big differences are the consensus mechanism over there is merge mining
right and i i mentioned our experience with merge mining on namecoin where because the merge mine chain is unless you somehow get 100 of the bitcoin miners to also mine the the march chain the merge mining chain is always like a subset of the main chain and then another kind of like thing that happens is let's say you have a large bitcoin miner that has 35 or something of bitcoin if that miner starts mining on the merge mine chain that miner might actually have sixty percent of of the merge change like we we went through those problems i i found some issues on namecoin where there was literally a single miner like having 75 of the hash power
and when i when i disclose those issues like somehow you know the community members were like we yeah we have known about this for a while and that's fine and like how is this fine right like this this is at this point a single miner is effectively running the network right so i think i think there are challenges and then there's practical challenges where of of the merge mind chain like it's about incentives like what is the incentive for a very large fraction of the bitcoin miners to continuously mine this chain especially when i think the way my understanding is rsk also doesn't have coinbase rewards right so they're really saying that the transaction volume on our chain is going to be so high that every single bitcoin miner
will want to mine our chain right that would be a great world if we can reach that but i think getting there has some sort of you know initial hurdles on incentive problems uh and secondly i think the big difference is that they uh they basically have solidity and evm right and i would not recommend you know young entrepreneurs and engineers who are basically trying to learn program smart contracts to go down that route ideally you know and many other projects are doing that we're not the only ones right if you look at tezos if you look at algorand algorand actually also collaborated with us on clarity like they're in the same camp that these need to be non-tiering complete much more focused on security type of
languages not not based i think i think what what happened is because ethereum was early and it got the initial kind of like adopt adoption now there is a little bit like hey let's just be compatible with evm because you know that's like an easier cell to developers but if someone made the bad decision like in the early stages of the industry doesn't mean that the industry needs to live with that decision for for forever like i'm i'm talking 10 years down the road like i think it will be a uh at least in my mind it'll be a pretty pretty sad outcome if people are still fighting kind of like reentrancy and all these types of like problems uh in smart contracts instead of just using more more secure languages there
are so many options available clarity is not the only one right zelika has has an interesting approach tesla's has an interesting approach algorand as i said they have a lower level language and now they're working with clarity as a higher level language as well cool so let's talk about some of the apps that run on top of um stacks 2.0 can you give us an idea of how many there are and kind of what the popular ones are yeah so i think uh first of all there's a divide between stacks 1.0 and 2.0 uh 1.0 did not have smart contracts so 1.0 is the chain that was directly on top of bitcoin and over there effectively the use of
the blockchain was effectively to register usernames uh domain names and pointers to storage right and then then we had a decentralized authentication system we had we had the rest of the stack so that people can build uh things like you know decentralized blogging uh decentralized photo sharing like even messaging applications and so on and we saw a bunch of them a lot of the the that traction goes back to our app mining program which is which is a very interesting experiment like we learned a lot from it it effectively was a more automated way to incentivize developer behavior that let's say that there are certain metrics based on which you are handing out rewards to developers right to kickstart
kind of like the app ecosystem so that people are building more applications interestingly what we saw was initially it was working really well right like developers would basically come and build these applications like we can even score them on decentralization right like hey how decentralize is your app or you can just put in like or you can score them on the ux of the app we had these this process of like multiple reviewers so let's say there are five independent reviewers who are giving a score on the ux there is a score for how decentralized the app is there's a score for you know how much users and app is getting and so on and and very quickly we started seeing that there was almost like some sort of unintended behavior
where developers were more interested in just gaming the scores for the rewards versus building you know uh really high quality decentralized applications for the love of it right and and looking back it might actually seems more obvious that of course they were just it's like it's like an exam right are you are you taking the class to actually learn or are you doing it just to pass the test right and there are so many students who are just focused on like i just want to clear the exam and get a get a good grade i don't care about the learning part for those reasons we ended up pausing the app mining program and it got us like more than 400 applications built on top of the network some of them were really high quality really good apps but then there was a long tail of people
who were effectively you know some people would build like 10 applications like they can have 10 entries in in app mining and kind of like get more rewards and whatnot but they're not really passionate about any single one or one of those applications so that the app finding program has been paused for almost a year now more than a year and we have definitely noticed a difference that there is more organic community like during the time app mining was running like we we got a lot more attention there were a lot more people but they were basically there for the money right like like a good good quantity of them but now the community feels much more organic the developers are there because they believe in decentralization they believe in privacy they believe in
in in building on bitcoin right like building on bitcoin is a very core kind like cultural dna of of the community that we are building and i'm super excited about it so in terms of apps you can just go to app.co that has a list of some of the top applications from stacks 1.0 that are also migrating to stacks 2.0 they need to up upgrade certain things in the app to migrate to 2.0 pravaca is a great example pravaca is a um almost like a decentralized zoom plus a decentralized whatsapp so you can do messaging and video video calls and it's amazing right like it's it's like you look at what's happening in the world and these are the kind of solutions you're
looking for where there's no company in the middle there's a completely encrypted video chat session and you look up the keys for people using their usernames that are registered on the stacks chain but then secured by bitcoin so with your private key you can actually just see in which transaction your name was registered how was it packaged on bitcoin and and you know that you know no one is going to change the the bitcoin chain and then in the newer applications because clarity just went live we are actually seeing there is a project called uh swapper which is like an automated market maker like like uni swap written in clarity which would be super interesting to see there are there's a project
called dual x it's like they have you can take a option to buy an asset and trade that right like so people are trying to now innovate more on the defy side of things and i think the key differentiator and going back to like what you mentioned earlier that the blockchain has only been live 2.0 has only been live for like two weeks now when we can have like more native bitcoin movement from the bitcoin chain into the stack chain and back and so on and i think it might happen over phases like sure you'll have a custodial approach you might have a semi decentralized and then a fully decentralized approach and so on but that means you can inject bitcoin capital
directly into d5 written in clarity which is a secure programming language and all of this is happening directly on top of bitcoin in the sense that you know all the state for these contracts is eventually getting settled back into bitcoin and i think that is a world that that i'm super excited about if you look at the bitcoin community there's a lot of resistance to any sort of token that's not bitcoin right and a lot of the apps that um run on top of stacks 2.0 um have native tokenomics um so how do you see that playing out do you think tokens i mean basically in bitcoin in many bitcoin circles
they are decried as you know this money grabbing um scam so how do you kind of see these two come together or do you see these two come together yeah so i think let me let me tease that apart a little bit and actually even before getting into that like there's one important kind of like thing that we have completely missed from the discussions right now and that is the ability to earn bitcoin rewards from consensus so these tax holders when that when mining is happening every bitcoin block literally bitcoin is being transferred to this tax folder and it's a it's a magical experience right like there were people tweeting about it they're showing their screenshots of basically getting bitcoin
in their wallet they can give any wallet address it could be an exchange or coinbase or however desktop wallet cold storage and it is and there's an economic tie between stacks and bitcoin like in the sense that if there are more smart contracts that are gaining traction on stacks the bitcoin yield is going up for these tax holders right so it's a little bit like imagine let's say we've seen in the crypto industry this tribalism especially like you know between bitcoin and ethereum as well where some sometimes you'll see the base like hey ethereum is going to be more valuable than bitcoin bitcoin can just be recreated on top of ethereum and so
on and the other way around but bitcoin has actually never had the capabilities that ethereum has it's mostly a passive asset like gold that people are kind of like just buying and it's just sitting there we are not only bringing the smart contract and app functionality to bitcoin we're doing it in a way that is that doesn't compete with bitcoin it can grow in harmony with bitcoin like we stacks is never going to say that stacks is going to replace bitcoin it's not even possible from a protocol perspective because you need the underlying reserve currency and the reserve asset to actually settle to it to actually benefit from it and then stacks has bitcoin rewards right which are tied to
smart contracts like in the sense if smart contracts are taking off these bitcoin awards are going up and people are kind of like you know more interested in the long term success of both bitcoin and and stacks right so let's let's have that framework in mind and then dig deeper into the bitcoin community who have they have resistance to new types of assets like there are people without naming them who have flat out told me that they love every single thing about this project minus the stacks cryptocurrency they love everything right it's open source it's decent lies it's bringing you know apps and smart contracts and all this innovation and all of that and you know we
they praise even the work we've done on regulations and this and that but they they have some sort of a mental barrier to a separate asset and then i and i then then i basically walk them through the journey and like why don't you fork our our project and run it without without the asset and basically see what happens so what would happen is that all this state for smart contracts that is being secured outside of bitcoin no one would have any incentive to store that state so then you're talking about can we shove this state back into bitcoin which is not going to happen right it's a scalability problem for bitcoin and then also i think incentives matter a lot like we just launched and and their miners were competing over mining blocks like we're not in a
situation where we are begging people that hey can you please come and you know run nodes on this chain just out of the goodness of your heart they're doing it because they're financially motivated to do it and it's the same thing with bitcoin how do you think bitcoin took off like it has incentives it it pays the operators of the network to operate the bitcoin network and similarly you need to pay the operators off of of the stacks network to operate these smart contracts and i think uh the the other interesting angle with bitcoiners is you would ask them that do you think bitcoin is a settlement layer and they will be like yes bitcoin is a settlement layer and bitcoin should settle everything in the world i'm like okay
great you know stack settles on bitcoin and if there is a token that is issued on big on stacks that that token also settles on bitcoin so i think there's a little bit of a that uh like a inner conflict where you cannot at the same time believe that everything in the world should be priced in bitcoin everything should should use bitcoin as a settlement layer and at the same time deny the existence of those assets that should be priced in bitcoin and should settle on bitcoin right so once you once you start walking through this like you you you see the conflict and and a lot of and also like i i shouldn't say that this is the same reaction from all of the bitcoin community like i
think even the bitcoin community is a spectrum there's some people who are extremely bullish and extremely helpful and extremely excited about what we're doing then they're they're people who are like hey they kind of accept it they're like you know i don't like the token but i overall you got what you guys are doing is like really beneficial and i kind of like it and then there's the the extreme form where they're like the token i just hate it enough that i'm going to hit the entire project because you have a token right so i think it's a it's a spectrum but over time i think especially with more education especially when people realize like imagine how many people are going to discover bitcoin because they're going to earn their first bitcoin through through stats or how or how this is actually making uh
nick carter uh i was on a podcast with them he made a really really important argument that stacks miners are willing to pay really high bitcoin transaction fees because the value of a stacks block to them is a way higher than a normal bitcoin transaction right which is actually a very sustainable model for bitcoin especially if all of these bitcoiners they would love to see bitcoin at fifty thousand hundred thousand a million right what do they think is going to happen with bitcoin fees when that happens right bitcoin fees are going to skyrocket and to sustain the fee market the only sustainable path is that you're actually packing so much valuable information in a bitcoin transaction
that it is okay for someone to pay a hundred dollar thousand dollar transaction fee our miners will gladly pay a thousand dollar transaction fee to just get there just get their transaction in they they actually do very aggressive replace by fee like you know they're always bumping up their their fee and updating their transaction because they really really want to get into a a bitcoin block and i think long term like that is the kind of use that can actually justify a very high price of bitcoin as well because you're packing so much information i think this is a this is a perfect note to end on i think this kind of sums up your entire offering really nicely so can you tell our listeners where should they go
to find you and to find information on your project yes so i think i'm i'm i'm fairly active on twitter uh and uh it's just my first name at mooneeb m-u-n-e-e-b and then uh the project is on stacks dot co and and there are actually like multiple entities in the project that you can then discover i run a developer focused company called hero there's a non-profit called stacks foundation there is a community focused entry freehold there are mining companies like damon and clients like secret key labs or new internet labs and so on so the project has really grown over over the years there are uh it's it's very
decentralized it's very much in the in the cap of bitcoin like it shares a lot of the dna with bitcoin and it's effectively trying to bring more more innovation to bitcoin perfect thank you so much for coming on monop awesome thanks thanks for having me thank you for joining us on this week's episode we release new episodes every week you can find and subscribe to the show on itunes spotify youtube soundcloud or wherever you listen to podcasts and if you have a google home or alexa device you can tell it to listen to the latest episode of the episode podcast go to epicenter.tv subscribe for a full list of places where you can watch and listen and while you're there be sure to sign up for the newsletter so you get new
episodes in your inbox as they're released if you want to interact with us guests or other podcast listeners you can follow us on twitter and please leave us a review on itunes it helps people find the show and we're always happy to read them so thanks so much and we look forward to being back next week you