Inal Kardanov: The Hitchhiker’s Guide to Waves Smart Contracts. Part 1wavesplatform waves smart-contracts programming blockchain
On September 10 Waves Platform released a new version of node, which has the support of Smart Contracts in their first implementation. In this article, we’re going to focus on the idea of Waves Smart Accounts and what makes it different than other existing solutions. We will begin with a brief introduction with some definitions of smart contracts then we’re going to see the difference between Bitcoin script, Ethereum Smart Contract and Waves Smart Accounts. After that, we will provide some use-cases implementation using our solution and explain more about our RIDE language.
So let’s prepare a cup of coffee and begin our journey!
Blockchain word has been around for a while and every day we’re hearing this word more and more. Usually, in the second or third sentence about the blockchain we hear about smart contracts, so they’re tightly coupled.
The definition of a Smart Contract
Most of us already heard about smart contracts and the first thing that comes to our mind when we say a smart contract is Ethereum, it is a little unfair, because the first proof-of-concept of a smart contract is Bitcoin Script. Actually, there are many different blockchain platforms which implemented the idea of a smart contract and the definition of the smart contract was introduced 20 years ago by Nick Szabo.
We can define a smart contract as follows:
- A smart contract is a program that runs on the blockchain and has its correct execution driven by the consensus protocol. A contract can encode any set of rules represented in its programming language. Therefore, smart contracts can implement a wide range of applications, including financial instruments and autonomous governance applications.
- The idea of a smart contract as defined by Nick Szabo is to satisfy common contractual conditions, to minimize exceptions both malicious and accidental, and minimize the need for trusted intermediaries.
Now let’s understand the concept of Bitcoin script — the language which is used for creating scripts in Bitcoin Network. Basically, the script is a Forth-like bytecode stack-based language but what makes bitcoin script different that is designed purposely so the script execution is guaranteed to terminate. Some characteristics that are available in Forth but are not available in Script include variables, arrays, functions, and loops. Bitcoin Script does not provide any primitives that allow random write access to either of the stacks. A very important thing to understand — there are no accounts in the Bitcoin network, there are only inputs and outputs. Every transaction is a list of outputs, which refers to inputs. Bitcoin Script can be attached to any input and it defines the rule of converting an input to an output (sending bitcoins to person, for example).
Bitcoin Script key features:
- Script language includes the necessary cryptographic operations and primitives, has many different opcodes (many of them are disabled), but there are no loops. Script memory access is stack-based.
- A script always terminates. The execution time is bounded above by the length of the script after the instruction pointer and this limitation prevents denial of service attacks on the nodes which are validating the blocks.
Why do we need smart contracts
Since the first day of development, we had in our mind the main goal which is to cover two types of tasks for smart contracts:
There is another common use case for smart contracts — tokens. For example, in Ethereum Network the vast majority of working contracts are ERC20 standard tokens. But in our case, it is not relevant, because we have lightweight tokens in the core (more details here). It is not necessary to create a contract to issue a token, you just have to send one transaction of the predefined type.
With our first implementation of smart contracts, we decided to cover first types of tasks, i.e. multisignatures, atomic swaps, escrows. This will provide functionality for implementing the most-needed scenarios as well as more elaborate protections for coins and with our data transaction, there will be a way to post Oracle data to the blockchain.
In the early stages of development we have created a list of requirements for such smart contracts:
About Waves Blockchain
Before moving on to the technical details of the implementation, let’s talk a little bit about Waves blockchain, it will be important for further understanding.
What is Smart Account?
The latest release of Waves Node makes Smart Accounts enabled. I will try to give you an intuition what is a smart account.Basically, the smart account is an account with attached transactions checking script. in other words, a script which is attached to an account so the account can validate every transaction before confirming it.
Facts about Waves Smart Accounts (NO GAS is the best fact)
In next part I will discuss about RIDE smart contracts language, it’s idea and technical details about costs, standard library and we will write our first smart contract for Waves using IDE.
P.S. You can find a lot of details and explanations, including Smart Accounts White Paper on Waves website.
The Hitchhiker’s Guide to Waves Smart Contracts. Part 1 was originally published in Waves Platform on Medium, where people are continuing the conversation by highlighting and responding to this story.
Original article was created by: Inal Kardanov at blog.wavesplatform.comDisclaimer: This article should not be taken as, and is not intended to provide, investment advice. Please conduct your own thorough research before investing in any cryptocurrency or ICO.
Interested in Cryptocurrencies and ICO's?
Follow our telegram channel for daily cryptomarket reports!Join @cointrends
|11 hours ago||blockchain|
|14 hours ago||blockchain|
|3 days ago||smart-contracts|
|3 days ago||smart-contracts|
|3 days ago||waves|
|3 days ago||waves|
|5 days ago||programming|
|2 weeks ago||wavesplatform|
Stay on top of Altcoins and ICO trends.
Subscribe to our free Weekly Cryptomarket report
Delivered once a week, strongly to your inbox.Subscribe to our mailing list
September 20, 2018
We have hit a major milestone in the history of Waves: our one millionth account has been created!Waves was launched in June 2016 with the intention of becoming a mass-market blockchain platform. Two and a half years later, we celebrate reaching a very impressive one million wallets created!We...From: Waves Platform
We are excited to announce a new exchange listing! Bithumb, the largest South Korean cryptocurrency exchange, will list WAVES token for trading.Bithumb, which has its headquarters in Seoul, has just announced a new schedule of coin listings. The exchange recently published a Cryptocurrency...From: Waves Platform
September 18, 2018
On September 10 Waves Platform released a new version of node, which has the support of Smart Contracts in their first implementation. In the first part we focused on the idea of Waves Smart Accounts and what makes it different than other existing solutions. In this part we will focus more on...From: Inal Kardanov
September 14, 2018
September 12, 2018
We are very excited to announce that our CEO Sasha Ivanov has started negotiations with the Maltese government, concerning Waves’ accreditation to work within the territory of the state.Waves CEO, Sasha Ivanov, met with Hon. Dr Joseph Muscat, Prime Minister of Malta, and representatives of...From: Waves Platform
September 10, 2018
It’s finally happened! We have released a system update that will start the process of activating Smart Contracts on the Waves MainNet.We have released a new system protocol for the Waves blockchain that will enable Smart Contracts. The update initialises a process of voting for miners on the...From: Waves Platform