IPcl.pclProxy
pclProxy(address proxy) external view returns (PclProxyEntry memory) Returns the on-chain registry entry for a PCL-wrapped proxy address. The PclProxyEntry tuple contains the proxy variant (kind), the currently-bound policy admin (admin), and the registered proxy address (proxy). If proxy is not registered, every field of the returned entry is zero (kind = Unspecified, admin = 0x0, proxy = 0x0) — the call does not revert. The admin field is a projection of the canonical contract-admin record: it is set the moment deployPclProxy runs and is kept in sync when a subsequent changeContractPolicies rotates the admin, so a client reading this view sees the current gatekeeper without a second query to contractPolicies.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
proxy | address | ✓ | The proxy address to look up in the PCL proxy registry. This is the address a user calls when transacting through the regulated path (not the underlying implementation address). |
Returns
PclProxyEntry A tuple of (PclProxyKind kind, address admin, address proxy). kind is one of Unspecified (0), Transparent (1), UUPS (2), Beacon (3), or Diamond (4). admin is the address currently authorized to call changeContractPolicies and removeContractPolicies against this proxy. proxy is the registered proxy address itself, echoed back for convenience when iterating multiple entries client-side. When the address is not registered, all three fields are zero.
Examples
Read a proxy registry entry with viem
The view returns zero-valued fields for unregistered addresses; branch on kind === Unspecified (0) to detect that case rather than catching a revert. The decoded kind byte covers all four live variants, so clients that previously enumerated only three should extend their lookup table to include Diamond (4).
import { createPublicClient, http } from "viem";
import { iPclAbi } from "@maroo-chain/contracts/abi/precompiles/pcl/IPcl";
const PCL = "0x1000000000000000000000000000000000000005" as const;
const client = createPublicClient({ transport: http("https://rpc-testnet.maroo.io") });
// TODO: replace with the real proxy address before production.
const proxyAddress = "0x8f3ac2b1d9e74c05a6b18fe27dc4913e5a0f7b62";
const entry = await client.readContract({
address: PCL,
abi: iPclAbi,
functionName: "pclProxy",
args: [proxyAddress],
});
if (entry.kind === 0) {
console.log("not a registered PCL proxy");
} else {
// PclProxyKind: 0 = Unspecified, 1 = Transparent, 2 = UUPS, 3 = Beacon, 4 = Diamond
const kindName = ["Unspecified", "Transparent", "UUPS", "Beacon", "Diamond"][entry.kind];
console.log(`kind=${kindName} admin=${entry.admin} proxy=${entry.proxy}`);
} Verify the caller of changeContractPolicies is still the registered admin
Because admin mirrors the contract-admin binding, on-chain automation can gate follow-up policy updates on the current admin without a second call to contractPolicies. The check kind != Unspecified accepts every registered variant, so a diamond (PclProxyKind.Diamond) passes the guard just like a Transparent proxy.
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.28;
import { IPcl, PclProxyEntry, PclProxyKind } from "@maroo-chain/contracts/precompiles/pcl/IPcl.sol";
contract AdminGuard {
IPcl constant PCL = IPcl(0x1000000000000000000000000000000000000005);
/// @notice Reverts unless `expectedAdmin` is currently the admin recorded
/// in the PCL proxy registry for `proxy`. Works for every proxy
/// kind (Transparent, UUPS, Beacon, Diamond) because the check is
/// `kind != Unspecified` rather than a fixed-kind comparison.
function requireProxyAdmin(address proxy, address expectedAdmin) external view {
PclProxyEntry memory entry = PCL.pclProxy(proxy);
require(entry.kind != PclProxyKind.Unspecified, "not a registered PCL proxy");
require(entry.admin == expectedAdmin, "admin rotated");
}
}