Skip to main content

Registry Pallet

pallet-pilier-registry is the chain's directory: it holds projects, decides which project may write under which company registration number, keeps code registries (short-number-to-string lookup tables such as country or category codes), holds passport schemas, and holds storage endpoints (the common part of an address a company's evidence files are found at). Both the Passport Pallet and the Documents Pallet ask this pallet, through the RegistryAccess trait, whether a caller is allowed to write and whether a referenced schema or storage endpoint exists; neither reads this pallet's storage directly.

Projects​

A project is an account (its owner) plus, optionally, other accounts allowed to write on its behalf (writers) — the owner is always implicitly a writer.

  • create_project(owner) — creates a project, returning the next ProjectId. Restricted to the council (AdminOrigin); an ordinary account cannot create a project for itself.
  • set_project_writers(project_id, writers) — replaces the project's writer list. Callable by the project's own owner.

Reading registry.projects(projectId) returns { owner, writers }.

Company registration numbers — the write-access list​

grant_registration_number(project_id, company_registration_number) and revoke_registration_number(company_registration_number) are what actually control who may write a passport or register a file under a given company name: a registration number maps to at most one project at a time (registry.companyPermissions(companyRegistrationNumber) returns that project's id, or nothing), granting it is exclusive, and revoking it removes the entry entirely. Both calls are restricted to the council. This is the entire mechanism behind the "who can write" sections on the Passport Pallet and Documents Pallet pages: today, exactly one registration number is granted, to Validité.

Schemas​

register_schema(category, version, description) stores a schema's full description on chain (so a passport stays readable even if the company that wrote its schema no longer exists), and a fingerprint — the hash of description, computed at registration time as an integrity check only, never the sole record of the schema. Reading registry.schemas(schemaId) returns { category, version, description, fingerprint }. category is an application-defined classifier this pallet does not interpret further — category 0 is the convention the Passport Pallet page's worked example uses.

Code registries​

A code registry is a short-number-to-string lookup table (for example, a list of country codes or product categories), plus which project may add entries to it:

  • create_registry_type(name, writer_project) — creates a registry, restricted to the council.
  • add_registry_entry(registry_type_id, value) — adds the next entry, callable by the registry's own writer_project.
  • deprecate_registry_entry(registry_type_id, entry_id) — marks an entry deprecated. An entry is never deleted, so a passport that already cites its number still resolves.

Reading registry.registryTypes(registryTypeId) returns { name, writer_project, next_entry_id }; registry.registryEntries(registryTypeId, entryId) returns { value, deprecated }.

Storage endpoints​

A storage endpoint is the common part of the address a company's evidence files are found at, addressed by the company registration number currently holding the right to write under it.

  • create_storage_endpoint(company_registration_number, address) — creates an endpoint, callable by a member of the project the registration number is granted to.
  • update_storage_endpoint_address(storage_endpoint_id, new_address) — changes an existing endpoint's address.

Reading registry.storageEndpoints(storageEndpointId) returns { companyRegistrationNumber, address }. Only the latest address is kept: a passport's proof is the file's own fingerprint (see the Documents Pallet page), not this address, so this pallet accepts that a company whose registration number's grant has since moved on leaves its past addresses only in this pallet's event log.

Worked example​

The worked example on the Passport Pallet and Documents Pallet pages uses project 3 (owner is the same account that created it), registration number DOCS-EXAMPLE-0001, schema 2 (category 0, version 1), and storage endpoint 2 (address https://example.invalid/passport-docs-example/). Reading any of these back:

const { ApiPromise, WsProvider } = require('@polkadot/api');

async function main() {
const api = await ApiPromise.create({ provider: new WsProvider('wss://rpc.pilier.dev') });
console.log('project:', (await api.query.registry.projects(3)).toHuman());
console.log('permission:', (await api.query.registry.companyPermissions('DOCS-EXAMPLE-0001')).toHuman());
console.log('schema:', (await api.query.registry.schemas(2)).toHuman());
console.log('storage endpoint:', (await api.query.registry.storageEndpoints(2)).toHuman());
await api.disconnect();
}

main().catch(console.error);