Blockchain Primer on Smart contract creation
BLOCKCHAIN PRIMER : SMART CONTRACTS
A few imperatives towards embracing block chain technologies – a blockchain basics primer

Banner-article8

In the previous article on blockchain carried out in PCounsel edition 5, we went into the basics of what is a Blockchain. In this current article, we now move ahead and go deeper into the applications of Blockchain in the legal technology domain, using the up-and-coming concept of smart contracts.

A smart contract is a self-executing contract with the terms of the agreement between the two parties directly written into the code. This entire coded agreement is stored across the distributed network of computers in the blockchain. The code controls the execution, and the transactions carried out are traceable, transparent, and irreversible. Thus, smart contracts enable trusted transactions over a secure network between even anonymous parties.

But implementing this in organizations requires attention to much-needed policies, protocols, etc so that the full value of the blockchain implementation can be realized. These protocols and policies refer to the setting up of the system within the enterprise, for example, a smart contracting-based solution, and deal with authorizations, limits on value transactions, task limits, privacy policies, access to resources, and more.

In other words, these are the settings or set of rules that govern the running of the software and thus ensure that the application delivers the requisite output. These are critical in the transition phase from a traditional to a smart contract-based CLM system and are what ensure a proper implementation as well as the seamless running of the system. This article is meant as a primer to familiarize the reader with these technical terms which are sure to come up when the actual consideration of smart contract implementation comes onto the table.

It is important for Law Firms & corporate legal departments to successfully adapt following policies to transition from traditional contracts to smart contract management.

01
Authorization – User Identification
This refers to using the key security feature of blockchain to identify users and specific devices. In this, the organization must restrict access to critical methods to specific users only. This is accomplished by mapping the addresses and typically checked using modifiers.

02
Rate Limit – Task Frequency
This is a key policy to ensure the security of the smart contract. Regulate task frequency, to limit the number of messages sent to a smart contract – in simple terms, how many times a certain task can be performed within a time limit, and thus control the system’s computational load.

03
Balance Limit – Amount Of Money At Risk
Limit the maximum amount of funds held within smart contracts, or the amount of money at risk within a smart contract.

04
Termination Of A Contract
Proper termination of a smart contract is vital to ensure the system continues operation unhindered. Thus, whenever smart contracts end, an ad-hoc code is inserted in the contract or calling the self-destruct function. Usually, only the contract owner is authorized to terminate a contract. In a smart contract scenario, there may be a situation where a particular contract runs for a long, consumes too many resources, or causes lag. To prevent such scenarios from occurring, Termination is used.

05
Contract Privacy
Smart contracts are not automatically confidential or private – and are theoretically accessible to everyone on the chain. Thus, there is a vital need to encrypt on-chain critical data to improve confidentiality and meeting legal requirements, such as the European GDPR.

06
Check Effect Interaction – Stop Unexpected Execution Of Contracts
Checks Effects Interaction Pattern is a basic coding pattern that prevents an unexpected execution of a contract. This is a programming pattern that checks all the prerequisites before executing a feature in a certain function. In other words, all pre-conditions need to be checked before performing a function in a smart contract. Never alter the sequence.

07
Reusability – Libraries And Templates
We need to ensure that we can use contract libraries and templates as a factory for creating multiple instances.

08
Mutex
Short for Mutual Exclusion – used to restrict concurrent access to a resource. This is essential if we have to ensure that any contract on the smart system can only be accessed by one process at a time. This, unless checked, can create a situation where two processes cause interference for example, as in pricing negotiations.

09
Speed Bump
Slow down contract-sensitive tasks to ensure more time is available for a counter-attack if any malicious hack takes place.

In addition to the above, other important checks which need to be incorporated, or working processes that need adoption by the organization are:

  • Fail-Safe mechanism – inbuilt ability to update or terminate contracts
  • Balance of contract needs to be checked always
  • Try to have transactions consolidated outside the blockchain and then register them at one time within the blockchain. This is to avoid the large fees or high latency constraints
  • Limit the amount of ether – a blockchain is a distributed network and consumes power Ether is the medium of exchange that enables processes to run on the system. Keep a strong internal check on this aspect
  • Transaction ordering needs to be carefully monitored
  • Avoid complex inheritance logic
  • Set approval systems for any fund withdrawal
  • Be careful with external calls
  • Use hash secrets for authentication and approvals
  • Use multiple signature approvals to reduce any malicious intentions
  • Don’t embed large objects within the blockchain, rather use their reference links
  • Use platform related standards (example ERC – Etherium Request for Comments)
  • Prevent over flow / under flow situations
  • Rounding errors need to be carefully reviewed
  • Validate all inputs in the blockchain
  • Don’t try to override built-in functions
  • Fix compilation errors
  • Time stamps need to be carefully monitored