The words blockchain technology are no longer associated only with cryptocurrency and coins with fancy names. The blockchain is a breakthrough technology that can change the way we see trades and property, adding visibility and transparency to things that once were completely closed. But most importantly, blockchain technology opens new possibilities for improving the security of our money and data in nearly every aspect of life, in managing software licenses.
In one of our previous posts, we shared our experience building an Ethereum smart contract for application licensing. In this article, we talk about the possibility of implementing software asset management on the blockchain and the potential benefits of application licensing with the blockchain. We also describe how you can use EOS smart contracts for application licensing and even provide an example of an EOS smart contract-based license checker.
First, let’s focus on software licensing and why you may need it. A license is the main document that defines the rights and obligations of the user of a particular piece of software, an application, or a service. It’s an agreement between two parties, the user and the service or software provider, that comes with the software product either in paper or electronic form.
There are at least four common practices used for software licensing:
- Subscription – A licensing scheme under which users get full or partial access to the distributed software and services for a certain subscription term, usually a month or a year
- OEM license – An all-in-one type of licensing that’s used for pre-installed software you get when buying new devices
- Volume licensing – A corporate license for software aimed at enterprises, organizations, and state institutions; one such license can usually activate multiple devices at once, simplifying software installation throughout an organization
- Full package product (FPP) – A licensing type that allows you to install software on any PC or other compatible devices, although the number of legitimate installations is usually limited
Most software providers and license managers store all licensing information on a centralized server. However, we can finally switch from centralized to decentralized software license management with the help of blockchain technology. This means we can make the process of granting and verifying licenses more transparent, comfortable, and secure.
Let’s look closer at how we can issue software licenses with the help of blockchain technology.
Blockchain technology allows you to create a stable, reliable, decentralized system and an information repository that’s both accessible for everyone and doesn’t belong to anyone in particular.
The range of uses for this technology is no longer limited to cryptocurrencies. Today, we can see this technology being used in different fields to:
- Conduct financial transactions (primarily but not limited to crypto exchange markets)
- Store and confirm copyrights in licensing
- Store personal information
- Store and manage information from electronic voting systems
The functioning of a blockchain network is ensured not by a centralized server but by the network members, or nodes. Information in a blockchain network is open. Access to the network is granted with the help of specially generated keys that are unique to each user. On the one hand, these keys ensure network security and stability and guarantee the impossibility of data substitution. On the other hand, they allow you to identify the node that has conducted a particular transaction (the node, but not the person).
However, in order to build a blockchain-based application licensing system, we’re going to focus on smart contracts.
5 Security Tips for Writing Smart Contracts
The development of smart contracts took blockchain technology to a whole new level. The first smart contracts were implemented in the Ethereum network. However, this approach was quickly deployed by other networks, including NEM, CODIUS, and EOS. The emergence of smart contracts has expanded the capabilities of blockchain networks from stores of information to peer-to-peer computing networks.
Smart contracts are self-executing contracts with one specific characteristic: all terms of the agreement between two parties to the contract are written directly into the lines of code. The code can be executed when and only if the conditions of the agreement are reached.
In order for a smart contract to be considered legitimate within the network, it must be properly executed and signed. Technically, the process of executing and signing a smart contract is pretty similar to the process of executing and signing regular transactions on the network.
Figure 1 below shows a standard process for executing a smart contract.
This is what the process looks like in practice:
- The contract takes effect after each of the parties to the contract signs it with their own unique key. The conditions of their agreement are written into the code.
- When certain conditions are met, the contract is automatically executed.
- While the contract is visible to everyone on the network, the private information of its participants remains confidential.
In the same way, you can use smart contracts to verify software licensing agreements (Figure 2).
Smart contracts are performed only in the environment they were created for and can operate only the entities that are available to them in that environment.
Now let’s finally get to the main reasons why you should consider using smart contracts for application licensing.
A blockchain opens multiple opportunities for improving the process of issuing, managing, and storing application licensing data. We’ll focus on the four most important benefits of blockchain technology for this purpose:
- Decentralization – There’s no single central server managed by one person or group of people
- Transparency – All operations that add new data to the repository are open and visible to the general public
- Sustainability – A complete copy of all data is stored immediately by numerous network members
- Security – All data on the network as well as all ongoing transactions are secured with asymmetric encryption
With the help of a blockchain, license management becomes easy. In fact, with decentralized data storage and a peer-to-peer computing network that allows for implementing any logic in smart contracts, a blockchain becomes an excellent tool for creating, managing, and storing licenses and licensing information.
It’s noteworthy that some of the advantages of the blockchain are also the causes of this technology’s pitfalls. In particular, the need to reach consensus among multiple members of the network imposes certain restrictions on network capacity. Plus, the more transactions are currently running in the network, the more time it’ll take to process each of them.
For instance, the Bitcoin network is currently capable of processing only four to five transactions per second; the Ethereum network can process up to 15 transactions per second, while Visa processes nearly 1,000 transactions per second. But for decentralized applications that operate with a large amount of data and a large number of transactions, performance is essential.
This is where the EOS network comes into play.
EOS is a blockchain network that uses Ethereum smart contract technology. It was created as a platform for developing decentralized applications (dApps). The main distinction of the EOS network is its so-called Delegated Proof of Stake (DPOS) approach where every transaction is confirmed by the votes of network members. The more tokens a particular member has, the more valuable their voice. In theory, consensus is reached when a transaction is confirmed by a certain number of tokens, not nodes, thus allowing for improved network performance.
EOS isn’t tied to any particular virtual machine and works with the WebAssembly (WASM) standard, which allows you to develop fairly efficient browser-based applications.
Now let’s see how we can develop a basic EOS smart contract.
EOS smart contracts are written in the C++ programming language. First, let’s take a look at a basic example of a smart contract from the EOS SDK using the example of hello.cpp.
1. Launch the development environment
2. Create a wallet
A wallet is necessary for working with EOS smart contracts because it serves as confirmation that you’re a member of the network. It’s also used for storing your personal keys and signing transactions with them.
3. Create an EOS network account
A legitimate account is necessary to make your smart contracts work within the network.
4. Create a basic smart contract
Now it’s time to create a smart contract.
As you can see, a smart contract has two basic methods:
- init() is used only once for basic initialization of the application.
- apply() is an application the event-handler function. Two arguments are passed to the input: code and action.
The inherited action class contains the send() method that’s used to send a message to the network.
When an event occurs, the apply() method is called. The contract determines on its own how to handle the event (or whether to handle it at all).
5. Deploy the final smart contract
Deploying the smart contract consists of two stages:
- Generating a WAST file
- Generating ABI files
When these two stages are completed, the smart contract is deployed.
6. Test the smart contract!
Now that our smart contract is ready, we need to test it.
We can send a message to the deployed smart contract. For instance:
- “some message” is the data sent to the contract
- ping is a command
- SomeAccount is the account that sends commands to the smart contract
In response, we’ll receive a notification in JSON format about successfully sending the message.
Using this template of a smart contract, we can easily implement licensing logic. All we have to do is add three more methods to our smart contract:
- pushLicense() — A function that allows you to add new information about a license to the network
- blockLicense() — A function for revoking a license
- FindLicenseById() — A function for getting extended information about a license: date of creation, vendor, list of products that the license is applicable to, validity period, etc.
Next, we provide information about the license structure.
And that’s it! We’ve created a basic license checker.
Blockchain technology proves beneficial in different areas where decentralization, flexibility, reliability, publicity, and strict control of actions are necessary. You should no longer see this technology as only a cryptocurrency-related innovation but also look at the blockchain as a solution for software licensing. Blockchain technology can significantly simplify the issuance and control of licenses, making the entire process open and transparent.
While you can use Ethereum smart contracts for application licensing, EOS smart contracts are more universal and much easier to deploy as they don’t require a specific virtual machine. Plus, EOS smart contracts are deployed on WASM technology and will help you to create fast and compact decentralized applications in future.
At Apriorit, we have extensive experience developing different kinds of blockchain-based applications and will gladly assist you in implementing licensing with EOS smart contracts for your product.