Search code examples
rpccorda

Corda view consumed states in terminal


is there an easy way to view the consumed states in the terminal with the CordaRPCOps interface? It seems that vaultQuery returns unconsumed states by default and I can't figure out how to use vaultQueryBy or anything with the criteria.

I know that there should be consumed states because I can see them with H2


Solution

  • Hi you could always write a short API to expose the states:

    there is a sample for /asset in corda existing samples:

    here is a code snippet api for your scenario:

    @GET
    @Path("asset")
    @Produces(MediaType.APPLICATION_JSON)
    fun getAssets(): List<StateAndRef<ContractState>> {
        val consumedCriteria = QueryCriteria.VaultQueryCriteria(Vault.StateStatus.CONSUMED)
        return services.vaultQueryBy<ContractState>(consumedCriteria).states
    }