This CorDapp shows the end-to-end process of upgrading contracts & state simultaneously in Corda.
The upgrade takes place in four stages:
- Create a replacement contract and state implementing the
UpgradedContract
interface - Bundle the replacement contract and state into a CorDapp and install it on each node
- For each state you wish to upgrade the contract of, authorise the contract and state upgrade for that state on each node
- On a single node, authorise the upgrade for each state you wish to upgrade the contract and state of
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 runUpgradeContractStateClient
- Windows:
gradlew runUpgradeContractStateClient
This will run the contract and state upgrade client defined HERE. 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 and state
- Wait ten seconds for the upgrade to propagate
- Log the state to show that its contract and state has been upgraded
You should see a message of the form:
```I 09:47:54 1 UpgradeContractStateClient.main - TransactionState(data=NewState(a=O=PartyA, L=London, C=GB, b=O=PartyB, L=New York, C=US, value=1), contract=com.upgrade.NewCon
tractAndState, notary=O=Notary, L=London, C=GB, encumbrance=null, constraint=net.corda.core.contracts.WhitelistedByZoneAttachmentConstraint@649b5891)```