Git Product home page Git Product logo

bootcamp-cordapp's Introduction

Corda

Bootcamp CorDapp

This project is the template we will use as a basis for developing a complete CorDapp during today's bootcamp. Our CorDapp will allow the issuance of tokens onto the ledger.

We'll develop the CorDapp using a test-driven approach. At each stage, you'll know your CorDapp is working once it passes both sets of tests defined in src/test/java/bootcamp.

Set up

  1. Download and install a JDK 8 JVM (minimum supported version 8u131)

  2. Download and install IntelliJ Community Edition (supported versions: prior than 2021)

  3. Download the bootcamp-cordapp repository:

    git clone https://github.com/corda/bootcamp-cordapp
    
  4. Open IntelliJ load the project

What we'll be building

Our CorDapp will have three parts:

The TokenState

States define shared facts on the ledger. Our state, TokenState, will define a token. It will have the following structure:

-------------------
|                 |
|   TokenState    |
|                 |
|   - issuer      |
|   - owner       |
|   - amount      |
|                 |
-------------------

The TokenContract

Contracts govern how states evolve over time. Our contract, TokenContract, will define how TokenStates evolve. It will only allow the following type of TokenState transaction:

-------------------------------------------------------------------------------------
|                                                                                   |
|    - - - - - - - - - -                                     -------------------    |
|                                              ▲             |                 |    |
|    |                 |                       | -►          |   TokenState    |    |
|            NO             -------------------     -►       |                 |    |
|    |                 |    |      Issue command       -►    |   - issuer      |    |
|          INPUTS           |     signed by issuer     -►    |   - owner       |    |
|    |                 |    -------------------     -►       |   - amount > 0  |    |
|                                              | -►          |                 |    |
|    - - - - - - - - - -                       ▼             -------------------    |
|                                                                                   |
-------------------------------------------------------------------------------------

          No inputs             One issue command,                One output,
                             issuer is a required signer       amount is positive

To do so, TokenContract will impose the following constraints on transactions involving TokenStates:

  • The transaction has no input states
  • The transaction has one output state
  • The transaction has one command
  • The output state is a TokenState
  • The output state has a positive amount
  • The command is an Issue command
  • The command lists the TokenState's issuer as a required signer

The TokenIssueFlow

Flows automate the process of updating the ledger. Our flow, TokenIssueFlow, will automate the following steps:

        Issuer                  Owner                  Notary
          |                       |                       |
   Chooses a notary
          |                       |                       |
    Starts building
     a transaction                |                       |
          |
    Adds the output               |                       |
      TokenState
          |                       |                       |
       Adds the
     Issue command                |                       |
          |
     Verifies the                 |                       |
      transaction
          |                       |                       |
      Signs the
     transaction                  |                       |
          |
          |----------------------------------------------►|
          |                       |                       |
                                                     Notarises the
          |                       |                   transaction
                                                          |
          |◀----------------------------------------------|
          |                       |                       |
     Records the
     transaction                  |                       |
          |
          |----------------------►|                       |
                                  |
          |                  Records the                  |
                             transaction
          |                       |                       |
          ▼                       ▼                       ▼

Running our CorDapp

Normally, you'd interact with a CorDapp via a client or webserver. So we can focus on our CorDapp, we'll be running it via the node shell instead.

Once you've finished the CorDapp's code, run it with the following steps:

  • Build a test network of nodes by opening a terminal window at the root of your project and running the following command:

    • Windows: gradlew.bat deployNodes
    • Linux/Mac: ./gradlew deployNodes
  • Start the nodes by running the following command:

    • Windows: build\nodes\runnodes.bat
    • Linux/Mac: ./build/nodes/runnodes
  • Build and Start the nodes using docker:

    • Windows: gradlew.bat prepareDockerNodes
    • Linux/Mac: ./gradlew prepareDockerNodes
    • ACCEPT_LICENSE=Y | docker-compose -f ./build/nodes/docker-compose.yml up
  • Open the nodes are started, go to the terminal of Party A (not the notary!) and run the following command to issue 99 tokens to Party B:

    flow start TokenIssueFlowInitiator owner: PartyB, amount: 99

  • You can now see the tokens in the vaults of Party A and Party B (but not Party C!) by running the following command in their respective terminals:

    run vaultQuery contractStateType: com.bootcamp.states.TokenState

bootcamp-cordapp's People

Contributors

anixon604 avatar ashutoshmeher-r3 avatar chrischabot avatar davidawad avatar florian-f avatar freyarhianna avatar ja9-look avatar olliegilbey avatar peterli-r3 avatar zkiss avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bootcamp-cordapp's Issues

Offline Use Is Misleading

The section in the README "Updating for offline use" is redundant.

Once you have run the project once all your dependencies will be cached locally by gradle anyway.

This section is misleading and redundant and should be removed.

You should also remove the following lines in the build.gradle

https://github.com/corda/bootcamp-cordapp/blob/v4/build.gradle#L16
flatDir { dirs "lib/dependencies" }

https://github.com/corda/bootcamp-cordapp/blob/v4/build.gradle#L20
classpath fileTree(dir: 'lib/dependencies', include: '*.jar')

https://github.com/corda/bootcamp-cordapp/blob/v4/build.gradle#L35
flatDir { dirs "${project.rootProject.projectDir}/lib/dependencies" }

https://github.com/corda/bootcamp-cordapp/blob/v4/build.gradle#L66
compileClasspath fileTree(dir: 'lib/dependencies', include: '*.jar')

https://github.com/corda/bootcamp-cordapp/blob/v4/build.gradle#L131-L139

task gatherDependencies(type: Copy) {
    into "lib/dependencies"
    from buildscript.configurations.classpath
    from configurations.runtime
    from configurations.compile
    from configurations.testCompile
    from configurations.testRuntime
    from configurations.quasar
}

Warning:Class 'ProjectImportedOKTest' not found in module 'bootcamp-cordapp-4'

Sorry to bother you....I really encounter trouble.
In the begining, when I want to run ProjectImportedOKTest, the intellJ idea will tell me:
2019-08-30 20-04-49 的屏幕截图

next, I choose
Use classpath of module:bootcamp-cordapp-4
JRE to be 1.8,
like the next picture, however, the intellJ idea will still tell me:

Warning:Class 'ProjectImportedOkTest' not found in module 'bootcamp-cordapp-4'
If I choose the other options, the intellJ idea will still warn me, could you tell me how to solve it?
2019-08-30 20-10-09 的屏幕截图
sorry to bother, not only I'm a beginner of corda, but also one of java.

build.gradle Needs Cleaning Up

Feel free to split this out into lots of smaller issues.

Referring to the v4 branch.

The wrong version of corda is specified:

corda_release_version = '4.0-SNAPSHOT'
corda_gradle_plugins_version = '4.0.37'

There are unnecessary repos.

mavenLocal() is only useful for R3 developers using snapshots.

flatDir { dirs "lib/dependencies" } is completely unnecessary see #6 for further details

This whole section should be removed
https://github.com/corda/bootcamp-cordapp/blob/v4/build.gradle#L52-L63

sourceSets {
    main {
        resources {
            srcDir "../config/dev"
        }
    }
    test {
        resources {
            srcDir "../config/test"
        }
    }
}

In this particular case there is only one module so you don't need it anyway.

In the general case it causes circular dependencies in IDEs and confusion with users as evidenced on Slack.
The only purpose of it is to not duplicate logging config.

https://github.com/corda/bootcamp-cordapp/blob/v4/build.gradle#L83
deployNodesJava can just be deployNodes like the kotlin project.

https://github.com/corda/bootcamp-cordapp/blob/v4/build.gradle#L84
directory "./build/nodes" is the default so doesn't need to be specified.

https://github.com/corda/bootcamp-cordapp/blob/v4/build.gradle#L90
"$project.group:cordapp:$project.version" the project name is not cordapp

There is no gradle.properties specifying the project group, name, version.

There is no need to repeat the cordapp[] section in each node when you could do:

    nodeDefaults {
        projectCordapp {
            deploy = true
        }
    }

Why are there no rpc settings for the notary?

☠ The piece of art was not found in ArtFlowInitiator Project

Hi

I am facing the issue in calling the Art project code.

start ArtFlowInitiator title: isha, artist: PartyA, newOwner: PartyB

 Error says this

`[ERROR] 15:15:10+0530 [Node thread-1] proxies.ExceptionSerialisingRpcOpsProxy.log - Error during RPC invocation [errorCode=1j2bz3l, moreInformationAt=https://errors.corda.net/OS/4.0/1j2bz3l] {actor_id=internalShell, actor_owning_identity=O=Notary, L=London, C=GB, actor_store_id=NODE_CONFIG, fiber-id=10000001, flow-id=ebeb4248-260d-4af3-9cda-06a579efc8ab, invocation_id=5eede5df-7c2e-44f9-b4d5-b2446cfe01d8, invocation_timestamp=2019-03-27T09:45:09.482Z, origin=internalShell, session_id=99f38c9a-cfee-4f1e-b324-2baafb0c9b63, session_timestamp=2019-03-27T09:42:57.390Z, thread-id=140}
[ERROR] 15:15:10+0530 [Node thread-1] proxies.ExceptionSerialisingRpcOpsProxy.log - Error during RPC invocation [errorCode=1j2bz3l, moreInformationAt=https://errors.corda.net/OS/4.0/1j2bz3l] {actor_id=internalShell, actor_owning_identity=O=Notary, L=London, C=GB, actor_store_id=NODE_CONFIG, fiber-id=10000001, flow-id=ebeb4248-260d-4af3-9cda-06a579efc8ab, invocation_id=5eede5df-7c2e-44f9-b4d5-b2446cfe01d8, invocation_timestamp=2019-03-27T09:45:09.482Z, origin=internalShell, session_id=99f38c9a-cfee-4f1e-b324-2baafb0c9b63, session_timestamp=2019-03-27T09:42:57.390Z, thread-id=140}
[ERROR] 15:15:10+0530 [Node thread-1] proxies.ExceptionSerialisingRpcOpsProxy.log - Error during RPC invocation [errorCode=1j2bz3l, moreInformationAt=https://errors.corda.net/OS/4.0/1j2bz3l] {actor_id=internalShell, actor_owning_identity=O=Notary, L=London, C=GB, actor_store_id=NODE_CONFIG, fiber-id=10000001, flow-id=ebeb4248-260d-4af3-9cda-06a579efc8ab, invocation_id=5eede5df-7c2e-44f9-b4d5-b2446cfe01d8, invocation_timestamp=2019-03-27T09:45:09.482Z, origin=internalShell, session_id=99f38c9a-cfee-4f1e-b324-2baafb0c9b63, session_timestamp=2019-03-27T09:42:57.390Z, thread-id=140}
[ERROR] 15:15:10+0530 [Node thread-1] proxies.ExceptionSerialisingRpcOpsProxy.log - Error during RPC invocation [errorCode=1j2bz3l, moreInformationAt=https://errors.corda.net/OS/4.0/1j2bz3l] {actor_id=internalShell, actor_owning_identity=O=Notary, L=London, C=GB, actor_store_id=NODE_CONFIG, fiber-id=10000001, flow-id=ebeb4248-260d-4af3-9cda-06a579efc8ab, invocation_id=5eede5df-7c2e-44f9-b4d5-b2446cfe01d8, invocation_timestamp=2019-03-27T09:45:09.482Z, origin=internalShell, session_id=99f38c9a-cfee-4f1e-b324-2baafb0c9b63, session_timestamp=2019-03-27T09:42:57.390Z, thread-id=140}
[ERROR] 15:15:10+0530 [Node thread-1] proxies.ExceptionSerialisingRpcOpsProxy.log - Error during RPC invocation [errorCode=1j2bz3l, moreInformationAt=https://errors.corda.net/OS/4.0/1j2bz3l] {actor_id=internalShell, actor_owning_identity=O=Notary, L=London, C=GB, actor_store_id=NODE_CONFIG, fiber-id=10000001, flow-id=ebeb4248-260d-4af3-9cda-06a579efc8ab, invocation_id=5eede5df-7c2e-44f9-b4d5-b2446cfe01d8, invocation_timestamp=2019-03-27T09:45:09.482Z, origin=internalShell, session_id=99f38c9a-cfee-4f1e-b324-2baafb0c9b63, session_timestamp=2019-03-27T09:42:57.390Z, thread-id=140}
[ERROR] 15:15:10+0530 [Node thread-1] proxies.ExceptionSerialisingRpcOpsProxy.log - Error during RPC invocation [errorCode=1j2bz3l, moreInformationAt=https://errors.corda.net/OS/4.0/1j2bz3l] {actor_id=internalShell, actor_owning_identity=O=Notary, L=London, C=GB, actor_store_id=NODE_CONFIG, fiber-id=10000001, flow-id=ebeb4248-260d-4af3-9cda-06a579efc8ab, invocation_id=5eede5df-7c2e-44f9-b4d5-b2446cfe01d8, invocation_timestamp=2019-03-27T09:45:09.482Z, origin=internalShell, session_id=99f38c9a-cfee-4f1e-b324-2baafb0c9b63, session_timestamp=2019-03-27T09:42:57.390Z, thread-id=140}
[ERROR] 15:15:10+0530 [Node thread-1] proxies.ExceptionSerialisingRpcOpsProxy.log - Error during RPC invocation [errorCode=1j2bz3l, moreInformationAt=https://errors.corda.net/OS/4.0/1j2bz3l] {actor_id=internalShell, actor_owning_identity=O=Notary, L=London, C=GB, actor_store_id=NODE_CONFIG, fiber-id=10000001, flow-id=ebeb4248-260d-4af3-9cda-06a579efc8ab, invocation_id=5eede5df-7c2e-44f9-b4d5-b2446cfe01d8, invocation_timestamp=2019-03-27T09:45:09.482Z, origin=internalShell, session_id=99f38c9a-cfee-4f1e-b324-2baafb0c9b63, session_timestamp=2019-03-27T09:42:57.390Z, thread-id=140}

➡️ Starting
🚫 Done
☠ The piece of art was not found.
`

Can you please help me with the issue.

Unable to generate CorDapp jar from local project

Hi, I was following the bootcamp videos and on video 17 Corda Bootcamp 17 - Flows Exercises I ran into this error why running FlowTests.

I did try to edit configurations as the video suggests, but still the same error (which is different than the error presented in the video).
Also worth noting that I only get the same error after adding the configuration if I try to run an individual test. If I try to run the entire class, I get the message "Test events were not received".

Any idea on what might be the reason?

minor bootcamp repo readme issues following 15/8/2019 bootcamp

It would be convenient if the web resources links were clickable. e.g.
"Key Concepts docs (docs.corda.net/key-concepts.html)"

In "Running our CorDapp" the deployNodes gradle target is wrong
says:
macOS: ./gradlew deployNodesJava
should be:
macOS: ./gradlew deployNodes

possibly same for windows - can't comment :)

bootcamp.TokenState is not a net.corda.core.contracts.ContractState

I am using JDK 1.8 version and following all the README.md steps.
On running the nodes, pop up windows come for Notary, PartyA, PartyB and PartyC properly.

Terminal for PartyA - trying to issue the amount to PartyC

Fri Jun 12 11:13:47 IST 2020>>> start TokenIssueFlowInitiator owner: PartyC, amount: 1000
Starting

Terminal for PartyC - trying to check the vault of PartyC

Fri Jun 12 11:16:17 IST 2020>>> run vaultQuery contractStateType: bootcamp.TokenState
RPC failed: net.corda.core.CordaRuntimeException: java.lang.IllegalArgumentException: bootcamp.TokenState is not a net.corda.core.contracts.ContractState

This error is actually coming for all the nodes.

TokenState.java - This file has TokenState implementing ContractState

@BelongsToContract(TokenContract.class)
public class TokenState implements ContractState {
    private final Party issuer;
    private final Party owner;
    private final int amount;
    private final List<AbstractParty> participants;

    public TokenState(Party issuer, Party owner, int amount){
        this.issuer = issuer;
        this.owner = owner;
        this.amount = amount;
        this.participants = new ArrayList<>();
        participants.add(issuer);
        participants.add(owner);
    }

    @NotNull
    @Override
    public List<AbstractParty> getParticipants() {
        return Arrays.asList(issuer, owner);
    }

    public Party getIssuer() {
        return issuer;
    }

    public Party getOwner() {
        return owner;
    }

    public int getAmount() {
        return amount;
    }
}

What could be the issue here?

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.