Skip to content

Commit c407f02

Browse files
Syndicated Lending Sample
1 parent 32b9d19 commit c407f02

File tree

44 files changed

+2160
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2160
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!groovy
2+
/**
3+
* Jenkins pipeline to build the java CorDapp template
4+
*/
5+
6+
/**
7+
* Kill already started job.
8+
* Assume new commit takes precedence and results from previousunfinished builds are not required.
9+
* This feature doesn't play well with disableConcurrentBuilds() option
10+
*/
11+
@Library('corda-shared-build-pipeline-steps')
12+
import static com.r3.build.BuildControl.killAllExistingBuildsForJob
13+
killAllExistingBuildsForJob(env.JOB_NAME, env.BUILD_NUMBER.toInteger())
14+
15+
pipeline {
16+
agent {
17+
label 'eight-cores'
18+
}
19+
options {
20+
ansiColor('xterm')
21+
timestamps()
22+
timeout(3*60) // 3 hours
23+
buildDiscarder(logRotator(daysToKeepStr: '7', artifactDaysToKeepStr: '7'))
24+
}
25+
stages {
26+
stage('Build') {
27+
steps {
28+
sh './gradlew --no-daemon -s clean build test deployNodes'
29+
}
30+
}
31+
}
32+
post {
33+
cleanup {
34+
deleteDir()
35+
}
36+
}
37+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Eclipse, ctags, Mac metadata, log files
2+
.classpath
3+
.project
4+
tags
5+
.DS_Store
6+
*.log
7+
*.log.gz
8+
*.orig
9+
10+
.gradle
11+
12+
# General build files
13+
**/build/*
14+
!docs/build/*
15+
16+
lib/dokka.jar
17+
18+
### JetBrains template
19+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio
20+
21+
*.iml
22+
23+
## Directory-based project format:
24+
#.idea
25+
26+
# if you remove the above rule, at least ignore the following:
27+
28+
# Specific files to avoid churn
29+
.idea/*.xml
30+
.idea/copyright
31+
.idea/jsLibraryMappings.xml
32+
33+
# User-specific stuff:
34+
.idea/tasks.xml
35+
.idea/dictionaries
36+
37+
# Sensitive or high-churn files:
38+
.idea/dataSources.ids
39+
.idea/dataSources.xml
40+
.idea/sqlDataSources.xml
41+
.idea/dynamic.xml
42+
.idea/uiDesigner.xml
43+
44+
# Gradle:
45+
.idea/libraries
46+
47+
# Mongo Explorer plugin:
48+
.idea/mongoSettings.xml
49+
50+
## File-based project format:
51+
*.ipr
52+
*.iws
53+
54+
## Plugin-specific files:
55+
56+
# IntelliJ
57+
/out/
58+
/workflows/out/
59+
/contracts/out/
60+
clients/out/
61+
*/bin/*
62+
63+
# mpeltonen/sbt-idea plugin
64+
.idea_modules/
65+
66+
# JIRA plugin
67+
atlassian-ide-plugin.xml
68+
69+
# Crashlytics plugin (for Android Studio and IntelliJ)
70+
com_crashlytics_export_strings.xml
71+
crashlytics.properties
72+
crashlytics-build.properties
73+
74+
# docs related
75+
docs/virtualenv/
76+
77+
# if you use the installQuasar task
78+
lib
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.eclipse.jdt.core.compiler.codegen.methodParameters=generate
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright 2016, R3 Limited.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<p align="center">
2+
<img src="https://www.corda.net/wp-content/uploads/2016/11/fg005_corda_b.png" alt="Corda" width="500">
3+
</p>
4+
5+
# Syndicated Lending Sample Cordapp
6+
7+
This is a sample Cordapp which demonstrate a high level Syndicated Lending scenario on a Corda network.
8+
9+
Syndicated lending comprises of multiple banks coming together to service the loan requirement of a borrower.
10+
Generally a lead bank is appointed who coordinated the process to forming a syndicate with other participating banks
11+
and agreeing on loan terms.
12+
13+
# Pre-Requisites
14+
15+
See https://docs.corda.net/getting-set-up.html.
16+
17+
# Usage
18+
19+
## Running the CorDapp
20+
21+
Open a terminal and go to the project root directory and type: (to deploy the nodes using bootstrapper)
22+
```
23+
./gradlew clean deployNodes
24+
```
25+
Then type: (to run the nodes)
26+
```
27+
./build/nodes/runnodes
28+
```
29+
30+
## Interacting with the CorDapp
31+
32+
PartyA (as a borrower) starts the `SubmitProjectProposalFlow` in order to submit the project details to a group of
33+
lenders and request for funds.
34+
35+
Go to PartyA's terminal and run the below command
36+
37+
```
38+
start SubmitProjectProposalFlow lenders: [PartyB, PartyC], projectDescription: "Overseas Expansion", projectCost: 10000000, loanAmount: 8000000
39+
```
40+
41+
Validate the project details are crated and shared with the lenders successfully by running the vaultQuery command in each
42+
lender's terminal and borrower's terminal.
43+
44+
```
45+
run vaultQuery contractStateType: net.corda.samples.lending.states.ProjectState
46+
```
47+
48+
Once the lenders have verified the project details and done their due deligence, they could submit bids for loan.
49+
50+
Goto PartyB's terminal and run the below command. The project-id can be found using the vaultQuery command shown earlier.
51+
52+
```
53+
start SubmitLoanBidFlow borrower: PartyA, loanAmount: 8000000, tenure: 5, rateofInterest: 4.0, transactionFees: 20000, projectIdentifier: <project_id>
54+
```
55+
56+
Validate the loanBid is submitted successfully by running the vaultQuery command below:
57+
58+
```
59+
run vaultQuery contractStateType: net.corda.samples.lending.states.LoanBidState
60+
```
61+
62+
Now the borrower can inspect the loan terms and approve the loan bid, to start the syndication process.
63+
64+
Go to PartyA's terminal and run the below command. The loanbid-identifier can be found using the vaultQuery command used earlier.
65+
66+
```
67+
start ApproveLoanBidFlow bidIdentifier: <loanbid-identifier>
68+
```
69+
70+
One the loan bid has been approved by the borrower, the lender can start the process of creating teh syndicate by
71+
acting as the lead bank and approach participating bank for funds.
72+
73+
Goto PartyB's terminal and run the below command.
74+
75+
```
76+
start CreateSyndicateFlow participantBanks: [PartyC, PartyD], projectIdentifier: <project-identifier>, loanDetailIdentifier: <loanbid-identifier>
77+
```
78+
79+
Verify the syndicate is created using the below command:
80+
81+
```
82+
run vaultQuery contractStateType: net.corda.samples.lending.states.SyndicateState
83+
```
84+
85+
On receiving the syndicate creation request, participating banks could verify the project and loan terms and submit
86+
bids for the amount of fund they wish to lend by using the below flow.
87+
88+
```
89+
start SyndicateBidFlow$Initiator syndicateIdentifier: <syndicate-id>, bidAmount: <lending-amount>
90+
```
91+
92+
Verify the syndicate bid is successfully created using the below command:
93+
94+
```
95+
run vaultQuery contractStateType: net.corda.samples.lending.states.SyndicateBidState
96+
```
97+
98+
The lead bank on receiving bids from participating banks could approve the bid using the below flow command.
99+
100+
```
101+
start ApproveSyndicateBidFlow bidIdentifier: <sydicatebid-id>
102+
```
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Corda and the Corda logo are trademarks of R3CEV LLC and its affiliates. All rights reserved.
2+
3+
For R3CEV LLC's trademark and logo usage information, please consult our Trademark Usage Policy at
4+
https://www.r3.com/trademark-policy/.
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
buildscript {//properties that you need to build the project
2+
Properties constants = new Properties()
3+
file("$projectDir/./constants.properties").withInputStream { constants.load(it) }
4+
5+
ext {
6+
corda_release_group = constants.getProperty("cordaReleaseGroup")
7+
corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup")
8+
corda_release_version = constants.getProperty("cordaVersion")
9+
corda_core_release_version = constants.getProperty("cordaCoreVersion")
10+
corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion")
11+
kotlin_version = constants.getProperty("kotlinVersion")
12+
junit_version = constants.getProperty("junitVersion")
13+
quasar_version = constants.getProperty("quasarVersion")
14+
log4j_version = constants.getProperty("log4jVersion")
15+
slf4j_version = constants.getProperty("slf4jVersion")
16+
corda_platform_version = constants.getProperty("platformVersion").toInteger()
17+
//springboot
18+
spring_boot_version = '2.0.2.RELEASE'
19+
spring_boot_gradle_plugin_version = '2.0.2.RELEASE'
20+
}
21+
22+
repositories {
23+
mavenLocal()
24+
mavenCentral()
25+
jcenter()
26+
maven { url 'https://software.r3.com/artifactory/corda-releases' }
27+
}
28+
29+
dependencies {
30+
classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version"
31+
classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version"
32+
classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version"
33+
classpath "org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_gradle_plugin_version"
34+
}
35+
}
36+
37+
allprojects {//Properties that you need to compile your project (The application)
38+
apply from: "${rootProject.projectDir}/repositories.gradle"
39+
apply plugin: 'java'
40+
41+
repositories {
42+
mavenLocal()
43+
jcenter()
44+
mavenCentral()
45+
maven { url 'https://software.r3.com/artifactory/corda' }
46+
maven { url 'https://jitpack.io' }
47+
}
48+
49+
tasks.withType(JavaCompile) {
50+
options.compilerArgs << "-parameters" // Required by Corda's serialisation framework.
51+
}
52+
53+
jar {
54+
// This makes the JAR's SHA-256 hash repeatable.
55+
preserveFileTimestamps = false
56+
reproducibleFileOrder = true
57+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
58+
}
59+
}
60+
61+
apply plugin: 'net.corda.plugins.cordapp'
62+
apply plugin: 'net.corda.plugins.cordformation'
63+
apply plugin: 'net.corda.plugins.quasar-utils'
64+
65+
sourceSets {
66+
main {
67+
resources {
68+
srcDir rootProject.file("config/dev")
69+
}
70+
}
71+
}
72+
//Module dependencis
73+
dependencies {
74+
// Corda dependencies.
75+
cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version"
76+
cordaCompile "$corda_release_group:corda-node-api:$corda_release_version"
77+
cordaRuntime "$corda_release_group:corda:$corda_release_version"
78+
79+
// CorDapp dependencies.
80+
cordapp project(":workflows")
81+
cordapp project(":contracts")
82+
83+
cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}"
84+
cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}"
85+
cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version"
86+
}
87+
88+
89+
//Task to deploy the nodes in order to bootstrap a network
90+
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
91+
92+
/* This property will load the CorDapps to each of the node by default, including the Notary. You can find them
93+
* in the cordapps folder of the node at build/nodes/Notary/cordapps. However, the notary doesn't really understand
94+
* the notion of cordapps. In production, Notary does not need cordapps as well. This is just a short cut to load
95+
* the Corda network bootstrapper.
96+
*/
97+
nodeDefaults {
98+
projectCordapp {
99+
deploy = false
100+
}
101+
cordapp project(':contracts')
102+
cordapp project(':workflows')
103+
runSchemaMigration = true //This configuration is for any CorDapps with custom schema, We will leave this as true to avoid
104+
//problems for developers who are not familiar with Corda. If you are not using custom schemas, you can change
105+
//it to false for quicker project compiling time.
106+
}
107+
node {
108+
name "O=Notary,L=London,C=GB"
109+
notary = [validating : false]
110+
p2pPort 10002
111+
rpcSettings {
112+
address("localhost:10003")
113+
adminAddress("localhost:10043")
114+
}
115+
}
116+
node {
117+
name "O=PartyA,L=London,C=GB"
118+
p2pPort 10005
119+
rpcSettings {
120+
address("localhost:10006")
121+
adminAddress("localhost:10046")
122+
}
123+
rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]]
124+
}
125+
node {
126+
name "O=PartyB,L=New York,C=US"
127+
p2pPort 10008
128+
rpcSettings {
129+
address("localhost:10009")
130+
adminAddress("localhost:10049")
131+
}
132+
rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]]
133+
}
134+
node {
135+
name "O=PartyC,L=New York,C=US"
136+
p2pPort 10011
137+
rpcSettings {
138+
address("localhost:10012")
139+
adminAddress("localhost:10052")
140+
}
141+
rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]]
142+
}
143+
node {
144+
name "O=PartyD,L=New York,C=US"
145+
p2pPort 10014
146+
rpcSettings {
147+
address("localhost:10016")
148+
adminAddress("localhost:10056")
149+
}
150+
rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]]
151+
}
152+
}

0 commit comments

Comments
 (0)