IPcl.pclProxy

pclProxy(address proxy) external view returns (PclProxyEntry memory)

Returns the registry entry for a proxy that was deployed via deployPclProxy on the PCL precompile. The entry currently carries a single kind field identifying the proxy variant (V1 only registers PclProxyKind.Transparent). If the queried address is not a registered PCL-wrapped proxy, every field of the returned struct is zero — kind decodes to PclProxyKind.Unspecified (enum value 0).

Parameters

Name Type Required Description
proxy address The proxy contract address to look up in the PCL proxy registry.

Returns

Type: PclProxyEntry

A PclProxyEntry struct with a single PclProxyKind kind field. PclProxyKind is an enum with values Unspecified (0) and Transparent (1). Unregistered addresses return an entry whose kind is Unspecified.

Examples

Check whether an address is a registered PCL proxy (viem)

Reads the registry entry for a proxy address. An Unspecified kind (0) means the address is not a PCL-registered proxy.

import { createPublicClient, http } from "viem";

const PCL = "0x1000000000000000000000000000000000000005" as const;

const pclAbi = [{
  name: "pclProxy",
  type: "function",
  stateMutability: "view",
  inputs: [{ name: "proxy", type: "address" }],
  outputs: [{
    type: "tuple",
    components: [
      { name: "kind", type: "uint8" },
    ],
  }],
}] as const;

const publicClient = createPublicClient({ transport: http("https://rpc-testnet.maroo.io") });

// Replace with the deployed proxy address before production use.
const proxyAddress = "0x1111111111111111111111111111111111111111" as const;

const entry = await publicClient.readContract({
  address: PCL,
  abi: pclAbi,
  functionName: "pclProxy",
  args: [proxyAddress],
});

// PclProxyKind: 0 = Unspecified (not registered), 1 = Transparent
if (entry.kind === 0) {
  console.log("not a PCL-wrapped proxy");
} else {
  console.log("kind =", entry.kind);
}

Solidity — gate a code path on PCL proxy registration

Contracts can use pclProxy to enforce that a target address is a chain-recognized PCL-wrapped proxy before routing calls through it.

// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.22;

import { IPcl, PclProxyEntry, PclProxyKind } from "@maroo-chain/contracts/precompiles/pcl/IPcl.sol";

contract PolicyAwareCaller {
    IPcl constant PCL = IPcl(0x1000000000000000000000000000000000000005);

    error NotAPclProxy(address target);

    function requirePclProxy(address target) external view {
        PclProxyEntry memory entry = PCL.pclProxy(target);
        if (entry.kind == PclProxyKind.Unspecified) {
            revert NotAPclProxy(target);
        }
    }
}
ESC
Type to search