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 using blockchain for software asset management 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.
Contents
What is software licensing?
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 model and ensure blockchain license management. 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.
Future-proof your software licensing strategy with blockchain
Learn how our services can provide you with a competitive edge in the market and drive business growth!
Blockchain as a solution for software licensing
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 of DeFi app development 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.
The evolution of 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 blockchain 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 blockchainย licensing.
Read also
How to Develop an Ethereum Smart Contract for Licensing?
Explore how you can use Ethereum for building a blockchain licensing system. We share technical details of working with a distributed database, developing smart contracts, and adding them to a licensing application.
How can you benefit from a blockchain for software 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 blockchain-powered software licensing:
- 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 blockchain software, 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.
Using EOS smart contracts for application licensing
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.
Related project
Developing Smart Contracts for Creating and Selling NFT Images
Explore our success story in NFT project development as we partnered with an EU startup. By leveraging our expertise in development of blockchain and web applications, as well as QA, our client was able to kickstart their NFT sale on time and without technical issues.
How to develop an 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
# To print a contract's output to the console by default, add:
# --contracts-console
nodeos -e -p eosio --plugin eosio::wallet_api_plugin --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin --contracts-console
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.
# 1. Create a new wallet with the name "somewallet"
cleos wallet create -n somewallet
# 2. Generate two sets of keys (run the command twice)
cleos create key
# 3. Import the generated private keys into the wallet (you need to specify the wallet at the end)
# {private_key_1} - This will be the OwnerKey
# {private_key_2} - This will be the ActiveKey
cleos wallet import --private-key={private_key_1} -n somewallet
cleos wallet import --private-key={private_key_2} -n somewallet
# 4. Add the private key for the "eosio" account to your wallet
# Note: If you're receiving Error 3090003: Provided keys, permissions, and delays do not satisfy declared authorizations
# you probably should add the private key for the "eosio" account to your wallet.
cleos wallet import --private-key=NoNp4gn340gLfi23jn4g2340g9j2g02gnlas39tg3jh20g93gjc -n somewallet
3. Create an EOS network account
A legitimate account is necessary to make your smart contracts work within the network.
# Create an account using your public keys
cleos create account eosio anorak {public_OwnerKey} {public_ActiveKey}
# "eosio" is the name of the account that will create the new account
# "someaccount" is the name of the new account
4. Create a basic smart contract
Now itโs time to create a smart contract.
/**
* @file
* @copyright defined in eos/LICENSE.txt
*/
#include <eosiolib/eosio.hpp>
#include <eosiolib/print.hpp>
#include <string>
/**
* The init() and apply() methods must have a C calling convention so that the blockchain can look up and
* call these methods.
*/
extern "C" {
/**
* This method is called once when the contract is published or updated.
*/
void init() {
eos::print( "Init World!\n" );
}
void test(string& Message) {
eos::print(Message.c_str());
}
/// The apply() method implements the dispatch of events to this contract
void apply( uint64_t code, uint64_t action ) {
eos::print( "simple World: ", eos::Name(code), "->", eos::Name(action), "\n" );
}
} // extern "C"
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.
struct action {
scope_name scope; // the contract defining the primary code to execute for code/type
action_name name; // the action to be taken
permission_level[] authorization; // the accounts and permission levels provided
bytes data; // opaque data processed by code
...
};
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.
eosiocpp -o simple.wast simple.cpp
eosiocpp -g simple.abi simple.cpp
# cleos set contract {account} {path_to_contract_folder} {path_to_.wast_file} {path_to_.abi_file}
cleos set contract anorak ./contracts/simple ./contracts/simple/simple.wast ./contracts/simple/simple.abi
Reading WAST...
Assembling WASM...
Publishing contract...
{
"transaction_id": "75111f11837135a3e1111bfe73a76d1141db31417417831f0",
"processed": {
"refBlockNum": 511,
"refBlockPrefix": 3855761785,
"expiration": "2018-08-15T14:05:16",
"scope": [
"eos",
"someaccount"
],
"signatures": [
"10413f16161d6f1a31d76476114b756c117da730e61d1315ed78c57f0171fb5b0f58db611de1bf1ccec33bb6d1b14d8a36113aff00014b1883e65b861fd1d65fff"
],
"messages": [{
"code": "eos",
"type": "setcode",
"authorization": [{
"account": "someaccount",
"permission": "active"
}
],
"data": "000000000013dd740000f1010061736d0100000001110460017f0060017e0060000060017e7e00011b0103656e76067071616e746e000103656e76067071616e7473000003030101030404017000000503010001071103066d656d6f7171010004616e61740001056170706c7100030a10010600411010010b17004110100110001000413010011001100041c00010010b0b3f050041040b04504000000041100b0d416e617410576f716c64110a000041100b0e48656c6c6f10576f716c643a10000041300b031d3e000041c0000b010a000011046e616d6504067071616e746e0100067071616e7473010004616e617400056170706c710101300131010b4163636f756e744e616d65044e616d6501087471616e7366657100030466716f6d0b4163636f756e744e616d6501746f0b4163636f756e744e616d6506616d6f756e740655416e743634076163636f756e740001076163636f756e74044e616d650761616c616e63650655416e74363401000000571d3ccdcd087471616e7366657101000000104f4d11310361363401076163636f756e7401044e616d65076163636f756e74"
}
],
"output": [{
"notify": [],
"deferred_transactions": []
}
]
}
}
6. Test the smart contract!
Now that our smart contract is ready, we need to test it.
# cleos push action {account} {action_name} '{data}' -p {account}@active
cleos push action someaccount test'[Hello smartcontract!"]' -p someaccount@active
executed transaction: 00e14223e2345252c2357979b789896a962307293818797987e798779a798219 126 bytes 3415 us
: Hello smartcontract!
We can send a message to the deployed smart contract. For instance:
eosc push message someaccount ping '"some message"' --scope someaccount
Where:
- โ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.
Expanding smart contract functionality
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.
typedef struct _LICENSE_INFORMATION
{
unsigned long long LicenseId;
char SomeInformation[0x40]; // array size is not important in this example
char vendor[0x40];
unsigned long long TimeStamp;
unsigned long long ExpirationTime;
bool blActive;
// ...
} LICENSE_INFORMATION, *PLICENSE_INFORMATION;
bool pushLicense(LICENSE_INFORMATION& LicenseInfo)
{
blStatus = action[LICENSE_INFORMATION].send();
return blStatus;
}
// find the license, change its status from active to blocked
// and push a new block to the EOS network
bool blockLicense(unsigned long long LicenseId)
{
bool blStatus = false;
LICENSE_INFORMATION LicenseInfo = {};
// 1. find the license in the blockchain array
LicenseInfo = FindLicenseById(LicenseId);
if (LicenseInfo.LicenseId == NULL)
return false;
// 2. change the license status
LicenseInfo.blActive = false;
// 3. push the license
blStatus = pushLicense(LicenseInfo);
return blStatus;
}
LICENSE_INFORMATION FindLicenseById(unsigned long long LicenseId)
{
bool blStatus = false;
LICENSE_INFORMATION info = {};
for (auto it = eos::items.begin(); it!=eos::items.end(); it++)
{
if (it->LicenseId == LicenseId)
{
info = *it;
}
}
return info;
}
And thatโs it! Weโve created a basic license checker.
Conclusion
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 consider ensuring software asset management using blockchain. 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 the future.
Ready to unlock the potential of blockchain technology for service?
Partner with us, and our experts will help you achieve greater efficiency and security in your operations!