Giter Club home page Giter Club logo

firma's Introduction

firma

Blockchain focusing on security token issuance and decentralized cap table.

Testing on Ocaml's toplevel

Compile the module interface

$ ocamlc -c merkle.ml     # merkle.cmi

Find and link dependencies, then compile to module object file (.cmo)

$ ocamlfind ocamlc -package cryptokit,yojson -c merkle.ml

Instruction here is awesome for linking libraries.

then load merkle.cmo on Ocaml's toplevel / utop:

#load "merkle.cmo";;
open Merkle;;

example

(** Print out all the tree's nodes *)

tree_of_txs ["A"; "B"; "C"; "D"] |> peek_all ;;

Run JSON API server

Find the root directory where api_server.mlis located, then run:

$ dune build api_server.exe
$ ./_build/default/api_server.exe

If nothing goes wrong, you should see this being printed:

Listening for HTTP on port 8080
Try 'curl http://localhost:8080/merkle?txs=x,y,z'

The API server writes a JSON structure representing a binary Merkle tree created from the input of transactions (txs).

example

Provided transactions A, B, C, and D:

curl http://localhost:8080/merkle?txs=A,B,C,D&debug=true

The JSON string being returned is

{
  "data": {
    "hash": "ABCD",
    "children": [
      {
        "hash": "AB",
        "children": [
          {
            "hash": "A",
            "children": []
          },
          {
            "hash": "B",
            "children": []
          }
        ]
      },
      {
        "hash": "CD",
        "children": [
          {
            "hash": "C",
            "children": []
          },
          {
            "hash": "D",
            "children": []
          }
        ]
      }
    ]
  }
}

Setting debug query parameter to anything other than true or leave empty will default to debug=false and hash strings are returned instead.

JSON with null data will be returned if the number of tx is not a power of two. Read merkle.mli to find out more.

WIP

firma's People

Contributors

jochasinga avatar

Stargazers

 avatar  avatar  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.