This CorDapp shows the end-to-end process of upgrading contracts in Corda.
The upgrade takes place in four stages:
- Create a replacement contract implementing the
UpgradedContract
interface - Bundle the replacement contract into a CorDapp and install it on each node
- For each state you wish to upgrade the contract of, authorise the contract upgrade for that state on each node
- On a single node, authorise the contract upgrade for each state you wish to upgrade the contract of
In this case, we are only upgrading the contract. It is also possible to upgrade the state only, or both the state and the contract at once.
See https://docs.corda.net/getting-set-up.html.
See https://docs.corda.net/tutorial-cordapp.html#running-the-example-cordapp.
Run the following command from the project's root folder:
- Unix/Mac OSX:
./gradlew runUpgradeContractClient
- Windows:
gradlew runUpgradeContractClient
This will run the contract upgrade client defined here: https://github.com/joeldudleyr3/contract-upgrades/blob/master/cordapp/src/main/kotlin/com/upgrade/Client.kt. This client will:
- Connect to PartyA and PartyB's nodes via RPC
- Issue a state with the old contract
- Upgrade the state to use the new contract
- Wait ten seconds for the contract upgrade to propagate
- Log the state to show that its contract has been upgraded
You should see a message of the form:
```I 17:41:35 1 UpgradeContractClient.main - TransactionState(data=State(a=C=GB,L=London,O=PartyA, b=C=US,L=New
York,O=PartyB), contract=com.upgrade.NewContract, notary=C=GB,L=London,O=Controller,CN=corda.notary.validating,
encumbrance=null, constraint=HashAttachmentConstraint(attachmentId=670BD1385F920D5F87FA9F42FAA2DE86E31F1CAD...))```
- Create an example of upgrading states and their contracts simultaneously
- Create an example of upgrading states but not their contracts