last update

Signed-off-by: Ed Prosser <edward.prosser@r3.com>
This commit is contained in:
Ed Prosser 2019-07-11 11:43:03 +01:00 committed by Mike Hearn
parent 4d0ec9a1a9
commit 903cdba57e
3 changed files with 24 additions and 10 deletions

View File

@ -150,7 +150,7 @@ After creating a state, you must create a contract. Contracts define the rules t
Commands are the operations that can be performed on a state. A contract will often define command logic for several operations that can be performed on the state in question, for example, issuing a state, changing ownership, and marking the state retired. Commands are the operations that can be performed on a state. A contract will often define command logic for several operations that can be performed on the state in question, for example, issuing a state, changing ownership, and marking the state retired.
9. Add ``val command = tx.commands.requireSingleCommand<Commands>()`` at the beginning of the ``verify()`` method. The ``verify()`` method defines the verification rules that commands must satisfy to be valid. 9. Add ``val command = tx.commands.requireSingleCommand<Commands>().value`` at the beginning of the ``verify()`` method. The ``verify()`` method defines the verification rules that commands must satisfy to be valid.
10. The final function of the contract is to prevent unwanted behaviour during the flow. After the ``val command = tx.commands...`` line, add the following requirement code: 10. The final function of the contract is to prevent unwanted behaviour during the flow. After the ``val command = tx.commands...`` line, add the following requirement code:
@ -192,7 +192,7 @@ After creating a state, you must create a contract. Contracts define the rules t
override fun verify(tx: LedgerTransaction) { override fun verify(tx: LedgerTransaction) {
val command = tx.commands.requireSingleCommand<Commands>() val command = tx.commands.requireSingleCommand<Commands>().value
when(command) { when(command) {
is Commands.Issue -> requireThat { is Commands.Issue -> requireThat {
@ -311,7 +311,13 @@ Step Four: Creating a flow
17. Verify the transaction by calling ``verify(serviceHub)`` on the ``TransactionBuilder``. 17. Verify the transaction by calling ``verify(serviceHub)`` on the ``TransactionBuilder``.
18. Sign the transaction and store the result in a variable, using a method found in the `**serviceHub** <./api-service-hub.html>`_. 18. Sign the transaction and store the result in a variable, using the following `serviceHub <./api-service-hub.html>`_ method:
.. container:: codeset
.. sourcecode:: kotlin
val notary = serviceHub.networkMapCache.notaryIdentities.first()
19. Delete the ``progressTracker`` as it won't be used in this tutorial. 19. Delete the ``progressTracker`` as it won't be used in this tutorial.
@ -560,7 +566,11 @@ Now that the CorDapp code has been completed and the build file updated, the Cor
4. To run flows in your CorDapp, enter the following flow command from any non-notary terminal window: 4. To run flows in your CorDapp, enter the following flow command from any non-notary terminal window:
``flow start CarIssueInitiator owningBank: BankofAmerica, holdingDealer: Dealership, manufacturer: Manufacturer, vin: "abc", licensePlateNumber: "abc1234", make: "Honda", model: "Civic", dealershipLocation: "NYC"`` .. container:: codeset
.. sourcecode:: kotlin
``flow start CarIssueInitiator owningBank: BankofAmerica, holdingDealer: Dealership, manufacturer: Manufacturer, vin: "abc", licensePlateNumber: "abc1234", make: "Honda", model: "Civic", dealershipLocation: "NYC"``
5. To check that the state was correctly issued, query the node using the following command: 5. To check that the state was correctly issued, query the node using the following command:

View File

@ -18,12 +18,16 @@ The first step is to deploy the CorDapp to nodes running locally.
To deploy the nodes on Mac or Linux run the following command: ``./gradlew clean deployNodes`` To deploy the nodes on Mac or Linux run the following command: ``./gradlew clean deployNodes``
3. To best understand the deployment process, there are several perspectives it is helpful to see. On Windows run the following command: ``build\nodes\runnodes`` 3. To best understand the deployment process, there are several perspectives it is helpful to see. On Windows run the following command: ``workflows-kotlin\build\nodes\runnodes``
On Mac/Linux run the following command: ``build/nodes/runnodes`` On Mac/Linux run the following command: ``workflows-kotlin/build/nodes/runnodes``
This command opens four terminal windows: the notary, and a node each for PartyA, PartyB, and PartyC. A notary is a validation service that prevents double-spending, enforces timestamping, and may also validate transactions. For more information on notaries, see the `notary documentation <./key-concepts-notaries.html>`_. This command opens four terminal windows: the notary, and a node each for PartyA, PartyB, and PartyC. A notary is a validation service that prevents double-spending, enforces timestamping, and may also validate transactions. For more information on notaries, see the `notary documentation <./key-concepts-notaries.html>`_.
.. note::
Maintain window focus on the node windows, if the nodes fail to load, close them using ``ctrl + d``. The ``runnodes`` script opens each node directory and runs ``java -jar corda.jar``.
4. Go through the tabs to see the perspectives of other network members. 4. Go through the tabs to see the perspectives of other network members.
Step Two: Run a CorDapp transaction Step Two: Run a CorDapp transaction
@ -35,7 +39,7 @@ Step Two: Run a CorDapp transaction
A flow is the mechanism by which a transaction takes place using Corda. This flow creates an instance of the IOU state, which requires an ``iouValue`` property. Flows are contained in CorDapps, and define the mechanisms by which parties transact. For more information on flows, see the `flow documentation <key-concepts-flows.html>`_. A flow is the mechanism by which a transaction takes place using Corda. This flow creates an instance of the IOU state, which requires an ``iouValue`` property. Flows are contained in CorDapps, and define the mechanisms by which parties transact. For more information on flows, see the `flow documentation <key-concepts-flows.html>`_.
3. To check whether PartyB has received the transaction, open the terminal window showing PartyB's perspective, and run the following command: ``run vaultQuery contractStateType:net.corda.example.IOUState`` 3. To check whether PartyB has received the transaction, open the terminal window showing PartyB's perspective, and run the following command: ``run vaultQuery contractStateType: com.example.state.IOUState``
This command displays all of the IOU states in the node's vault. States are immutable objects that represent shared facts between the parties. States serve as the inputs and outputs of transactions. This command displays all of the IOU states in the node's vault. States are immutable objects that represent shared facts between the parties. States serve as the inputs and outputs of transactions.

View File

@ -29,8 +29,8 @@ Step One: Downloading a sample project
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1. Open a command prompt or terminal. 1. Open a command prompt or terminal.
2. Clone the CorDapp example repo by running: ``git clone https://github.com/corda/cordapp-example`` 2. Clone the CorDapp example repo by running: ``git clone https://github.com/corda/samples``
3. Move into the ``cordapp-example`` folder by running: ``cd cordapp-example`` 3. Move into the ``cordapp-example`` folder by running: ``cd samples/cordapp-example``
4. Checkout the corresponding branch by running: ``git checkout release-V4`` in the current directory. 4. Checkout the corresponding branch by running: ``git checkout release-V4`` in the current directory.
@ -41,7 +41,7 @@ Step Two: Creating an IntelliJ project
2. Click **File** > **Project Structure**. To set the project SDK click **New...** > **JDK**, and navigating to the installation directory of your JDK. Click **Apply**. 2. Click **File** > **Project Structure**. To set the project SDK click **New...** > **JDK**, and navigating to the installation directory of your JDK. Click **Apply**.
3. Select **Modules** > **+** > **Import Module**. Select the ``cordapp-example`` folder and click **Open**. Select **Import module from external model** > **Gradle** > **Next** > **Finish** > **Ok**. Gradle will now download all the project dependencies and perform some indexing. 3. Select **Modules** > **+** > **Import Module**. Select the ``cordapp-example`` folder and click **Open**. Select **Import module from external model** > **Gradle** > **Next** > tick the **Use auto-import** checkbox > **Finish** > **Ok**. Gradle will now download all the project dependencies and perform some indexing.
Your CorDapp development environment is now complete. Your CorDapp development environment is now complete.