Best of Crypto

Best of Crypto


Examples for the 2019 Derivhack Hackathon


The goal of the ISDA Common Domain Model (CDM) is to allow financial institutions to have a coherent representation of financial instruments and events. This document shows how institutions can use the CDM and the Algorand blockchain to maintain separately owned but coherent financial databases with the following properties:

  1. Coherency: All institutions participating in a trade agree on the digital representation of that trade at any point in time.
  2. Privacy: The details of the trade are only revealed to the institutions which participate in it. Any other agent cannot learn anything about the trade.
  3. Lineage: Any modification in the state of a trade can refer to the previous state, generating a traceable lineage for the history of that trade.
  4. Ease of Use: Because the Algorand blockchain is a permissionless blockchain, institutions can interact with it using the software of their choice, and without the need to set up their own distributed system. Algorand provides easy to use APIs that read to and write from the blockchain, and SDKs in Python, Go, Java and Javascript.

The Algorand Blockchain

The Algorand blockchain can process 1000 transactions per second with a latency of less than 5 seconds and ensures transaction finality with point-of-sale speed. The Algorand blockchain is a permissionless blockchain with hundreds of independently operating nodes distributed around the world. The Algorand blockchain allows developers to create their applications without having to set up their own distributed systems. In addition, Algorand provides extensive documentation, and provides SDKs in four languages (Go, Python, Java and Javascript) to interact with the blockchain.

Figure 1: Nodes running the Algorand client software around the world Figure 1: Nodes running the Algorand client software around the world

Installing, Compiling and Running the Code


Running the code in this repository requires that you have

  1. A Unix-based OS such as Mac OS X or Linux
  2. Java
  3. Maven

Java and Maven Installation


These are bash scripts which install Java and Maven and set the correct paths to use them. These scripts are in the INSTALL folder and should be run in the following order

  1. if the user does not have Hombrew installed (OS X utility to install programs)
  2. if the user does not have Java installed. This installs the OpenJDK
  3. if the user does not have Maven installed
  4. if the user does not have MongoDB installed


These are bash scripts which install Java and Maven and set the correct paths to use them. These scripts are in the INSTALL folder and should be run in the following order

  1. if the user does not have Java installed. This installs the OpenJDK
  2. if the user does not have Maven installed
  3. if the user does not have MongoDB installed

Java library Installation

The main directory contains a pom.xml file which Maven uses to download Java libraries that the code depends on, including the Algorand Java SDK, and the Java implementation of the ISDA CDM.

The code has been tested on a computer running OS X Version 10.14.5, OpenJDK 13, and Maven version 3.6.1. and on an AWS instance ("4.15.0-1044-aws") running Ubuntu 18.04.2 LTS, OpenJDK 11 and Maven version 3.6.0


A settings.xml file is provided in the project root directory, use it install dependencies as below:

mvn -s settings.xml clean install

You can also run


from the root directory.

Running the Code

To run the example code, type


in the root directory.

This script will start a MongoDB service and run the examples for the first three use cases in the hackathon. Ubuntu users need to uncomment the following line to run the mongo service on ubuntu.

##UNCOMMENT THIS LINE FOR UBUNBTU                                                                                                 
# bash 

(OPTIONAL): Starting and Stopping MongoDB

The code needs to have a Mongo DB service running to persist some information. Right now the script starts this service automatically if it is not running. However, we have provided scripts to start and stop this automatically

To run the mongodb service, run


To stop the mongodb service, run


Example Use Cases


In the Derivhack Hackathon, users are given a trade execution file and need to

  1. Load the JSON file into their system
  2. Create users in their distributed ledger corresponding to the parties in the execution
  3. Create a report of the execution

In this example, we use the Algorand blockchain to ensure different parties have consistent versions of the file, while keeping their datastores private. The information stored in the chain includes the global key of the execution, its lineage, and the file path where the user stored the Execution JSON object in their private data store.

The following function, from the class reads a CDM Event, creates Algorand accounts for all parties in the event. It gets the executing party (Client 1's broker), and has this party send details of the execution to all other parties on the Algorand blockchain.

 public  class CommitExecution {

    public static void main(String [] args) throws Exception{
        //Read the input arguments and read them into files
        String fileName = args[0];
        String fileContents = ReadAndWrite.readFile(fileName);

         //Read the event file into a CDM object using the Rosetta object mapper
        ObjectMapper rosettaObjectMapper = RosettaObjectMapper.getDefaultRosettaObjectMapper();
        Event event = rosettaObjectMapper
                .readValue(fileContents, Event.class);
        //Create Algorand Accounts for all parties
        // and persist accounts to filesystem/database
        List<Party> parties = event.getParty();
        User user;
        DB mongoDB = MongoUtils.getDatabase("users");
                .map(party -> User.getOrCreateUser(party,mongoDB))

        //Get the execution
        Execution execution = event

        // Get the executing party  reference
        String executingPartyReference = execution.getPartyRole()
                .filter(r -> r.getRole() == PartyRoleEnum.EXECUTING_ENTITY)
                .map(r -> r.getPartyReference().getGlobalReference())

        // Get the executing party
        Party executingParty = event.getParty().stream()
                .filter(p -> executingPartyReference.equals(p.getMeta().getGlobalKey()))

        // Get all other parties
        List<Party> otherParties =  event.getParty().stream()
                .filter(p -> !executingPartyReference.equals(p.getMeta().getGlobalKey()))

        // Find or create the executing user
        User executingUser = User.getOrCreateUser(executingParty, mongoDB);
        //Send all other parties the contents of the event as a set of blockchain transactions
        List<User> users = otherParties.
                            .map(p -> User.getOrCreateUser(p,mongoDB))

        List<Transaction> transactions = users

The corresponding shell command to execute this function with the Block trades file is

##Commit the execution file to the blockchain
mvn -s settings.xml exec:java -Dexec.mainClass="com.algorand.demo.CommitExecution" \
 -Dexec.args="./Files/UC1_block_execute_BT1.json" -e -q


The second use case for Derivhack is allocation of trades. That is, the block trade execution given in use case 1 will be allocated among multiple accounts. Participants are also given a JSON CDM file specifying the [allocation] ( Since allocations are CDM events, the same logic applies as in the Execution use case. To commit the allocation event to the blockchain, participants can use the following shell command

mvn -s settings.xml exec:java -Dexec.mainClass="com.algorand.demo.CommitAllocation" \
 -Dexec.args="./Files/UC2_allocation_execution_AT1.json" -e -q


The third use case is the affirmation of the trade by the clients. In contrast with the other cases, the Participants can look at the classes ( and ( for examples on how to derive the Affirmation of a trade from its allocation.

In the affirmation step, the client produces a CDM affirmation from the Allocation Event, and sends the affirmation to the broker over the Algorand Chain.

``` class CommitAffirmation {
public static void main(String[] args){

        //Load the database to lookup users
        DB mongoDB = MongoUtils.getDatabase("users");

        //Load a file with client global keys
        String allocationFile = args[0];
        String allocationCDM = ReadAndWrite.readFile(allocationFile);
        ObjectMapper rosettaObjectMapper = RosettaObjectMapper.getDefaultRosettaObjectMapper();
        Event allocationEvent = null;
                allocationEvent = rosettaObjectMapper
                                    .readValue(allocationCDM, Event.class);
            catch( e){
        List<Trade> allocatedTrades = allocationEvent.getPrimitive().getAllocation().get(0).getAfter().getAllocatedTrade();
        //Keep track of the trade index
        int tradeIndex = 0;

        //Collect the affirmation transaction id and broker key in a file
        String result = "";
        //For each trade...
        for(Trade trade: allocatedTrades){

        //Get the broker that we need to send the affirmation to
        String brokerReference = trade.getExecution().getPartyRole()
            .filter(r -> r.getRole() == PartyRoleEnum.EXECUTING_ENTITY)
            .map(r -> r.getPartyReference().getGlobalReference())

            User broker = User.getUser(brokerReference,mongoDB);

        //Get the client reference for that trade
        String clientReference = trade.getExecution()
                                        .filter(r-> r.getRole()==PartyRoleEnum.CLIENT)
        // Load the client user, with algorand passphrase
        User user = User.getUser(clientReference,mongoDB);
        String algorandPassphrase = user.algorandPassphrase;

        // Confirm the user has received the global key of the allocation from the broker
        String receivedKey = AlgorandUtils.readEventTransaction( algorandPassphrase, allocationEvent.getMeta().getGlobalKey());
        assert receivedKey == allocationEvent.getMeta().getGlobalKey() : "Have not received allocation event from broker";
            //Compute the affirmation
            Affirmation affirmation = new AffirmImpl().doEvaluate(allocationEvent,tradeIndex).build();
             //Send the affirmation to the broker
            Transaction transaction = 
                        user.sendAffirmationTransaction(broker, affirmation);
            result += transaction.getTx() + "," + brokerReference +"\n";
            tradeIndex = tradeIndex + 1;
           ReadAndWrite.writeFile("./Files/AffirmationOutputs.txt", result);
        catch(Exception e){


Download Details:
Author: algorand
Source Code:
License: MIT License

#algorand  #blockchain  #cryptocurrency #java 

What is GEEK

Buddha Community

Examples for the 2019 Derivhack Hackathon
Trevor  Russel

Trevor Russel


New Hackathon For Data Scientists — Workation Price Prediction Challenge

MachineHack, in association with Analytics India Magazine, has come up with yet another hackathon for the machine learning community — the Workation Price Prediction Challenge.

In the light of the new normal, different websites have started providing packages to work from different locations. The concept of workation — a portmanteau of work and vacation– is gaining currency. However, it is challenging to find a good place with all the amenities, including high-speed internet and a comfortable stay within the budget.

Thus, to solve the real-world problem of finding the best deals for workations, MachineHack is challenging the machine learning community to build a model for predicting the price per person for workation trips.

To facilitate this, MachineHack has collected workation packages in and around India — starting from Kashmir to Kanyakumari and from Gujarat to Assam. The data has more than 18000+ rows of different packages with details like start location, hotel type, cost per person, destination, itinerary, and many more. Using this dataset, along with the knowledge of machine learning, deep learning, and model building, the participants need to create a model that can efficiently and accurately predict a workation trip’s expense.

#data science hackathon #hackathon #hackathon for data scientists #machine learning hackathon #ml hackathon #predicting workation price #workation price prediction challenge

Edna  Bernhard

Edna Bernhard


Melanoma Tumor Size Prediction: Weekend Hackathon

MachineHack welcomes all Data Science and Machine Learning enthusiasts to another exciting weekend hackathon. This weekend, participants must use their data science skills to predict the melanoma tumor size based on a number of factors.

#featured #datascience hackathons #hackathon #machine learning hackathon #machine learning hackathons

Laravel AJAX CRUD Example Tutorial

Hello Guys,

Today I will show you how to create laravel AJAX CRUD example tutorial. In this tutorial we are implements ajax crud operation in laravel. Also perform insert, update, delete operation using ajax in laravel 6 and also you can use this ajax crud operation in laravel 6, laravel 7. In ajax crud operation we display records in datatable.

Read More : Laravel AJAX CRUD Example Tutorial

Read Also : Read Also : Laravel 6 CRUD Tutorial with Example

#laravel ajax crud example tutorial #ajax crud example in laravel #laravel crud example #laravel crud example with ajax #laravel #php

3 Examples Of Design Applications With Great UX

When it comes to design, it has long been said that simplicity is key. And although I always understood the basis for this saying, I never fully appreciated what it really meant.

As a beginner it is natural to want to show all your ability by wowing your audience. And as a teacher I see my students making this mistake often. They try to build out features as much as possible and try to showcase every aspect of their ability. As many of you know, this approach does not always result in the most aesthetically pleasing design, let alone the most user friendly experience. This is why I have stressed the importance of simplicity to all my students from the first day I started teaching.

For our latest project, I assigned teams of 4 to each create a prototype for a design application.

#design #web-design #hackernoon-top-story #ux #good-ux-design-examples #good-ui-design-examples #web-application-ui-examples #web-application-design-example

Tyshawn  Braun

Tyshawn Braun


Product Sentiment Classification: Weekend Hackathon

We are back with another weekend hackathon and this weekend we are challenging the machinehack community to build an NLP model to analyze sentiments in the product reviews for various electronic products.

Analyzing sentiments related to various products such as Tablet, Mobile and various other gizmos can be fun and difficult especially when collected across various demographics around the world. In this weekend hackathon, we challenge the machinehackers community to develop a machine learning model to accurately classify various products into 4 different classes of sentiments based on the raw text review provided by the user. Analyzing these sentiments will not only help us serve the customers better but can also reveal a lot of customer traits present/hidden in the reviews.

The challenge will start on 4th Sep Friday at 6 pm IST.

Click here to participate

Problem Statement & Description

The sentiment analysis requires a lot to be taken into account mainly due to the preprocessing involved to represent raw text and make them machine-understandable. Usually, we stem and lemmatize the raw information and then represent it using TF-IDF, Word Embeddings, etc. However, provided the state-of-the-art NLP models such as Transformer based BERT models one can skip the manual feature engineering like TF-IDF and Count Vectorizers.

The dataset collected has close to 9000 rows with 4 columns and the reviews are in the form of raw text. The labels for each review are provided with the training labels such as positive, negative, no sentiment, and can’t be said(neutral sentence).

In this short span of time, we would encourage you to leverage the ImageNet moment (Transfer Learning) in NLP using various pre-trained models to classify the product reviews correctly using Multi-class Log Loss as a metric.

Given are raw customer reviews over various types of products with 4 different sentiment classes. Your objective as a data scientist is to build a natural language processing model that can accurately classify the class of sentiments as close as possible.

#hackathons #machine learning hackathon #machinehack hackathon #machine-learing