Fetching archived contracts to be displayed in the UI

Hi all,

I’d like to ask if there is an existing best practice when fetching archived contracts to be displayed in a React App UI, which is currently using the HTTP JSON API to fetch the active contracts from the ledger.

Thanks in advance!

2 Likes

Hi Matheus, and welcome to the forums!

A good practice to follow here is that everything that should be displayed in your app (and is therefore relevant to the business logic in some way) should be represented with an active contract on the ledger. Your application should always only depend on the active contract set. If you, for example, need to display history or prior revisions of some data that a user might have the option to revert to, you could use an explicit History contract to represent that.

Following this guideline is also beneficial for portability, when you eventually want to migrate from one ledger infrastructure to another (eg from Postgres to Corda). There a data migration has to take place that typically doesn’t consider archived contracts. Depending only on the active contract set means that your app will continue to function as is on the new ledger infrastructure and you’re not loosing any relevant data.

Archived contracts can only be retrieved from the full transaction stream on the gRPC API, and this is fairly expensive since you have to traverse the ledger from genesis. It’s really mostly intended for “forensic” purposes, for example, if you have to provide an audit trail for a particular contract to verify its provenance.

Hope this helps!

5 Likes

Hi Georg,

Makes sense, thanks for the reply!