Reputation: 93
i created one transaction using . After that i made some changes in code and build and deploy the nodes successfully. I tried to consume previously created data to create new data. But it led to Contract constraints failed error. But i didn’t get any error at the time of creating new data and consuming the same to create another transaction at that instance.
Upvotes: 0
Views: 118
Reputation: 497
TransactionVerificationException.ContractConstraintRejection
This exception is thrown when you have existing states in the vault and you updated the contract code and redeployed.
Every time at the node startup CorDapp Jar are scanned and Jar which has Contract classes are uploaded to attachment storage, and the hash
of the Jar used as Attachment ID
to attach the contract
to a transaction
.
Now, consider, you have a first fresh version of CorDapp - Attachment ID
is: 3B6CA18330500C738455444115C49769D54074CE3CFFB194D8943F34494DB0A4
To create State
on vault, you build the transaction
, Corda auto-attach the contract
using Attachment ID
given above.
Then, consider, you changed the code and re-ployed the CorDapp, now jar hash changed, new Attachment ID
is: F054BA8C1A67BAABF58539F8718B8A62DC770157D9F1D01434B86E73AD2A9217
My finding, when you create any new the transaction, Corda uses new/recent Attachment ID
to attach specified contract
.
For example, You want to update State already present on vault.
a. You created a transaction which has one input and it's output state.
b. You sent this transaction for verification.
c. There is check verifies that
input state
contract
Attachment Id
and currenttransaction
Attachment Id
must be same.d. But right now
input state
pointing to oldAttachment ID
andtransaction
pointing newAttachment ID
. Here check fails and throws aTransactionVerificationException.ContractConstraintRejection
exception.
Upvotes: 1