Coder Social home page Coder Social logo

blockchain-bitcoin-'s Introduction

qfactom

qfactom is a kdb+ wrapper library designed to interact with the Factom blockchain via the factomd client (factomd) and wallet (factom-walletd) REST APIs. The library allows records, in the form of kdb+ tables, lists etc, to be easily secured on the Factom blockchain through the use of simple q function. Entries made to Factom chains can serve as a Proof of Existence, enabling cryptographically secure audit trails to be constructed. Data stored on existing Factom chains, like those used to hold Stock market prices, can also be easily extracted and coverted to kdb+ table format, see example.

Combining the speed and scalability of kdb+, with the security and scalability of Factom, enables millions of records to be secured quickly and safely.

For install and usage instructions see wiki pages.

Functionality

  • Transactions: Both factoid->factoid and factoid->entry credit, see Transactions.
  • Chain creation: Create chains and make entries to those chains, see Creating Chains.
  • Chain extraction: Extract all chain entries given a chain id, see Chain extraction.
  • Receipts: Extract cryptographic proof that chain entries are secured with a single
    hash on the Bitcoin blockchain, see Anchors.
  • Utilities: Check balances, block-height, transaction status, see State information.

Use cases

Prerequisites

  • kdb+ v3.4 or higher
  • qutil - Required if you wish to load the library using qutil. If not, an alternative method is provided. See below.
  • A factomd client and wallet application for the library to communicate with.

Installing

First set the environmental variable QFACTOM_HOME to where you placed the qfactom folder locally.

    $export QFACTOM_HOME=/home/test/library/qfactom/

Prior to loading the q scripts, a shared C library needs to be generated. Navigate to qfactom/lib/clibs/ and run

    $make curlLib        // This library is used to enable TLS support, see below

To load the qfactom library using qutil, follow the steps below.

Create a link named "qfactom" in the QPATH directory which points to qfactom/lib. This will enable .utl.require function to find the init.q file and load all q files. You can confirm the library is loaded correctly by checking that the .factomd and .factomwallet namespaces are present in the q session. Each namespace contains all the supported v2 API calls for the associated application.

    q).utl.require "qfactom"
    q)key `
    `q`Q`h`j`o`util`factomd`factomwallet    // .factomd and .factomwallet namespace loaded

Alternatively, the library can be loaded using the provided factomLoad.q script.

    $q $QFACTOM_HOME/lib/factomLoad.q
    q)key `
    `q`Q`h`j`o`util`factomd`factomwallet   

Configure

Hostnames

By default, qfactom assumes the factomd and factom-walletd applications are running on your localhost server. If they are hosted elsewhere, then run the following commands to change the default

    q).factomd.initHost["http://remotehost:8088/v2"]       // Change factomd host location
    q).factomwallet.initHost["http://remotehost:8089/v2"]  // Change factom-walletd host location

Security: Username and Password

If you are running factomd with username and password enabled, as shown below

    $./factomd -rpcuser <username> -rpcpass <password>

Then run the following command to ensure the authentication credentials are passed during the API calls

    q).factomd.initPass[username;password]

An easy way to confirm that the hostname and authentication credentials are set up correctly, is to execute the .factomd.properties and .factomwallet.properties function which will make a simple request for the version properties.

    q).factomd.properties[{x}]
    jsonrpc| "2.0"
    id     | 0f
    result | `factomdversion`factomdapiversion!("0.4.2.1";"2.0")

    q).factomwallet.properties[{x}]
    jsonrpc| "2.0"
    id     | 0f
    result | `walletversion`walletapiversion!("0.2.2.3";"2.0")

Incorrect username and password credentials will result in an error message being printed to stderr, and a dictionary object with key error being returned.

    q).factomd.properties[{x}]
    Error: illegal char U at 4 .Q.hpfact returned: 401 Unauthorized.

    error| "401 Unauthorized.\n"

Security: TLS Support

When factomd is started with TLS mode enabled, as shown below

    $./factomd -tls=true -selfaddr=domain.net,123.23.111.44

the calling program needs to specify the certificate file generated by factomd, see Security.
To enable TLS support within qfactom, pass the certificate file path to the .factomd.initTLS function.

     q).utl.require "qfactom"
     q).factomd.initTLS["/home/.factom/m2/factomdAPIpub.cert"]
     q).factomd.tlsEnabled   // Check it is enabled
     1b

When TLS is enabled, the .factomd.request function which submits queries to factomd and factom-walletd, will switch to using a C library function instead of the native .Q.hp function.

Tests

qspec tests are currently under construction.
See Test Folder

License

This code is licensed under an MIT license. See LICENSE for the full text.

Contact

Jeremy Lucid
[email protected]
https://github.com/jlucid

blockchain-bitcoin-'s People

Contributors

topdev0706 avatar

Stargazers

Sato Akihiro avatar valk32 avatar Pantom-007 avatar over-light avatar yamamotozunki0815 avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.