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 | ABI 디코딩된 인자 개수가 0이 아닐 때 revert됩니다. InvalidNumberOfArgs(uint256 expected, uint256 got) 형태로 인코딩됩니다. |
UnknownMethod | UnknownMethod | calldata가 이 프리컴파일에서 인식하는 메서드 selector와 일치하지 않을 때 revert됩니다. UnknownMethod(string methodName) 형태로 인코딩됩니다. |
QueryFailed | QueryFailed | 내부 x/eas 파라미터 조회가 실패할 때 revert됩니다. QueryFailed(string queryMethod, string reason) 형태로 인코딩되며, 해당하는 경우 공유 SDK 오류 레지스트리를 거쳐 정규화됩니다. |
eas keeper is not initialized | eas keeper is not initialized | 프리컴파일의 easKeeper 참조가 아직 연결되지 않았을 때 반환되는 평문 문자열 revert입니다. 타입 지정 커스텀 오류가 아니므로 decodeErrorResult가 아니라 UTF-8 문자열로 디코드합니다. |
예제
시작 시점에 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 미초기화 상황은 여전히 UTF-8 문자열로 도착하므로 타입 디코딩이 실패하면 문자열 디코딩으로 대체합니다.
import { decodeErrorResult, hexToString } from "viem";
const iPrecompileErrorsAbi = [
{ type: "error", name: "InvalidNumberOfArgs",
inputs: [{ name: "expected", type: "uint256" }, { name: "got", type: "uint256" }] },
{ type: "error", name: "UnknownMethod", inputs: [{ name: "methodName", 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: any) {
if (err?.data) {
try {
const decoded = decodeErrorResult({ abi: iPrecompileErrorsAbi, data: err.data });
console.error("getParams reverted:", decoded.errorName, decoded.args);
} catch {
// Plain-string revert (e.g. "eas keeper is not initialized").
console.error("getParams reverted with string:", hexToString(err.data));
}
} else {
throw err;
}
}