βοΈConfiguration
Each application instantiates its own DWN with its own protocol. This protocol can be configured to suit the needs of the application.
Protocol definition
The protocol definition is an object where you can define the protocol's name, the schemas needed for your application, and the permissions for those schemas. Altogether, it looks like this:
The
protocol
property defines the name of the protocol for your application. It should be consistent across the application.
Schemas
The
types
property is where you can define all of the schemas needed for your application.Each property defined in the
types
object is the name of a schema for your application.The
schema
property is the name of the protocol and the name of the schema with a/
between them.The
dataFormats
property defines what types of data this schema can be.
Permissions
The
structure
property allows you to define the permissions for your schemas.There should be a corresponding property defined in the
structure
object for every schema.$actions
is an array of objects that define the permissions for the schema.
Protocol definition example
Let's assume that we're building a simple file storage application called Store. We would need to configure our protocol to include a schema for documents. That could look like this:
{
"protocol": "http://message-protocol.xyz",
"published": true,
"types": {
"message": {
"schema": "http://message-protocol.xyz/schema/message",
"dataFormats": [
"text/plain"
]
}
},
"structure": {
"message": {
"$actions": [
{
"who": "anyone",
"can": "write"
},
{
"who": "anyone",
"can": "read"
}
]
}
}
}
Using the protocol definition
One your protocol has been defined, it should be added to the DWN when a DID is initialized. See the initialization page for a full example.