Matthew Layton
Matthew Layton

Reputation: 42260

Corda - Reference States and "current-ness"

The R3 documentation for Reference States states that:

A reference input state is a ContractState which can be referred to in a transaction by the contracts of input and output states but whose contract is not executed as part of the transaction verification process and is not consumed when the transaction is committed to the ledger but is checked for “current-ness”. In other words, the contract logic isn’t run for the referencing transaction only. It’s still a normal state when it occurs in an input or output position.

With regards to checking for "current-ness" does this mean that you can only reference unspent/unconsumed states, or can you also reference spent/consumed states as well?

Upvotes: 1

Views: 459

Answers (1)

Roger Willis
Roger Willis

Reputation: 922

When a transaction containing states in the references list is sent to a notary, the notary will check whether those states (StateRefs) in the references list have been spent. If they have been spent (i.e. they are not current) then the notary will not sign. If they have not been spent (the StateRefs have not been spent), then they are current and the notary will sign the transaction, assuming all inputs (if present) are current and the transaction is notarised within the boundaries of the supplied time window.

You cannot include states which are already known to be spent in the references list. The assumption here is that the data will be stale so cannot be relied upon.

The state pointer feature assumes that you will not be referencing data known to be stale. If you do need to intentionally reference an old state then embed the StateRef directly in your state. You will have to manually ensure that all parties which need the StateRef, have it.

Upvotes: 1

Related Questions