Deprecation notice
Consortium networks have been deprecated. This guide is for historical reference.Overview
Ticket scalping for popular events has been a problem even in the pre-Internet era; however, with the digital technology becoming ubiquitous, scalping looked like a solved problem for a brief moment—it made sense too, the tickets became digital and available through websites, and all one had to do was enter their credit card details online and click Buy. This brief period of fair distribution lasted mostly during the dawn of the Internet. What happened later and is still happening today is that the ticket scalping returned at a much grander scale—something that the pre-Internet speculators could only dream of. Today ticket scalping is run through automated scalping bots, there are even claims of insider scalping, and some well-known media like Pitchfork just putting it bluntly that scalping won’t go away. What this tutorial offers is a very basic CorDapp on the Corda blockchain platform to give an idea and a steer in the direction of how the scalping problem can be solved. In this tutorial you will:- Build a CorDapp.
- Upload the CorDapp to your Corda nodes.
- Connect to the nodes in shell and run the CorDapp.
- Build and run a webserver that connects to your Corda node and interacts with the CorDapp.
Get the CorDapp without building
If you want to just try out the CorDapp, you can download the latest contract and workflow versions and skip this tutorial to the Install the CorDapp section.Prerequisites
- Clone the CorDapp repository to your machine.
- Set up your CorDapp development environment. See Corda docs: Set-up instructions.
noScalpDapp
Each CorDapp has the following components: noScalpDapp is no exception and has the components written in Kotlin:- noScalpFlow.kt — the CorDapp flow that starts sessions between the nodes and builds and verifies the ticket distribution transactions.
- noScalpContract.kt — the CorDapp contract for the ticket distribution transaction
- noScalpState.kt — the CorDapp state that creates an on-ledger fact that can be retrieved by the nodes participating in the transaction.
noScalpFlow
, noScalpContract
, and noScalpState
has comments explaining the what and how, so do check them.
Prepare a Corda network
Create a consortium project
See Create a project.Deploy a Corda network
See Deploy a consortium network.Add a second node to your Corda network
For this tutorial, you need at least two nodes. See Add a node to a network.Get your Corda node access and credentials
See View node access details.Build and install noScalpDapp
Build the JAR files
Thebuild.gradle
script in root comes with the JAR instructions to build the CorDapp:
- Contract:
/contracts/build/libs/
- Workflow:
/workflows/build/libs
Install the CorDapp
See Installing a CorDapp. Install the CorDapp on at least two nodes.Interact with the CorDapp through shell
See Interaction tools. To check if noScalpDapp has loaded successfully, run in the shell:- NAME — any event name that you are distributing the tickets to.
- QUANTITY — the number of tickets you are distributing.
- LEGAL_NAME — the legal name of the node you are distributing the tickets to. This cannot be the same node you are currently connected to. To get the node’s legal name, see View node access details.
ND-123-456-789
:
totalStatesAvailable: -1
. This is a known Corda issue.
Build and run the noScalpDapp webserver and client
Before you start
Once you have your Corda network with noScalpDapp running, you can start a webserver to interact with the nodes. The webserver is a Spring Boot implementation. For a general webserver implementation, see Interaction tools: Using Spring Boot webserver. For this tutorial, the webserver implementation is in theclients
directory of the CorDapp repository that you cloned at the start of the tutorial.
Components:
-
Backend:
- MainController.kt — the main component that does POST and GET mappings and calls noScalpState.kt.
- NodeRPCConnection.kt — the standard Corda RPC wrapper that uses the CordaRPCClient and CordaRPCConnection classes.
- Server.kt — a Spring Boot application with JacksonSupport
-
Frontend:
- index.html — calls angular-module.js
- angular-module.js — calls MainController.kt for GET and POST mappings
Configure the webserver
To be able to connect to your Corda node, you must configure the webserver with the connection details. The webserver connection details are inclients/build.gradle
under task runDistributor
:
- SERVER_PORT — your Spring Boot server instance port
- CORDA_RPC_HOSTNAME — your Corda node RPC hostname
- CORDA_RPC_PORT — your Corda node RPC port
- CORDA_RPC_USER — your Corda node RPC username
- CORDA_RPC_PASSWORD — your Corda node RPC password
localhost:50005
and connect it to node ND-123-456-789
.
Build and run the webserver
In the project root, run:runDistributor
task specified in clients/build.gradle
, start the server, and connect the server to to your node.
The task progress for the webserver start printed in the output will never reach 100% completion. You can access the webserver at around 95%.
Interact with the node through webserver
Interact via user interface or via API endpoints.User interface
Connect tolocalhost:50005
in your browser. This will show the legal name of the node you are connected to and the Distribute tickets button.
- Click Distribute tickets.
- In the To distrubutor field, choose the node to distribute the tickets to. This will pick up all your peer nodes in your Corda network. Make sure that the node you select is also running the noScalpDapp.
- Provide Ticket quantity and Event name.
- Click Create distribution.
API endpoints
The GET requests are defined via@GetMapping
in MainController.kt.
The POST requests are defined via @PostMapping
in MainController.kt.
A GET request example to see the legal name of the node the webserver is connected to: