Module Registry
Schemas and Resolvers
Schemas allow for flexible attestation data, giving smart account developers and auditors the ability to create attestations in the way that best fits their use case. The Schema Registration function is responsible for registering new schemas in the Module Registry. A schema is composed of an ABI description of data saved in attestations, as well as the schema validator address.
Resolvers are contracts that can be used to enforce custom functionality or permissions on top of the regular Module Registry flows. Every registered Module has an associated Resolver that is triggered during key flows of a Module's lifecycle. For example, a Resolver can be used to enforce a fee on attestations or pay out a bounty on revocation of an attestation.
Schemas
Schema Registration
Schemas can be defined in typical ABI format.
When calling the registerSchema
function on the Module Registry, the following parameters are required:
function registerSchema(
string calldata schema,
ISchemaResolver resolver // OPTIONAL
)
external
returns (bytes32);
After a successful schema registry, the Module Registry will return a unique identifier for the schema. This identifier can be used to reference the schema in future operations.
struct SchemaRecord {
uint48 registeredAt; // The time when the schema was registered (Unix timestamp).
ISchemaValidator validator; // Optional external schema validator.
string schema; // Custom specification of the schema (e.g., an ABI).
}
Schema Validator
The Schema Validator is the contract that is called during attestation in order to determine whether the data of an attestation adheres to the schema. The Schema Validator is an optional component of the Schema Record, and is only required if the Schema Owner wants to enforce validation rules on the data being attested.
Validator Interface
/**
* @title The interface of an optional schema resolver.
*/
interface ISchemaValidator is IERC165 {
/**
* @notice Validates an attestation request.
*/
function validateSchema(AttestationRequestData calldata attestation)
external
view
returns (bool);
/**
* @notice Validates an array of attestation requests.
*/
function validateSchema(AttestationRequestData[] calldata attestations)
external
view
returns (bool);
}
Validator Examples
- SimpleValidator: A simple validator demo.
Resolvers
Resolver Registration
When calling the registerResolver
function on the Module Registry, the following parameters are required:
function registerResolver(
IResolver _resolver // OPTIONAL
)
external
returns (bytes32);
After a successful resolver registry, the Module Registry will return a unique identifier for the schema. This identifier can be used to reference the resolver in future operations.
struct ResolverRecord {
IResolver resolver; // Optional resolver.
address resolverOwner; // The address of the account used to register the resolver.
}
Resolver Contract
The Resolver contract is the contract that is called during key flows of a Module's lifecycle. The Resolver is an optional component of the Module Record, and is only required to enforce custom functionality or permissions on top of the regular Registry flows. These flows are:
- Module Registration
- Attestation
- Revocation
The Registry will call the associated resolver contract during these flows, allowing the resolver to perform any necessary actions. For example, a resolver can be used to enforce a fee on attestations or pay out a bounty on revocation of an attestation.
Resolver Interface
/**
* @title The interface of an optional schema resolver.
* @dev The resolver is responsible for validating the schema and attestation data.
* @dev The resolver is also responsible for processing the attestation and revocation requests.
*
*/
interface IResolver is IERC165 {
/**
* @dev Returns whether the resolver supports ETH transfers.
*/
function isPayable() external pure returns (bool);
/**
* @dev Processes an attestation and verifies whether it's valid.
*
* @param attestation The new attestation.
*
* @return Whether the attestation is valid.
*/
function attest(AttestationRecord calldata attestation) external payable returns (bool);
/**
* @dev Processes a Module Registration
*
* @param module Module registration artefact
*
* @return Whether the registration is valid
*/
function moduleRegistration(ModuleRecord calldata module) external payable returns (bool);
/**
* @dev Processes multiple attestations and verifies whether they are valid.
*
* @param attestations The new attestations.
* @param values Explicit ETH amounts which were sent with each attestation.
*
* @return Whether all the attestations are valid.
*/
function multiAttest(
AttestationRecord[] calldata attestations,
uint256[] calldata values
)
external
payable
returns (bool);
/**
* @dev Processes an attestation revocation and verifies if it can be revoked.
*
* @param attestation The existing attestation to be revoked.
*
* @return Whether the attestation can be revoked.
*/
function revoke(AttestationRecord calldata attestation) external payable returns (bool);
/**
* @dev Processes revocation of multiple attestation and verifies they can be revoked.
*
* @param attestations The existing attestations to be revoked.
* @param values Explicit ETH amounts which were sent with each revocation.
*
* @return Whether the attestations can be revoked.
*/
function multiRevoke(
AttestationRecord[] calldata attestations,
uint256[] calldata values
)
external
payable
returns (bool);
}
Resolver Examples
- TokenizedResolver: A resolver that can be used to enforce an ERC-20 fee on attestations.
- ValueResolver: A resolver that can be used to enforce an ETH fee on attestations.
- DebugResolver: A debug resolver that can be used for testing purposes.