Cryptocurrency scripting/contract development differences

4년 전

Many cryptocurrencies have emerged with different ideas on how to make cryptography-based currencies more "smart". This blog post takes a look at several and the differences between them, from a developer perspective.


Each transaction has a script which contains a stack-based program written using custom opcodes. Most transactions (currently) are "Pay to public key hash" (P2PKH), meaning the script is "anyone who can sign a message with a private key that relates to public key X is allowed to spend this". Each transaction picks individual outputs from previous transactions, supplies input values into their scripts that evaluate properly, and creates new scripts for each output setting the conditions they can be spent in.


A special transaction can be sent from an account to create a smart contract, which gets it own public address — distinct from the address that created it. The smart contracts are programmed by the creator, and once created, are immutable (the program itself cannot change), but can provide function hooks to be called by future transactions (repeatedly, if desired), and can have mutable state variables. The functionality of the smart contracts are executed in the Ethereum Virtual Machine (EVM; defined in the Ethereum yellow paper). The EVM is a stack machine with its own custom opcodes. Smart contract definitions need to be compiled down to EVM bytecode, but there are several programming languages (notably Solidity, though Serpent, Viper and others exist too) that are higher-level (more human-friendly to read and write) and compile down to EVM bytecode.


EOS applications are deployed to the blockchain with a special transaction, which gets its own public address — distinct from the address that created it. The applications are programmed by their creator, and once created must maintain the same external interface, but the internal logic can be updated by the original creator (for bug fixes, etc.). The functionality of applications are defined by Web Assembly code (aka WASM). This is not a custom language, but rather one that's shared with next-generation browsers alongside Javascript for client-side functionality. Web Assembly as a programming language is designed to provide external hooks/interfaces for other code to call (in a browser setting, DOM events are captured by Javascript handlers, which in turn can call WASM functions). In an EOS setting, the same hook/interface functionality is used to allow EOS applications to respond to events in transactions. Web Assembly can be compiled to from C or C++ code (using LLVM and clang). The EOS development team has created C++ API classes, which provide easy access to common EOS application tasks.


The Stellar network allows for the creation of assets and the distribution/management of them. Assets in Stellar provide for the most common use case of applications/smart contracts in other blockchains (to create a new coin/token/currency), but no additional customizable features. All assets in Stellar are issued by a specific account, which is created like a normal user account, but then only used as the issuing agent for a specific asset. Users need to trust the issuing account before they can receive assets from them. Assets are identified by a short name combined with the issuing account (so name conflicts don't matter; "CAT" tokens issued by account A are different from "CAT" tokens issued by account B). All assets have seven decimal places of precision, and stored as a 64-bit integer.


The NEM blockchain has the capability to create Smart Assets. (a.k.a. Mosaics). The Nanowallet software provides GUI interfaces for developing Mosaics. Mosaics are compared to "colored coins" and so have features that are relevant to custom currencies. There are several properties that can be enabled/disabled on a given Mosaic to determine things like if it can be transferred between users, has fractional units (up to 6), etc. Mosaics have a name, but also have to be stored under a namespace, which differentiates them from other Mosaics with the same name.


The Cardano blockchain is at its core level a financial blockchain, and is currently working on adding a Computation Layer on top of it, which will enable smart contract execution. The smart contracts will run on the IELE Virtual Machine , which is a register-based machine. Smart contracts to be deployed on this blockchain will need to be written in IELE (a variant of LLVM).


Blockstack is a system built on top of existing blockchains, storing additional data on them that serves as metadata for the Blockstack layer. Blockstack users all run their own node on their own device, which allows them to configure where they want their data to be stored, and applications written for Blockstack are written to expect a running Blockstack node to be on the same device, and communicates with it directly. Currently Blockstack is layered on top of the Bitcoin blockchain, and applications written for Blockstack can use the user's Bitcoin assets to trigger payments . Applications written for Blockstack are web applications (so, HTML, CSS, and Javascript languages), and use the blockstack.js Javascript API to send commands to the user's Blockstack node. Blockstack provides data storage APIs for writing data to the user's data repository (not the blockchain), and is very flexible as to what data can get stored by the application.


Most all the blockchain technologies that allow "smart" interactions implement the functionality by a developer writing the logic/functionality once and deploying it to a designated place on the blockchain to be used over and over again. Bitcoin is the outlier in that model, in that if you want to repeat some functionality from a previous transaction, every transaction that wants to do that same action needs to include its own copy of the script used, since each output can only be spent/used once. This model allows for fixing any flaws in the script very easily (just start using it next time). EOS is the only other one that provides for mutability in the contract, though the developer needs to push a "fix" transaction to the blockchain to enact the change.

Most all these technologies define some sort of virtual processor with its own opcodes to program against, and allows for lots of creativity/possibilities in what gets designed using that. The exceptions to this are Stellar and NEM. Both of those focus more on defining additional currencies/tokens on the blockchain, and lock down "smart" functionality to only those functions that would be useful to a custom token. If all you want to make is a custom token, those may be a better choice simply because they're more focused on that. However, the applications moving around of those tokens doesn't have a trusted, verifiable way to do that provided by Stellar or NEM, and would have to figure out different ways to provide trust to their users. Using a blockchain like Ethereum, both the asset and the application manipulating them can be verified and trusted as they're both on-chain.

There are many, many more cryptocurrencies cropping up, but these are the highest market cap ones that seem to be getting the most traction. Other cryptocurrencies probably are very similar to one of these models; are there any others that you know of that I missed that are doing something unique?

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  trending

Do you have a pulse?? Do you want to be awesome and experience emotions even greater than pure bliss??? Come visit my amazing blog! Every word is made of win.