Bloqly: JavaScript Smart Contracts Engine + SQL database
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

README.md

JavaScript Smart Contracts Engine on a pBFT+PoA-inspired blockchain consensus algorithm


Build Status

This is a work in progress, API and implementation details can change.

Telegram Twitter Slack

What's this?

Bloqly is a written from the scratch smart contracts engine with JavaScript support.

First, small contract code sample:

const fractions = new Long('10').pow(8);
const maxSupply = new Long('1_000_000_000').multiply(fractions);

function main(context, orig, dest, amount) {

    let origBalance = getProperty(orig, 'balance', ZERO);
    let destBalance = getProperty(dest, 'balance', ZERO);

    let newOrigBalance = origBalance.safeSubtract(amount);
    let newDestBalance = destBalance.safeAdd(amount, maxSupply);

    return [
        { target: orig, balance: newOrigBalance },
        { target: dest, balance: newDestBalance },
    ];
}

function set(context, orig, dest, key, value) {

    return [ property(dest, key, value) ];
}

function setSigned(context, orig, dest, key, value, signature, publicKey) {

    let message = Crypto.sha256(value)

    if (!Crypto.verify(message, signature, publicKey)) {
        throw "Invalid signature"
    }

    return [ property(dest, key + ":" + publicKey, value) ];
}

Installation

Install Bloqly

Download and unpack the latest binary distribution for your platform from https://github.com/bloqly/bloqly/releases

Note 1: right now MacOS and Linux are supported natively. For Windows please use Linux Bash Shell for Windows (it works great actually).

Note 2: Bloqly uses Java under the hood, but you don't need to download and install JVM in order to get it working, it is already packed up into the distribution archives.

Install Postgres

For Linux I find these instructions of installing Postgres very well written and easy to follow:

https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-16-04 https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-18-04

For MacOS just run brew install postgres

After Postgres is installed, lets create test databases and users:

sudo -su postgres

createdb bloqly_main
createdb bloqly_rhea
createdb bloqly_loge
createdb bloqly_ymir

createuser user_main
createuser user_rhea
createuser user_loge
createuser user_ymir

psql -d bloqly_main -c "alter user user_main with password 'password_main';"
psql -d bloqly_rhea -c "alter user user_rhea with password 'password_rhea';"
psql -d bloqly_loge -c "alter user user_loge with password 'password_loge';"
psql -d bloqly_ymir -c "alter user user_ymir with password 'password_ymir';"

Documentation

Quick start

Bloqly consensus algoritm

Functional smart contracts with JavaScript