Be a crypto hero in the market by logging in

Don't you have an account? Sign in

Token price

  • BTC

    8,963,246.4KRW

    -0.6%

  • ETH

    178,439.5KRW

    -0.1%

  • XRP

    272.2KRW

    -0.9%

  • USDT

    1,192.5KRW

    -0.5%

  • BCH

    253,887.2KRW

    -0.3%

  • LTC

    54,759.1KRW

    -0.5%

  • EOS

    3,249.2KRW

    -0.6%

  • BNB

    18,658.8KRW

    -0.1%

  • BSV

    114,475.3KRW

    -0.6%

  • XLM

    66.4KRW

    -0.1%

  • XTZ

    1,923.7KRW

    3.5%

  • ADA

    45.6KRW

    -1.3%

  • TRX

    17.3KRW

    -0.8%

  • XMR

    64,101.3KRW

    -1.7%

  • HT

    3,361.8KRW

    0.0%

  • NEO

    10,683.7KRW

    -1.1%

  • MKR

    603,485.1KRW

    0.6%

  • DASH

    62,514.4KRW

    0.6%

  • USDC

    1,192.8KRW

    -0.5%

  • ETC

    4,651.2KRW

    -0.6%

  • ONT

    758.1KRW

    -0.6%

  • VET

    8.5KRW

    2.2%

  • XEM

    43.0KRW

    -1.2%

  • DOGE

    2.6KRW

    -0.9%

  • BAT

    229.5KRW

    0.9%

  • ZEC

    37,560.8KRW

    6.1%

  • PAX

    1,192.7KRW

    -0.5%

  • DCR

    24,238.9KRW

    -2.9%

  • INB

    635.7KRW

    -1.1%

  • QTUM

    2,105.5KRW

    0.3%

  • TUSD

    1,190.8KRW

    -0.6%

  • RVN

    37.8KRW

    -3.8%

  • LINK

    485.1KRW

    2.0%

  • ZRX

    280.9KRW

    -1.1%

  • REP

    12,332.3KRW

    -1.9%

  • NANO

    988.7KRW

    0.0%

  • CNX

    2,333.8KRW

    -0.1%

  • OMG

    902.9KRW

    0.8%

  • BTG

    7,115.1KRW

    -1.7%

  • XIN

    257,394.4KRW

    -0.0%

  • XIN

    257,394.4KRW

    -0.0%

  • LSK

    820.1KRW

    0.5%

  • DGB

    7.8KRW

    -0.5%

  • XVG

    6.0KRW

    4.3%

  • KCS

    1,141.4KRW

    -1.8%

  • BTM

    93.4KRW

    -1.9%

  • BTM

    93.4KRW

    -1.9%

  • KMD

    787.1KRW

    -0.7%

  • THETA

    104.3KRW

    6.6%

  • IOST

    7.3KRW

    1.7%

  • BCD

    445.2KRW

    -1.5%

  • ICX

    162.4KRW

    0.4%

  • ENJ

    103.9KRW

    -7.7%

  • MCO

    5,013.7KRW

    0.6%

  • BCN

    0.4KRW

    14.7%

  • SC

    1.8KRW

    2.9%

  • ZIL

    7.8KRW

    -3.5%

  • MONA

    1,082.2KRW

    -0.2%

  • WAVES

    689.7KRW

    -0.5%

  • QNT

    5,645.2KRW

    1.1%

  • DAI

    1,186.6KRW

    -0.5%

  • BTS

    24.2KRW

    -0.3%

  • HC

    1,460.3KRW

    -1.9%

  • NEXO

    113.3KRW

    -2.1%

  • MAID

    136.8KRW

    0.2%

  • ARDR

    57.3KRW

    -0.0%

  • AE

    194.5KRW

    0.3%

  • STEEM

    146.3KRW

    0.5%

  • ETN

    4.5KRW

    -2.4%

  • SNT

    12.8KRW

    -2.2%

  • NPXS

    0.2KRW

    0.0%

  • GNT

    44.3KRW

    0.0%

  • ELF

    74.0KRW

    -1.3%

  • XZC

    4,258.0KRW

    -0.4%

  • AOA

    5.8KRW

    1.0%

  • STRAT

    358.0KRW

    -0.4%

  • FCT

    3,806.3KRW

    2.7%

  • PPT

    633.2KRW

    0.3%

  • ELA

    1,923.7KRW

    -0.0%

  • AION

    77.5KRW

    -1.5%

  • LRC

    29.9KRW

    1.1%

  • WTC

    626.9KRW

    -2.4%

  • ARK

    226.8KRW

    1.0%

  • LOOM

    25.7KRW

    -6.3%

  • R

    50.2KRW

    -0.4%

  • RDD

    0.8KRW

    5.7%

  • WAX

    24.0KRW

    -2.9%

  • POWR

    50.3KRW

    5.9%

  • PAI

    14.2KRW

    -0.8%

  • PAI

    14.2KRW

    -0.8%

  • MOAC

    329.2KRW

    1.9%

  • BNT

    324.2KRW

    1.2%

  • ANT

    637.7KRW

    -0.2%

  • DENT

    0.2KRW

    3.3%

  • ODE

    71.5KRW

    0.1%

  • PIVX

    273.5KRW

    0.7%

  • POLY

    29.7KRW

    8.7%

  • TTC

    33.0KRW

    -5.5%

  • PAY

    67.1KRW

    -2.4%

  • MBL

    2.5KRW

    22.9%

  • BAAS

    1.8KRW

    0.2%

  • EOSC

    7.7KRW

    6.9%

  • APIX

    0.7KRW

    16.2%

  • BORA

    9.1KRW

    0.7%

  • CPT

    1.9KRW

    0.7%

  • REPO

    50.3KRW

    -4.6%

  • GUSD

    1,189.1KRW

    -0.7%

  • FNB

    4.4KRW

    -17.2%

  • COSM

    7.1KRW

    -1.6%

  • HUM

    9.1KRW

    7.7%

  • AERGO

    41.5KRW

    11.8%

  • FLETA

    9.3KRW

    -1.5%

  • UPP

    12.2KRW

    -0.9%

  • VRA

    1.1KRW

    -0.1%

  • MVL

    0.4KRW

    -3.7%

  • DCC

    0.9KRW

    0.4%

  • LKY

    51.0KRW

    2.2%

  • eDEL

    2.4KRW

    -0.7%

  • RBG

    1.3KRW

    14.4%

  • MEETONE

    1.1KRW

    -0.1%

  • TEMCO

    0.6KRW

    -5.2%

  • ABL

    5.6KRW

    -34.0%

  • AKRO

    1.7KRW

    -11.2%

  • AMON

    2.3KRW

    40.1%

  • AID

    2.5KRW

    -4.3%

  • PTON

    0.1KRW

    9.0%

  • WET

    5.6KRW

    -0.9%

  • PXL

    20.5KRW

    -2.4%

  • CLB

    1.7KRW

    4.6%

  • KARMA

    0.1KRW

    0.7%

  • XRA

    4.8KRW

    -6.7%

  • RBTC

    8,663,093.2KRW

    -2.2%

  • WIKEN

    1.5KRW

    -25.9%

  • SEAL

    0.8KRW

    -0.0%

  • NEWS

    1.2KRW

    -1.2%

  • PUB

    0.2KRW

    2.1%

  • NPER

    3.5KRW

    0.4%

  • HORUS

    0.2KRW

    -0.0%

  • CCH

    0.1KRW

    --%

  • PUT

    1.1KRW

    -8.1%

  • KNT

    0.0KRW

    37.4%

  • IQ

    3.1KRW

    -4.0%

  • BLACK

    0.9KRW

    27.9%

  • CET

    17.8KRW

    -2.0%

  • RCD

    3.0KRW

    --%

  • MCC

    0.4KRW

    0.4%

  • INC

    0.2KRW

    -10.5%

  • BZKY

    0.1KRW

    -78.8%

  • CRE

    2.0KRW

    9.7%

Community

Smart contracts for the private blockchain network

Waves | 07.12| 180

Vostok’s approach addresses many of the shortcomings of public-blockchain smart contracts when applied to a private network.

Difference between smart contracts on public and private networks

The blockchain is evolving from payment systems, to enabling the platforms that allow underpin decentralised applications. Charles Hoskinson provides a good explanation: when Ethereum was developing their platform they realised that the transfer of assets has a story behind it, which can consist of different terms and conditions to be fulfilled for transfer to be finished. Consequently, with further technological development blockchain users realised that more than transferring is possible and started to build various useful and even funny decentralised applications. As far as the public blockchain goes the main use cases are:

  1. Games — Crypto Kitties, Ride on waves, etc
  2. Asset exchange
  3. Secure Voting systems
  4. Crowdfunding (ICOs)

With the growth of adoption and popularity of public blockchain platforms, enterprise companies understood that blockchain technology could actually be very efficient for some of their business processes. That progress and focus on business needs had an influence on smart contract development as well. Now, given our experience with the corporate customers, we can provide popular use cases in which smart contracts can shine in the private blockchain arena:

  1. Corporate document flow
  2. Supply chain business processes
  3. Insurance
  4. Secure voting systems
  5. Clearing of mutual settlements with suppliers
  6. Leasing and rental equipment
  7. Creation of derivative financial instruments, backed by tangible or intangible assets (e.g. debt tokenisation)
  8. Auctions of any type or complexity
  9. Predictive analytics over blockchain data

As you might imagine, there is a difference between smart contracts for public and private blockchains. On a private blockchain the key differences are:

  • Data operated by smart contracts is much more sensitive compared to public networks.
  • A common case is that smart contracts should be able to operate with documents and data stored outside of the blockchain, which is not possible for public blockchain platforms. In a public network, there are oracles which are either trusted or can store very limited data objects directly on the blockchain. In both cases, there are serious limitations for the private case.
  • Sometimes transactions which invoke smart contracts should be encrypted, if we are dealing with private smart contracts in such a way that only authorized parties can decrypt and execute the contract.

What do business customers expect from smart contract functionality in business applications?

The answer to this question is relatively simple — they want to translate their complex business processes into blockchain logic with a minimum amount of pain. In order to satisfy the needs of our customers, we conducted research and formulated questions to understand what has to be done with our smart contracts:

  1. Q: What language should contracts use and how safe it should be?

As you might know, Waves has the RIDE language, which is really convenient and well-integrated to the blockchain — but it is useful only when the logic of the application is confined to the chain. For applications which need to operate with a lot of different documents, RIDE is inconvenient and we should use something more friendly for developers.

2. Q: Can the system easily express complex business rules?

For most languages the answer is, unfortunately, no. There are many reasons for this. Corporate developers do not know blockchain specifics and languages for smart contract development, and the relevant languages aren’t able to work with off-chain data.

3. Q: Can we upgrade contracts in the future without rewriting all blockchain structures?

Again, no for most approaches on the market (except Hyperledger Fabric). The main reason is that contracts are integrated into the blockchain too closely, which is inherited from public networks where another integration poses a direct threat to system security.

4. Q: How easy is it to integrate smart contracts into existing customer infrastructure and work with other business applications?

Unfortunately, most of the business applications or their APIs have to be redesigned and it is hard to use them from smart contracts, which introduces additional costs for businesses when adopting blockchain within their project.

In the next section, we will describe how we approached all these problems and what our complete solution is.

Vostok Smart Contracts

So, what smart contracts are available for Vostok Platform?

RIDE

As you already know, Vostok support RIDE and relatively soon will adopt RIDE 4 dAps. But RIDE, like almost any other smart contract language that was developed for the public platform initially, lacks the ability to work with off-chain data. Given that RIDE is very fast and well-integrated to the blockchain we propose to use RIDE for implementation of simple logic that doesn’t involve data processing from external sources. So, for example, public auctions, public voting, public insurance could all be implemented using the RIDE language. Otherwise, we recommend using our new feature — Docker smart contracts.

Docker smart contracts

Vostok Docker smart contracts are actually programs wrapped into the Docker container. The Docker container is placed in the Docker registry (one or many). Each container has an address on the blockchain and an image hash associated with it (obviously to ensure that we are using the valid container we publish the image hash beforehand with the DockerCreate transaction: more on this can be found in our documentation). To execute a contract, a blockchain transaction is made with the required call parameters, and the contract will also write the results on the blockchain. Since we are using Docker containers, any programming languages and frameworks can be used, unlike Hyperledger Fabric, where developers are limited by the SDK. Note that Docker isolates the application from the Vostok node and we do not have access to the node at the Code level, but we do have a network connection so are able to execute HTTP or RPC requests when we need to. This means we are able to request not only our node but almost any other service we know. To summarise our previous statements, the key advantages of Vostok’s Docker smart contracts are:

  • Flexibility of programming languages. Developers can choose any programming language, with any frameworks and packages they are comfortable with.
  • As a result, we can run Neural networks and other machine learning models inside contracts to bring the power of AI to blockchain applications.
  • We can connect our smart contracts to external data sources, accessing real-time data and working with applications outside of the blockchain.
  • Complexity of smart contracts is bounded only by the computing power of the virtual machine on which the contract is deployed. Execution time is bounded only by block time, or can be lower if user wants.
  • Contract parameters can be encrypted to prevent users from knowing what data you are processing.

What happens when you call a contract?

As explained in the previous section we have some code in the docker container. But what actually happens, when someone puts a call transaction in the Node transaction pull? The procedure is as follows:

  1. If the container does not exist, it will be created with the necessary environment variables.
  2. It loads exec, a firewall if an Internet connection for this contract is prohibited, and the domain Node is initialised with environmental variables.
  3. Then run.sh script is executed, which will install dependencies if the container did not exist
  4. The contract can obtain information about the node and transaction through the OS environment variables.
  5. The contract will be killed on timeout if takes too long to compute (the exact timeouts can be configured by the user).
  6. The result of the contract’s execution should be printed to STDOUT and formatted as List[DataEntry]. For more details on the format and output you can check the documentation.
  7. If the contract executed successfully, the miner will create ExecutedContractTransaction and sign it. The transaction contains the call transaction which invoked the contract, and the result. Then, like any other transaction, it is included in the block and applied to the state.
  8. All participants receiving the block can validate that the transaction signature was produced by the participant with role ‘mine’, and also apply the tx to the state.

If you are interested in seeing examples and the necessary steps of deploymen,t you can check this guide in our official documentation.

Brief comparison with the best on the market

The advantages do we gain from these technological solutions are important, so here we will discuss how our Docker smart contracts compare with other popular smart contracts.

1. Ethereum has a strong community and has dominated for a long period of time as the number one dApp development platform in the public blockchain arena. It has also been modified for private blockchain use (for example Quorum and Masterchain). But Solidity and EVM languages in general, for the sake of execution on a public network, have serious limitations which Vostok Docker contracts do not have.

a) Gas. EVM languages are Turing complete, but in order to be stable in case of an attack, which would paralyse the system by executing infinite calculations, there is a limit to how many operations EVM can perform per contract execution and how complex operations can be. As a result, if we have a complex contract we may get an Out of Gas Error. This is impractical for a private network, because we require that business processes will be completed.

b) Off-chain data. You can put some data in the Ethereum smart contracts, but the storage is quite limited and expensive. You can not, for example, write a contract for example, that requests current prices from an exchange, and uses them for other operations. In other words, you can not create a small web server using Solidity, but you can do it with Vostok — and even with your favourite programming language and framework.

2. Hyperledger Fabric is currently the best-known platform for private blockchain solutions, and also brings to the table smart contracts in Docker containers. However, they are limited by the SDK and only available for Go, JS, etc. Developers have to handle a lot of low-level operations like dispatch and argument discovery, making even the simplest ‘hello world’ programme on Go 90 lines of code. This might be impractical for many developers.

What’s next?

We are constantly working on improving our technology and have already started work on some of the key features we will release in the coming months. To start with, we are working on security enhancements for the current protocol. In the future, smart contracts may require a multi-signature by miners involved in contract execution. We are also enhancing our mining process to support parallel mining of Docker smart contracts and ordinary transactions, along with mining multiple Docker contracts in parallel.

References

  1. Vostok Site
  2. Vostok Documentation
  3. Vostok Docker example
  4. Waves RIDE docs

Smart contracts for the private blockchain network was originally published in Waves Platform on Medium, where people are continuing the conversation by highlighting and responding to this story.

Comment 0

delete

Are you sure you want to delete this post?