As mobile internet technology continues to mature, the emergence of blockchain technology represents the upcoming post-mobile era. In fact, blockchain is a critical innovation for our generation. Despite currently being in an early stage of development (to the extend of being percieved as mysterious by the public), blockchain has a promising future. Subsequent to the previous two blockchain articles I published, this article aims to elaborate on the heart of blockchain – smart contracts.

What is a smart contract
The term “smart contract” was first coined by Nick Szabo in 1995, loosely defining it as a digital contract that is executed automatically.
A sales contract can be used as simple example of a smart contract. Two parties, a buyer and a seller, agree to terms of sale, such as price, delivery option and payment method. Once the seller has commited to send products to the buyer, the smart contract is updated, and the buyer’s payment is made automatically. Whenever a predetermined condition or term is met (such as confirmation of a sent parcel), the smart contract will execute in accordance.

Blockchain technology is evolving rapidly, with more value being generated by its applications with each iteration. Smart contracts are not only automated traditional contracts, but play a critical role in the world of blockchain. Below, I explore the future of this revolutionary technology through a technical analysis of Ultrain’s Blockchain 3.0 smart contracts.

Smart contract technical analysis
Ultrain's contract system does not allow other contract’s code to be embedded in custom contracts, but Ultrain does provide three methods to call code from other contracts, which we explore below.

  1. Action.requireRecepient()
    The Action.requireRecepient() method requires an action from a specified recipient. This command calls the deployed smart contract with a specified name.
    As an example below, we have written and deployed two contracts. In Figure 1, a contract was deployed on account “jack”, requiring authentication (Action.requireAuth()) from“rose”. The other contract, seen in Figure 2, was deployed on account “rose”and uses Action.requireRecipient() to validate the received notification from and “jack”.

0_1547691810374_950f7b5e-cd2e-4670-8960-f2152e3267c4-image.png
Figure 1
0_1547691819893_0384eb27-7efc-416e-9351-eda730fed2c5-image.png
Figure 2
We can test our calls by initiating a transaction. If everything runs smoothly, the log will show that both “jack” and “rose” recipient methods were called.

0_1547691836559_4d752cd2-a1d1-44a8-af12-c34d67de90de-image.png

We learn from this that:
(1)The recipient with the name “jack” has been called.
(2)The parameter transmitted is inconsistent with the parameter,“messi”, initiated by the transactions.
(3)Both the recipient methods of “rose” and “jack” will be called within the same transaction.
(4)Both “rose” and “jack” control their own permissions

  1. Action.sendInlin()
    Based on the testing result of Action.requireRecepient(), we can see that requireRecepient() has some limitations. Action.sendInline() is a method that solves this issue and allows any parameter to be called. Here is another explanatory example, again with two contracts, “rose” and “jack”:
    0_1547691846801_0dcd959e-3013-4ec2-9fb2-5b05bc45d8f2-image.png
    rose Contract
    0_1547691863662_f33a3412-3b75-434e-afe5-2e1575e996e2-image.png
    jack Contract
    Contract “rose” uses the Action.sendInline() method and delivers arbitrary parameters (params) to “jack” once executed.
    We can see in the execution log that “jack”’s “name”value has changed in accordance “params”specified in “rose”.
    0_1547692019357_597a63fb-be77-48b7-b988-a7b9bb1466f1-image.png
    This indicates that sendInline() can be used to call any method in any contract. Permissions are controlled by each contract independently, similar to the previous example, and the change is executed within the same transaction.

  2. Transaction.send()

    We saw in the previous examples that the actions specified in requireRecepient() and sendInline() are executed within the same transaction. This leaves the possibility for a mistake to result in the failure of an entire transaction. Transaction.send() is a perfect solution to this potential issue.
    The following picture demonstrates how this method is used:
    0_1547691910972_2a124a99-e633-4212-9a34-d50050130386-image.png
    rose Contract
    0_1547691919366_bbe55182-6dc1-47fc-8722-71c64e7be98a-image.png
    jack Contract
    We can execute the deferred methods specified in “rose”even after the contract has been deployed. Please note, the active right of rose to must be assigned to utrio.code, otherwise the request will not successfully exeucte.
    Once this method is conducted succesfully, we see rose’ log informtion(see Figure 3), but where is jack’s? We find it within the nodes (see Figure 4).
    0_1547691877757_b8ad0b91-7852-41e2-b8ea-ae47d9de6565-image.png
    Figure3
    0_1547691888676_dfec72aa-e5d5-4912-95e5-edf458548c47-image.png
    Figure4

From above we can see that Transaction.send() has the following charateristics:
1)Transaction.send() can call jack from any method.
2) the method allows execution outside of the same transaction
3)A called method can transmit any parameter
4)when the jack method is being called, it has the same permissions as rose at initiation

The table below recaps the charateristics of the methods described above. Each method has different strengths and weaknesses, and are therefore suited to their own specific circumstances.

0_1547692227496_21ca6ef4-2852-48bd-acb7-22741a2e5a4f-image.png

In summary, our analysis above clearly demonstrates the important role of smart contracts play in the Blockchain 3.0 era, by allowing flexible and secure computations on a decentralized system. Hopefully you have also glimpsed the power of Ultrain’s smart contracts.

Ultrain, a pioneer of next-gen blockchain projects, has made many improvements and breakthroughs in existing smart contract technology. Ultrain contracts are far beyond the requirements of traditional contracts and can realize increasingly complex business logic. They can be used for technical intercommunication that builds bridges between various industries. For this reason, blockchain technology is an essential component required for creating a business empire with high performance, low cost, high service quality and support for large-scale data assetization.