Interfaces in Ceramic Protocol: Intro Guide

The Ceramic Protocol and Interfaces

The Ceramic protocol has expanded ComposeDB's capabilities with a new feature called Interfaces (introduced in ComposeDB v0.6.0). Interfaces are important for setting standards in data models.

Interfaces also constitute another step toward real data composability, which is the ability to easily combine and recombine data from various sources to create new datasets or insights.

This article explains Interfaces, why they're useful, and how they're implemented in ComposeDB.

What are Interfaces?

Interfaces are like a blueprint for data models. They define a set of fields that any type or model must include to be compliant with the Interface. This approach ensures that different models, though unique, maintain a level of standardization and interoperability.

In ComposeDB, Interfaces help create a common ground for diverse data models.

For a simplified example, you could have an Interface Vehicle that represents any kind of vehicle in a transportation system.


Copy

This means that any type that implements Vehicle must have these specific fields.

Here are some types that might implement Vehicle:


Copy

You'll notice that both of these types possess all the fields from the Vehicle Interface, but they also feature additional fields: passengerCapacity, vehicleType, wingspan, and airline, that are unique to that specific kind of vehicle.

Interfaces are particularly useful when you wish to return an object or a collection of objects, and these objects could represent several different types.

Benefits of Interfaces in ComposeDB

Interfaces in ComposeDB offer several advantages:

Interface Implementation Example

An excellent example of Interfaces in action within Ceramic is the verifiable credentials Interface. This Interface example standardizes the structure for decentralized identity systems.

It establishes a standard set of fields for all credential models, ensuring consistency across applications. At the same time, it allows you to add whatever additional fields you need for your own application.


Copy

This snippet shows how an Interface (VerifiableCredential) is defined and how a specific type (VerifiableCredentialEIP712) implements it. This snippet is from our Verifiable Credentials example app and you can see more on GitHub.

This example of the verifiable credentials Interface standardizes the basic structure for credentials in decentralized identity systems. By doing so, it facilitates various applications in creating, exchanging, and interpreting credentials in a consistent and reliable way.

Conclusion

Interfaces are crucial in the Ceramic protocol for helping decentralized applications work together. As managing data in a decentralized way becomes more common, knowing and using Interfaces will become more important.