IEas.getParams

getParams() external view returns (EasParams memory params)

이 체인의 표준 Ethereum Attestation Service 주소를 반환합니다. 반환값은 schemaRegistry, eas, indexer preinstall 주소입니다. 네트워크별로 주소를 하드코딩하는 대신 런타임에 해석하도록 시작 시점에 호출합니다. 이 프리컴파일은 공유 IPrecompile 오류 인터페이스를 상속합니다. 인자 형태 오류는 타입 지정 오류로 revert되지만, keeper가 초기화되지 않은 경우에는 여전히 평문 문자열 "eas keeper is not initialized"로 revert됩니다.

파라미터

이 메서드는 파라미터가 없습니다.

반환값

타입: tuple

세 필드를 가진 EasParams 구조체를 반환합니다. schemaRegistry, eas, indexer는 각각 이 체인의 표준 EAS 배포 주소입니다.

에러

코드 이름 설명
InvalidNumberOfArgs InvalidNumberOfArgs 공유 IPrecompile 오류 집합에 InvalidNumberOfArgs(uint256 expected, uint256 got)로 선언되어 있지만, getParams는 이 오류로 revert되지 않습니다. 인자를 받지 않으며, selector 뒤에 붙은 바이트는 무시됩니다.
ABISetupFailed ABISetupFailed calldata를 프리컴파일 ABI로 디코딩할 수 없을 때 revert됩니다. 예를 들어 오래된 ABI의 알 수 없는 4바이트 selector이면 사유가 no method with id: 0x…입니다. ABISetupFailed(string reason) 형태로 인코딩됩니다. 프리컴파일에 UnknownMethod도 선언되어 있지만, 알 수 없는 selector는 이 오류로 revert되지 않습니다.
QueryFailed QueryFailed 내부 x/eas 파라미터 조회가 실패할 때 revert됩니다. QueryFailed(string queryMethod, string reason) 형태로 인코딩되며, 해당하는 경우 공유 SDK 오류 레지스트리를 거쳐 정규화됩니다.
eas keeper is not initialized eas keeper is not initialized 프리컴파일의 easKeeper 참조가 시작 시점에 연결되지 않은 경우에만 발생합니다. 타입 지정 오류가 없으며, 이유는 Solidity Error(string) 형태로 ABI 인코딩됩니다. 따라서 decodeErrorResult는 이를 errorName: "Error"로 반환하고 이유는 args[0]에 담깁니다.

예제

시작 시점에 EAS 주소 해석

반환된 세 주소는 체인마다 안정적이므로 프로세스 수명 동안 캐시해도 됩니다.

import { createPublicClient, http } from "viem";

const EAS_PRECOMPILE = "0x1000000000000000000000000000000000000009" as const;
const easPrecompileAbi = [{
  type: "function", name: "getParams", stateMutability: "view",
  inputs: [],
  outputs: [{
    type: "tuple", components: [
      { name: "schemaRegistry", type: "address" },
      { name: "eas",            type: "address" },
      { name: "indexer",        type: "address" },
    ],
  }],
}] as const;

const publicClient = createPublicClient({ transport: http("https://rpc-testnet.maroo.io") });
const { schemaRegistry, eas, indexer } = await publicClient.readContract({
  address: EAS_PRECOMPILE,
  abi: easPrecompileAbi,
  functionName: "getParams",
});

공유 IPrecompile 오류와 평문 문자열 revert 디코드

타입 지정 IPrecompile 오류는 decodeErrorResult로 디코드되며, keeper 미초기화 같은 평문 이유도 마찬가지입니다. 이 이유는 Solidity Error(string) 형태로 도착하므로 errorName: "Error"로 디코드됩니다. ABI에 없는 revert는 다시 던집니다.

import { BaseError, ContractFunctionRevertedError, decodeErrorResult } from "viem";

const iPrecompileErrorsAbi = [
  { type: "error", name: "InvalidNumberOfArgs",
    inputs: [{ name: "expected", type: "uint256" }, { name: "got", type: "uint256" }] },
  { type: "error", name: "ABISetupFailed", inputs: [{ name: "reason", type: "string" }] },
  { type: "error", name: "QueryFailed",
    inputs: [{ name: "queryMethod", type: "string" }, { name: "reason", type: "string" }] },
] as const;

try {
  await publicClient.readContract({
    address: EAS_PRECOMPILE,
    abi: easPrecompileAbi,
    functionName: "getParams",
  });
} catch (err) {
  // viem keeps the revert data on the ContractFunctionRevertedError in the cause chain, not on err.
  const revert = err instanceof BaseError ? err.walk((e) => e instanceof ContractFunctionRevertedError) : null;
  if (!(revert instanceof ContractFunctionRevertedError) || !revert.raw) throw err;
  try {
    // decodeErrorResult also knows Solidity's Error(string), so a plain reason
    // (e.g. "eas keeper is not initialized") decodes as errorName "Error".
    const decoded = decodeErrorResult({ abi: iPrecompileErrorsAbi, data: revert.raw });
    console.error("getParams reverted:", decoded.errorName, decoded.args);
  } catch {
    throw err; // a revert this ABI does not describe
  }
}
ESC
검색어를 입력하세요