• Forum has been upgraded, all links, images, etc are as they were. Please see Official Announcements for more information

Smart Contracts for Dash

xjones

Member
Recently, Craig Wright spoke at a conference called “The Future of Bitcoin” in which he said that Bitcoin's scripting language is a 2-PDA, or two-stack pushdown automaton, which is Turing complete.

If you click on the below video you might not see what you expect. The forum software in use here forces embedding of videos even if YouTube does not permit the video to be embedded. It also deletes video timestamps. You may need to manually go to the URL:
Code:
https://youtu.be/YAcOnvOVquo?t=10117

If necessary go to the timestamp 2:48:37.


Normally, a simple pushdown automaton or PDA is less powerful than a Turing machine.

https://en.wikipedia.org/wiki/Pushdown_automaton

But giving it a second stack makes it into a 2-PDA, which is Turing complete.

I didn't find any single good source article on 2-PDAs, but a web search shows several references that say in passing that a 2-PDA is in fact as powerful as a Turing machine.

The two Bitcoin opcodes that implement a second stack are OP_TOALTSTACK and OP_FROMALTSTACK.

Since Dash is forked from Bitcoin, it too has these opcodes.

https://github.com/dashpay/dash/blob/master/src/script/script.cpp#L53

If all of the assertions above are correct, then:

The Turing machine built into Bitcoin and Dash should be able to implement smart contracts as well as Ethereum does. All we need to do is put a user interface around it.
 
Last edited:
Nice post :) We're going to need to define exactly what's meant by "smart contract" one of these days as it's meaning very different things to different people, a multisig transaction could be considered a smart contract, some are seeing it as machine readable legal documents, some seeing it as DAOs or distributed computing platforms... it can get confusing.

Imho that definition is vital because the answers when asking "does digital cash need smart contracts?" gets all sorts of answers depending on the point of view. Does digital cash need multisig? Hell yes!! (imho ofc). Does digital cash need to function as a distributed computing platform? Well... that's exactly how the masternodes will function but I'm not so sure if it's a good idea for the tokens.

Complex transactions take up a lot of storage and as we know storage can be a problem, personally I'd be more in favour of simplifying transactions to reduce storage needs but the main point (for digital cash) is performance, how fast transactions can be processed. Maybe smart contracts can be handled with little or no overhead but I've got my doubts and I don't see any way they can be included in the blockchain without causing bloat. The governance objects are along the same lines and cause no bloat, they can safely be dropped when no longer needed. Imho that's a better basis for distributed computing than including it in a blockchain but only time will tell.
 
I wonder if there could be smart contracts DAOs to sort these things out? I'm not wild about the smart contract logic being built into the core...too much surface...too much can go wrong. If smart contracts were layered in a DAO, could you get the best of both worlds? It's akin to the Linux kernel concept.

I'm thrilled with the decisions DASH core has been making along these lines. All of these questions we have will sort themselves out if DASH core is done properly. I can find no other coin I'm more aligned with.
 
Yeah, I'd definitely second that, something goes wrong and it's a component failure rather than an entire system broken and needing a re-start.

The ability for users to create their own DAOs based on that of Dash is suggested occasionally and I don't think I've ever heard any negative comments on the idea, not a huge amount of support but quite a bit considering how unfamiliar the concept is. It seems like smart contracts are up in the air at the mo with everyone waiting to see where they land, like the blockchain concept but more so and DAO platforms could well be one of the places they grow well, distributed organisations entirely governed by them. I'd guess if that ever comes to Dash it will be at least a few years away, the roadmap is well planned out and something like that kind of oversteps "digital cash" but zero-profit DAOs replacing for-profit corporations could be a huge change for the better.
 
Yes!

When I follow this logic further out, I start to think the promise of programmable money could not be fulfilled by Bitcoin and that Ethereum is intended precisely as the layer you're decribing. In fact, I believe Ethereum has even stated as much. Ethereum could become the turing complete language to compliment Bitcoin.

Nice concept but it's starting to look like a slow motion train wreck...instead, what if you could have all of it under one roof? Hmmm, who's driving that bus? Oh, I know! PIVX? </sarc>
 
Lol, just maybe they might but then we can use their code for a change ;) Got to love open source :) Maybe Etherium could be that platform but personally I've always had my doubts, always seemed like it was trying to do too much to soon and at best would have to make serious compromises, at worst... yep, train wreck but maybe it'll pull through.

Cross-chain standards are something I should keep a closer eye on though, there's a bit of a standards war going on at the mo but I'm betting it'll get a whole lot bigger before too long. Always thought that would be the next step, interoperability between chains but whether that will pan out as a blockchain solution, a common virtual machine, an entirely different platform... who knows? Well worth thinking about though and a common language is certainly one of the potential directions :)
 
I'm still learning about the use cases for smart contracts, which seem a little thin to me. But programmable money is pretty much the same idea, so they exist. So far, a decentralized casino might be the easiest one to explain and understand.
 
A smart contract doesn't have to do a lot of computation. Even relatively simple things can be useful.

Look at Ethereum's domain registration system which runs entirely via a smart contract. See: https://ens.domains/. The smart contract will let you register a domain name via an auction, or sell/transfer your domain to others for a desired fee, or map a domain to a desired Ethereum address, all in trustless transactions. Soon, all wallets supporting ether will recognize these domains and allow funds to be sent to human-readable addresses. These domains will be relatively un-censorable, because they will live on the Ethereum blockchain. Nobody can hack your domain via social engineering — they will need your private key.

Dash's new Evolution release is supposed to enable something like this. But in the case of Ethereum, no changes were needed in the Ethereum system itself.

As another example of a useful smart contract, consider the British singer Imogen Heap's experiment, which was intended to let people buy a song download using ether, with the incoming payment being automatically sent in predetermined proportions to the singer and to all the musicians who were involved in recording the song. So there would be no need for anybody to do any accounting — each person gets their share of the income in the right proportion in real time, and nobody cheats anybody. The experiment didn't go very far, because hardly anybody had heard of Ethereum at that time. It does however show you some of the potential of smart contracts. Web search for: Imogen Heap ethereum.

Ethereum is the first-ever implementation of blockchain smart contracts, The failure of the notorious The DAO showed how dangerous a poorly-done smart contract can be. I don't think Dash should blindly copy smart contracts from Ethereum. Rather, we should use Ethereum's idea to inspire us into something better and easier to debug and use. At the very least, the smart contract programming language ought to be much more easy to debug and prove correct than Ethereum's error-prone Solidity.

━━
Edit: Corrected spelling for Imogen Heap.
 
Last edited:
Last time I checked, many of the script OP codes found in the bitcoin/dash code were disabled for different reasons, mainly security as I'd assume. Only a handful of script types are supported at the moment, making the scripting possibilities quite limited. The only flexibility you have is in the P2SH type of scripts, which delegates transaction verification to another script which must be part of the spending transaction. But even with those scripts, you are quite limited to only make stuff like multi-sig and comparable work.
 
Isn't our proposal system basically a smart contract? You have to put up 5 Dash to have it go live in Dashcentral and then it moves over to governance system for approval. The Dash funding you ask for is locked in the signatures you used to create the proposal.
 
Last time I checked, many of the script OP codes found in the bitcoin/dash code were disabled ....

Are you saying that the OP_TOALTSTACK and OP_FROMALTSTACK opcodes are disabled in the Dash-specific code? They are definitely not disabled in the Bitcoin code.
 
Isn't our proposal system basically a smart contract? You have to put up 5 Dash to have it go live in Dashcentral and then it moves over to governance system for approval. The Dash funding you ask for is locked in the signatures you used to create the proposal.

If we use the phrase "smart contract" with the meaning that it has in the Ethereum world, then no, I don't think the proposal system is a smart contract. The code in an Ethereum-style smart contract (a) lives on the blockchain and (b) can be written by anybody without needing write access to the Ethereum repository.

If we redefine "smart contract" to mean something else, then it can be anything we want it to be. But in that case it would be better to pick a new name, to avoid confusion.
 
Are you saying that the OP_TOALTSTACK and OP_FROMALTSTACK opcodes are disabled in the Dash-specific code? They are definitely not disabled in the Bitcoin code.
OP_TOALTSTACK seems to be enabled. There are however other op codes being disabled. The bigger problem is however the list of accepted "standard scripts", which are only 5 as of http://davidederosa.com/basic-blockchain-programming/standard-scripts/. Only these 5 types of scripts are relayed on main net (at least in bitcoin, not sure about Dash). This limits the things you could possibly do a lot.

Of the 5 standard scripts, only the P2SH is flexible enough to do some actual coding. The only thing however that I figured out to produce with this was different kinds of multi-sig transactions.
 
If we use the phrase "smart contract" with the meaning that it has in the Ethereum world, then no, I don't think the proposal system is a smart contract. The code in an Ethereum-style smart contract (a) lives on the blockchain and (b) can be written by anybody without needing write access to the Ethereum repository.

If we redefine "smart contract" to mean something else, then it can be anything we want it to be. But in that case it would be better to pick a new name, to avoid confusion.

The term "smart contract" was in use way before Etherium, maybe it will end up defining it but it's meaning is probably too broad.

Isn't our proposal system basically a smart contract? You have to put up 5 Dash to have it go live in Dashcentral and then it moves over to governance system for approval. The Dash funding you ask for is locked in the signatures you used to create the proposal.

+1
 
Last time I checked, many of the script OP codes found in the bitcoin/dash code were disabled for different reasons, mainly security as I'd assume. Only a handful of script types are supported at the moment, making the scripting possibilities quite limited. The only flexibility you have is in the P2SH type of scripts, which delegates transaction verification to another script which must be part of the spending transaction. But even with those scripts, you are quite limited to only make stuff like multi-sig and comparable work.

I think you and Craig Wright are thinking along different lines.

Your thinking is that you are limited to whatever the current opcodes allow you to do, e.g., multi-sig and comparable computations, so a generalized smart contract cannot be implemented.

Craig Wright's thinking is that Bitcoin's existing opcodes, in conjunction with a second stack, implement a 2-PDA, which is equivalent to a Turing machine, so they can do any computation at all, not just multi-sig and comparable computations.

I think Craig Wright will eventually turn out to be correct. However, there are two remaining barriers in the way of smart contracts on the Bitcoin blockchain and quite likely also on the Dash blockchain.

1. Without proper I/O, no computation is useful. It's not clear if the Bitcoin opcodes support enough I/O to allow practical smart contracts to be implemented.

2. Whether the fees charged by the Bitcoin system can be made low enough to allow economical execution of useful smart contracts.
 
Recently, Craig Wright spoke at a conference called “The Future of Bitcoin” in which he said that Bitcoin's scripting language is a 2-PDA, or two-stack pushdown automaton, which is Turing complete.

If you click on the below video you might not see what you expect. The forum software in use here forces embedding of videos even if YouTube does not permit the video to be embedded. It also deletes video timestamps. You may need to manually go to the URL:
Code:
https://youtu.be/YAcOnvOVquo?t=10117

If necessary go to the timestamp 2:48:37.


Normally, a simple pushdown automaton or PDA is less powerful than a Turing machine.

https://en.wikipedia.org/wiki/Pushdown_automaton

But giving it a second stack makes it into a 2-PDA, which is Turing complete.

I didn't find any single good source article on 2-PDAs, but a web search shows several references that say in passing that a 2-PDA is in fact as powerful as a Turing machine.

The two Bitcoin opcodes that implement a second stack are OP_TOALTSTACK and OP_FROMALTSTACK.

Since Dash is forked from Bitcoin, it too has these opcodes.

https://github.com/dashpay/dash/blob/master/src/script/script.cpp#L53

If all of the assertions above are correct, then:

The Turing machine built into Bitcoin and Dash should be able to implement smart contracts as well as Ethereum does. All we need to do is put a user interface around it.

Why the video is so blocked on YouTube?
 
Back
Top