IPcl.getParams
getParams() external view returns (PclParams memory) 현재 PCL 모듈 파라미터를 PclParams struct로 반환합니다. 체인 전역 정책 관리자 주소와, AA principal 디코딩을 위해 PCL이 신뢰하는 ERC-4337 EntryPoint 컨트랙트 목록을 포함합니다. Solidity 컨트랙트나 오프체인 클라이언트에서 정책 관리자를 하드코딩하지 않고 조회하거나, 계정 추상화 트랜잭션에서 PCL이 인식하는 EntryPoint 주소를 열거할 때 사용합니다.
파라미터
이 메서드는 파라미터가 없습니다.
반환값
PclParams 두 개의 필드를 가진 PclParams struct를 반환합니다. policyAdmin (address)은 정책 템플릿 등록/제거 및 전역 정책 설정 관리 권한을 가진 체인 전역 정책 관리자입니다. entrypoints (address[])는 AA principal 디코딩을 위해 PCL이 신뢰하는 ERC-4337 EntryPoint 컨트랙트 주소 목록입니다. 이 EntryPoint 주소를 대상으로 하는 호출만 AA principal 디코딩 대상이 됩니다.
예제
viem으로 PCL 파라미터 조회
프리컴파일에서 PCL 모듈 파라미터를 직접 조회합니다. 두 필드 모두 dApp에서 유용합니다. policyAdmin은 체인 전역 정책을 변경할 수 있는 주체를 보여주며, entrypoints는 UserOperation 흐름이 인식된 EntryPoint를 대상으로 하는지 확인할 때 사용합니다.
import { createPublicClient, http } from "viem";
const PCL_PRECOMPILE = "0x1000000000000000000000000000000000000005";
const pclParamsAbi = [{
name: "getParams", type: "function", stateMutability: "view",
inputs: [],
outputs: [{
type: "tuple", components: [
{ name: "policyAdmin", type: "address" },
{ name: "entrypoints", type: "address[]" },
],
}],
}] as const;
const client = createPublicClient({ transport: http("https://rpc-testnet.maroo.io") });
const params = await client.readContract({
address: PCL_PRECOMPILE,
abi: pclParamsAbi,
functionName: "getParams",
});
console.log("policyAdmin:", params.policyAdmin);
console.log("entrypoints:", params.entrypoints); Solidity에서 PCL 파라미터 조회
현재 정책 관리자를 조회하고 신뢰되는 EntryPoint 목록에 포함되는지 확인하는 읽기 전용 Solidity 헬퍼입니다. 이 값들은 거버넌스로 변경될 수 있으므로 storage에 캐싱하지 말고 호출 시점에 조회합니다.
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.22;
import { IPcl, PclParams, PCL_CONTRACT } from "@maroo-chain/contracts/precompiles/pcl/IPcl.sol";
contract PolicyAdminReader {
function currentPolicyAdmin() external view returns (address) {
PclParams memory p = PCL_CONTRACT.getParams();
return p.policyAdmin;
}
function isTrustedEntryPoint(address candidate) external view returns (bool) {
PclParams memory p = PCL_CONTRACT.getParams();
for (uint256 i = 0; i < p.entrypoints.length; i++) {
if (p.entrypoints[i] == candidate) return true;
}
return false;
}
}