Skip to main content

PolicyRegistry

The PolicyRegistry is an informational on-chain registry of reveal policy contracts. It provides a discovery mechanism for wallets, UIs, and indexers to find available policies. Registration is not required for a policy to function -- any contract implementing IRevealPolicy can be used with commitWithPolicy regardless of registry status.

Deployed address: 0x2DC1641d5A32D6788264690D42710edC843Cb1db

Functions

register

function register(address policy) external

Registers a policy contract in the registry.

Parameters:

NameTypeDescription
policyaddressThe address of the policy contract to register.

Behavior:

  1. Verifies the address contains code (is a contract).
  2. Adds the policy to the internal registry.
  3. Records the registrant (msg.sender) and registration timestamp.

Reverts if:

  • policy is the zero address.
  • policy has no code (is an EOA).
  • policy is already registered.

isRegistered

function isRegistered(address policy) external view returns (bool)

Checks whether a policy address is registered.

Parameters:

NameTypeDescription
policyaddressThe address to check.

Returns:

NameTypeDescription
(unnamed)booltrue if the policy is registered, false otherwise.

getPolicy

function getPolicy(address policy) external view returns (
address registrant,
uint256 registeredAt,
bool active
)

Returns metadata about a registered policy.

Parameters:

NameTypeDescription
policyaddressThe policy address to query.

Returns:

NameTypeDescription
registrantaddressThe address that registered the policy.
registeredAtuint256Block timestamp when the policy was registered.
activeboolWhether the policy is currently active in the registry.

getPolicies

function getPolicies() external view returns (address[] memory)

Returns an array of all registered policy addresses.

Returns:

NameTypeDescription
(unnamed)address[]Array of all registered policy contract addresses.

Storage

struct PolicyInfo {
address registrant;
uint256 registeredAt;
bool active;
}

mapping(address => PolicyInfo) public policies;
address[] public policyList;

Usage Examples

Registering a Custom Policy

// After deploying a custom policy contract
MyCustomPolicy policy = new MyCustomPolicy();

// Register it for discoverability
PolicyRegistry(registryAddress).register(address(policy));

Querying Available Policies

// Get all registered policies
address[] memory allPolicies = PolicyRegistry(registryAddress).getPolicies();

// Check a specific policy
bool registered = PolicyRegistry(registryAddress).isRegistered(policyAddress);

// Get policy details
(address registrant, uint256 registeredAt, bool active) =
PolicyRegistry(registryAddress).getPolicy(policyAddress);

Front-End Integration

const registry = new ethers.Contract(registryAddress, registryABI, provider);

// List all available policies for a UI dropdown
const policies = await registry.getPolicies();
for (const addr of policies) {
const info = await registry.getPolicy(addr);
console.log(`Policy: ${addr}, Registered by: ${info.registrant}, Active: ${info.active}`);
}

Notes

  • The registry is informational only. It does not enforce any behavior in the CommitRevealVault. A policy does not need to be registered to be used with commitWithPolicy.
  • Registration is permissionless. Anyone can register a policy contract. The registrant field provides attribution but does not imply endorsement.
  • The built-in Specter policies (TimelockExpiry, DestinationRestriction, ThresholdWitness) are pre-registered at deployment time.