All pages
Powered by GitBook
1 of 6

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Deploy Your dApps

Bluzelle currently supports multiple languages including JS, Go, Python, Ruby & Java. We are also releasing client libraries for C# and PHP soon.

Select a client library to get started👇

JSGoPythonRubyJava

Python

Getting started

Ensure you have a recent version of installed.

Grab the package from github:

Use:

Examples

Copy .env.sample to .env and configure if needed.

Then run the example:

Tests

The tests/ can best be run in a environment. To do so, initialize one with:

Install requirements:

Then run the tests:

User Acceptance Testing

Please checkout the document for more details.

Licence

MIT

pipenv install git+https://github.com/bluzelle/blzpy.git#egg=bluzelle
import bluzelle

client = bluzelle.new_client({
  'address':  '...',
  'mnemonic': '...',
})

gas_info = {
  'max_fee': 4000001,
}

key = 'foo'

client.create(key, 'bar', gas_info)
value = client.read(key)
client.update(key, 'baz', gas_info)
client.delete(key, gas_info)
cp .env.sample .env
DEBUG=false python examples/crud.py
pipenv --python 3
pipenv install
make test
Python 3
pipenv
UAT.md

Go

Getting started

Ensure you have a recent version of Go installed.

Grab the package from github:

go get github.com/bluzelle/blzgo

Use:

package main

import (
  "github.com/bluzelle/blzgo"
  "log"
)

func main() {
  // create client
  options := &bluzelle.Options{
    Mnemonic: "...",
    Endpoint: "http://dev.testnet.public.bluzelle.com:1317",
    UUID: "...",
  }
  client, err := bluzelle.NewClient(options)
  if err != nil {
    log.Fatalf("%s", err)
  }

  key := "foo"
  value := "bar"

  gasInfo := bluzelle.GasInfo{
    MaxFee: 4000001,
  }
  leaseInfo := bluzelle.LeaseInfo{
    Days: 1,
  }

  // create key
  if err := client.Create(key, value, gasInfo, leaseInfo); err != nil {
    log.Fatalf("%s", err)
  } else {
    log.Printf("create key success: true\n")
  }

  // read key
  if v, err := client.Read(key); err != nil {
    log.Fatalf("%s", err)
  } else {
    log.Printf("read key success: %t\n", v == value)
  }

  // update key
  if err := client.Create(key, value, gasInfo, nil); err != nil {
    log.Fatalf("%s", err)
  } else {
    log.Printf("create key success: true\n")
  }

  // delete key
  if err := client.Delete(key, gasInfo); err != nil {
    log.Fatalf("%s", err)
  } else {
    log.Printf("delete key success: true\n")
  }
}

Examples

You can test out the examples/ included by following these steps:

  1. Copy .env.sample to .env and configure if needed.

cp .env.sample .env
  1. Install dependencies:

go get ./...
  1. Run an example as defined in the Makefile, for example, to read the value of an existing key, foo, run:

make read key=foo

This will run the examples/crud/read.go.

Integration Tests

make test

User Acceptance Testing

Please checkout the UAT.md document for more details.

Licence

MIT

Java

blzjava is a Java/Android library that can be used to access the Bluzelle database service.

  • Build and API docs

  • Java docs

  • Examples

  • Android example

  • Tests

Quickstart

Make sure that Java is installed and has a version at least 8 (JDK 1.8).

$ java -version
$ javac -version

If Java is not installed, install it.

$ sudo apt-get update
$ sudo apt-get install default-jdk

Download bluzelle.jar from releases or using terminal.

$ wget https://github.com/bluzelle/blzjava/releases/download/0.0.1/bluzelle.jar

Create file "Quickstart.java".

import com.bluzelle.*;

public class Quickstart {

    public static void main(String[] args) {
        Bluzelle bluzelle = Bluzelle.connect(
                "around buzz diagram captain obtain detail salon mango muffin brother morning jeans display attend knife carry green dwarf vendor hungry fan route pumpkin car",
                "http://dev.testnet.public.bluzelle.com:1317",
                null,
                null
        );

        GasInfo gasInfo = new GasInfo(10, 0, 0);
        LeaseInfo leaseInfo = new LeaseInfo(1, 0, 0, 0);

        bluzelle.create("key", "value", gasInfo, leaseInfo);
        System.out.println("created");
        bluzelle.update("key", "new value", gasInfo, leaseInfo);
        System.out.println("updated");
        System.out.println("'key': " + bluzelle.read("key", false));
        bluzelle.delete("key", gasInfo);
        System.out.println("deleted");
    }
}

Compile.

$ javac -cp ./bluzelle.jar Quickstart.java

Run.

$ java -cp .:./bluzelle.jar Quickstart

Ruby

Getting started

Ensure you have a recent version of Ruby installed.

  1. Install libsecp256k1 as described here.

  2. Add the gem to your Gemfile:

gem 'money-tree', git: 'https://github.com/bluzelle/money-tree'
gem 'bitcoin-secp256k1', git: '[email protected]:cryptape/ruby-bitcoin-secp256k1'
gem 'bluzelle', git: 'https://github.com/bluzelle/blzrb'
  1. Then install:

bundle install
  1. Use:

require "bluzelle"

client = Bluzelle::new_client({
  "address" =>  "...",
  "mnemonic" => "...",
  "uuid" => "bluzelle",
  "endpoint" => "http://dev.testnet.public.bluzelle.com:1317",
})

key = 'foo'
gas_info = {
  'max_fee' => 4000001,
}

client.create key, 'bar', gas_info
value = client.read key
client.update key, 'baz', gas_info
client.delete key, gas_info

Examples

Copy .env.sample to .env and configure if needed.

cp .env.sample .env

Then run the example:

DEBUG=false LIBRESSL_REDIRECT_STUB_ABORT=0 bundle exec ruby examples/crud.rb

Tests

Configure env as described in the examples section above.

bundle exec rspec --format documentation

User Acceptance Testing

Please checkout the UAT.md document for more details.

Abort 6 error

If you encounter this error, you either might have to:

  • Add a new entry to ffi_lib in money-tree/lib/openssl_extensions.rb if using a newer OpenSSL version

  • Specify where your libsecp256k1.dylib is located with the LIBSECP256K1 environment variable.

Licence

MIT

JS

blzjs is a Typescript/JavaScript library that can be used to access the Bluzelle database service.

Installation

yarn add bluzelle
or
npm install bluzelle

There are two versions of the bluzelle library. bluzelle-node.js and bluzelle-js.js. By default the NodeJS version will be used.

To use the NodeJS version

import { bluzele } from 'bluzelle';
or
const { bluzelle } = require('bluzelle');

To use the pure JS version

import { bluzele } from 'bluzelle/lib/bluzelle-js';
or
const { bluzelle } = require('bluzelle/lib/bluzelle-js');

To load additional Typescript definitions

import {bluzelle, API, BluzelleConfig} from 'bluzelle'
import {bluzelle, API, BluzelleConfig} from 'bluzelle/lib/bluzelle-js'
  • API docs

  • Download browser version for <script> tag

  • Examples

  • REPL (interactive console)

Quckstart

Javascript

const {bluzelle} = require('bluzelle');

const config = {
    mnemonic: "apology antique such ancient spend narrow twin banner coral book iron summer west extend toddler walnut left genius exchange globe satisfy shield case rose",
    endpoint: "http://testnet.public.bluzelle.com:1317",
    chain_id: 'bluzelle',
    uuid: Date.now().toString()
};

(async () => {
    const bz = await bluzelle(config);

    await bz.create("somekey", "somevalue", {'gas_price': 10})
    console.log(await bz.read("somekey"))
})();

Typescript

import {bluzelle, API, BluzelleConfig} from 'bluzelle';

const config: BluzelleConfig = {
    mnemonic: "apology antique such ancient spend narrow twin banner coral book iron summer west extend toddler walnut left genius exchange globe satisfy shield case rose",
    endpoint: "http://testnet.public.bluzelle.com:1317",
    chain_id: 'bluzelle',
    uuid: Date.now().toString()
};

(async () => {
    const bz: API = await bluzelle(config);

    await bz.create("somekey", "somevalue", {'gas_price': 10})
    console.log(await bz.read("somekey"))
})();
Build Status
Coverage Status