corda / net.corda.core.contracts / StatePointer


@DoNotImplement sealed class StatePointer<T : ContractState>

A StatePointer contains a pointer to a ContractState. The StatePointer can be included in a ContractState or included in an off-ledger data structure. StatePointers can be resolved to a StateAndRef by performing a vault query. There are two types of pointers; linear and static. LinearPointers are for use with LinearStates. StaticPointers are for use with any type of ContractState.



Determines whether the state pointer should be resolved to a reference input when used in a transaction.

abstract val isResolved: Boolean


An identifier for the ContractState that this StatePointer points to.

abstract val pointer: Any


Type of the state which is being pointed to.

abstract val type: Class<T>



Resolves a StatePointer to a StateAndRef via a vault query. This method will either return a StateAndRef or return an exception.

abstract fun resolve(services: ServiceHub): StateAndRef<T>

Resolves a StatePointer to a StateAndRef from inside a LedgerTransaction. The intuition here is that all of the pointed-to states will be included in the transaction as reference states.

abstract fun resolve(ltx: LedgerTransaction): StateAndRef<T>

Companion Object Functions


Creates a LinearPointer to the specified linear state.

fun <T : LinearState> linearPointer(state: T, isResolved: Boolean = true): LinearPointer<T>


Creates a StaticPointer to the specified contract state.

fun <T : ContractState> staticPointer(stateAndRef: StateAndRef<T>, isResolved: Boolean = false): StaticPointer<T>



LinearPointer allows a ContractState to "point" to another LinearState creating a "many-to-one" relationship between all the states containing the pointer to a particular LinearState and the LinearState being pointed to. Using the LinearPointer is useful when one state depends on the data contained within another state that evolves independently. When using LinearPointer it is worth noting:

class LinearPointer<T : LinearState> : StatePointer<T>


A StaticPointer contains a pointer to a specific StateRef and can be resolved by looking up the StateRef via ServiceHub. There are a number of things to keep in mind when using StaticPointers:

class StaticPointer<T : ContractState> : StatePointer<T>