Building the Decentralized Organization Chain Project

One of the challenges of new startups is to get initial funding which is needed for rent, equipment and salaries. Decentralized Organization Chain (DOC) allows companies to start their own company blockchain and receive funding by selling tokens to investors. Investors in turn have a chance to make and influence company decisions by creating polls, or run a forging node creating a Decentralized chain and earning rewards. Anyone who bought enough tokens can become a board member and create polls. In addition, token holders can register themselves as investors so they're able to vote on polls. After the poll has ended, the company is expected to follow the most voted answer.

By Lisk

09 Jun 2020

building-the-decentralized-organisation-chain-project-OG@2x.png

Example:

New poll: Should we hire 2 additional R&D employees?

Options: [Yes] [No]

The DOC application is built with the Lisk SDK and consists of a server and client part, both written in Javascript. The server runs the actual blockchain using NodeJS and a PostgreSQL database. The client part acts as an interface to the server and is built using NodeJS, React, bootstrap, and Lisk Elements.

I’ve found that I could reuse parts of the custom transactions of my previous Proof of Concept, Global Data Chain. After a while, you will have many custom transactions made by various developers, making it easier and faster to build a blockchain tailored to your needs.

Rules

The following rules are part of DOC:

  • Founders hold a significant amount of tokens, which can also be used for future funding of the company.
  • Initial Token Offering (ITO) allows interested parties to invest in the startup company and even take a board member position.
  • Quarterly profit is used to buy back and then burn tokens from the exchanges, increasing the token price for investors and also decreasing the existing amount of tokens.
  • After a poll ends, the company must follow the most voted decision.
  • If the above rules are violated, then it will result in investors losing faith, selling their tokens and decreasing the value of the Founders tokens.

Usage

View polls

You can find all polls by clicking on Polls Overview in the menu on the top left of the page. From there look through the different pages or filter to view All polls, the Open polls or Closed polls.

To vote on a poll, go to Open polls and click on a poll question. This will take you to the Polls detail page. You can even share the link to the poll by copying the url, for example: doc.korben3.com/poll/8097342680131618285L.

Login

Before you can create a poll, you first have to login. Go to the top right of the page and enter a valid passphrase for the Decentralized Organization Chain. Alternatively use the already filled in passphrase, which belongs to an investor account and allows you to vote. Then click the Login button.

After you login an extra menu option appears called Account Info. Here you can check how many DOC tokens the account holds and if it's registered as an investor or board member. Depending on your user type, you can either vote, or vote and create new polls.

Register Account

If you own enough DOC tokens you can register your account by first logging in and then going to Account Info. There you can click on the link called Register as an investor or board member. Or go to doc.korben3.com/register

To register, create a good username and choose a user type: investor or board member. If the account has enough balance it will be registered after clicking on the Register Account button.

Vote on a poll

To vote on a poll select one from the Open polls which you can find in the Polls Overview. Read the question and click on the circle option before the answer you would like to choose. Then click on the Vote button. Remember that for voting you should first login, you should have enough balance and you should be registered as an investor or a board member. You can also see how much time is remaining before the poll closes.

Create a new poll

To create a new poll you first must be registered as a board member. If you want to try it out, just ask korben3 on Discord for an account. Go to Create Poll and fill in a good business-related question and at least 2 answers. Be sure to review the poll and then click on the Submit Poll button. It will create the poll on an unique address. You can find the created poll by going to Polls Overview and selecting Open polls. Click on the poll and copy the url to share it with others.

Custom transactions

The following custom transactions are used:

TypeNameDescriptionFee (DOC)
101RegisterInvestorTransactionRegister as an investor.1000
102RegisterBoardMemberTransactionRegister as a board member.100000
103AddPollTransactionAdd a new poll.1000
104CastVoteTransactionCast a vote.100

You can find the source code on GitHub: korben3 - Decentralized Organization Chain

Register as investor

Filename: register-investor_transaction.js

This transaction allows token owners to register themselves as investors. Investors are able to vote on polls created by board members. The fee is set to 1000 DOC so the threshold to participate is low.

In the validateAsset() method we make sure the transaction conforms to the following rules:

  • The user.name property is present and equal or smaller than 32 characters
  • The user.type property is present and the value is set to "investor"
  • The transaction contains only 1 asset object and only 2 user properties

Below is the code that makes sure the user.type is set to "investor" or else it will throw an error.

File name
1if (!user.type || user.type !== "investor") { errors.push( new TransactionError("Invalid user type for this transaction.") ); }

After the transaction (tx) is validated, the investor type will be applied to the users account. And the user will be allowed to vote on a poll.

Register as a board member

Filename: register-board-member_transaction.js

Registering as a board member costs 100000 DOC, this is an intended high fee because members are allowed to create new polls changing the direction of the company. Both the company and investors benefit from good decisions, so any new poll is taken very seriously. Board members are also allowed to vote.

Add new poll

Filename: add-poll_transaction.js

With this transaction, board members can create new polls for 1000 DOC. A poll is open for 7 days after which it is not possible to vote on any of the answers. When the poll closes, the company is expected to follow the result, which is the answer with the highest amount of votes. If the company decides to ignore the result, it will decrease trust and investors might decide to sell large parts of their tokens, decreasing the value.

The poll transaction code performs various checks to make sure valid polls are submitted:

  • A Question must be present and of correct length.
  • At least 2 and a maximum of 5 answers are allowed and must be of correct length.
  • No cheating allowed, so it cannot start with votes present.
  • The sender must be registered as a board member.
  • If the poll address already contains a poll. Overwriting is not allowed.

For example, the following code checks if the sender is registered as a board member.

File name
1if (sender.asset.user.type !== "board") { errors.push( new TransactionError("Sender is not registered as a board member.") ); }

Cast vote

Filename: cast-vote_transaction.js

Token owners registered as investors or board members are able to vote on any open poll. One vote costs 100 DOC tokens. Multiple votes on an answer are allowed because this shows that someone is willing to spend a lot of tokens to make a certain decision. Token holders only benefit from good decisions, so any vote is considered carefully. After the poll closes it is not possible to vote any more and the vote is rejected by the blockchain. The cast vote transaction checks if the vote asset is valid, if the poll is still open and if the sender is registered as a board member or investor.

The code below in the applyAsset method adds the vote.

  • If there are no votes, it simply adds a new vote asset with the first vote of the sender.
  • If the answer is already voted on, it increases the vote count of that answer.
  • If there are already votes but this is a new answer, it stores all the previous votes and adds the new answer with a value of 1.
    File name
    1if (recipient.asset.poll.votes) { let votes = recipient.asset.poll.votes; if (votes[vote]) { ++votes[vote]; recipient.asset.poll.votes = votes; } else { recipient.asset.poll.votes = { ...votes, [vote]: 1 }; } } else { recipient.asset.poll.votes = { [vote]: 1 }; } store.account.set(recipient.address, recipient);

Extending DOC

The current version of Decentralized Organization Chain could be extended with small features such as setting a custom poll duration, adding a user type for founders or creating a “Create New Account” page. Or with new ways to move more structure and communication from a company to the DOC blockchain besides polls. For instance: Allowing founders to post monthly news in a blog format. Adding employee user types and awarding them automatically for certain achievements or paying them a monthly bonus in DOC tokens. Creating short and long term company goals and triggering certain actions upon success or failure.

There are so many possibilities with the custom transactions from the Lisk SDK. Having a decentralized company blockchain can increase trust, transparency and efficiency. Feel free to use the code on GitHub to explore and create your own versions!

For further details about the Decentralized Organization Chain project and the code, check out its GitHub repository.

If you feel inspired and want to build your own proof of concept blockchain application, check out the Lisk Grant program. More information about the program and the application procedure can be found on the Lisk web page for the Lisk Grant program.

Disclaimer: This blog post was written by our community member, Korben3 Lisk.chat (username: korben3) as part of his participation in the Lisk Builders program.