testnet
GitHub

PCL Precompile

compliance external-dapp

Manage on-chain compliance policies directly from your smart contracts.

The Programmable Compliance Layer (PCL) Precompile is a special-purpose smart contract at a fixed address that serves as the bridge between the EVM and Maroo's native compliance engine. It allows developers to programmatically define, update, and enforce regulatory and business rules for their dApps using standard Solidity tooling. This eliminates the need for off-chain oracles for compliance checks and embeds rule enforcement directly into the transaction lifecycle.

Key Features

On-Chain Policy Management

Register, read, update, and remove compliance policies for any smart contract, directly from another authorized smart contract.

Dual-Track Transaction Model

Utilize the `runOnPcl` function to execute transactions within a regulated context, ensuring all relevant global and contract-specific policies are checked before execution.

Extensible Policy Templates

System administrators can register new types of compliance checks (Policy Templates) which can then be configured and used by any contract on the network.

EVM Native Interface

Interact with the entire PCL system using a standard Solidity interface (`IPcl.sol`), complete with custom errors and events for robust dApp development.

Architecture

graph TD
    subgraph EVM Space
        A[DApp / User] -- EVM Call --> B{Your Smart Contract};
        B -- `runOnPcl(target, data, value)` --> C[PCL Precompile @ 0x10...05];
    end

    subgraph Maroo Native Layer
        D[x/pcl Cosmos SDK Module];
        E[Policy Storage];
        F[Compliance Logic];
    end

    C -- Native Bridge --> D;
    D -- Reads --> E[Policy Storage];
    D -- Executes --> F[Compliance Logic];
    F -- Pass/Fail --> D;
    D -- Result --> C;
    C -- Returns / Reverts --> B;
    B -- `(bool success, bytes memory result) = target.call(data)` --> G{Execute Original Call};
    G -- Returns --> B;
    B -- Returns --> A;

A user's call to a compliant smart contract is intercepted and forwarded to the PCL Precompile. The precompile bridges the call to the native x/pcl module, which loads relevant policies and executes compliance logic. If the checks pass, control is returned to the EVM to execute the original intended call.

How It Works

The PCL Precompile acts as a singleton contract accessible to all other contracts on the Maroo network. It exposes functions that directly map to the capabilities of the underlying x/pcl Cosmos SDK module. When a developer wants to make a contract compliant, they don't add the logic to the contract itself. Instead, they register policies against that contract's address using the precompile.

The core of the enforcement mechanism is the runOnPcl function. Instead of a user or contract directly calling a function on a regulated contract (e.g., myToken.transfer(...)), they call pcl.runOnPcl(myToken, encodedTransfer, ...) instead. This function first triggers the native PCL module to perform all necessary checks based on the policies registered for myToken. These checks can include verifying the sender's KYC status, checking against denylists, or enforcing transfer volume limits. If and only if all checks pass, the PCL precompile then uses a low-level EVM call to execute the original, encoded transfer function. If any check fails, the entire transaction reverts with a descriptive custom error.
Note: The PCL Precompile address is `0x1000000000000000000000000000000000000005`. An easy-to-use interface constant `PCL_CONTRACT` is available in `IPcl.sol`.

Global vs. Contract Policies

The PCL supports two levels of policy configuration. Global Policies are set by the network's policy administrator and apply to all transactions on the network, providing a baseline level of compliance. Contract Policies are specific to a single contract address and are managed by a designated admin for that contract. When a transaction is checked via runOnPcl, both global and contract-specific policies are evaluated. This layered approach allows for network-wide safety nets while giving individual dApp developers the flexibility to define their own specific rules.

Next Steps

Source: maroo
ESC
Type to search