IAgent.getParams
getParams() external view returns (Params memory) Returns the canonical addresses that the Agent module resolves for this chain — the ERC-8004 identityRegistry and reputationRegistry preinstalls. Call this once at startup so your dApp can locate the registries without hard-coding an address per network. The precompile inherits the shared IPrecompile error surface, so any failure surfaces as a typed error rather than a bespoke one.
Parameters
This method has no parameters.
Returns
tuple A Params struct with two fields: identityRegistry (address of the ERC-8004 IdentityRegistry preinstall) and reputationRegistry (address of the ERC-8004 ReputationRegistry preinstall).
Errors
| Code | Name | Description |
|---|---|---|
InvalidNumberOfArgs | InvalidNumberOfArgs | Reverts when the ABI-decoded argument count does not match the method signature. getParams expects zero arguments; extra ABI-encoded values trigger this. Encoded as InvalidNumberOfArgs(uint256 expected, uint256 got). |
UnknownMethod | UnknownMethod | Reverts when calldata does not match a known method selector on this precompile. Encoded as UnknownMethod(string methodName). |
QueryFailed | QueryFailed | Reverts when the underlying params lookup on the Agent module fails. Encoded as QueryFailed(string queryMethod, string reason). The reason string carries the underlying failure text, mapped through the shared SDK error registry when it corresponds to a known code (e.g. SDKNotFound). |
Examples
Resolve registry addresses at startup
The addresses returned are stable across upgrades of the chain binary — cache them for the lifetime of the process.
import { createPublicClient, http } from "viem";
const AGENT_PRECOMPILE = "0x100000000000000000000000000000000000000A" as const;
const agentAbi = [{
type: "function", name: "getParams", stateMutability: "view",
inputs: [],
outputs: [{
type: "tuple", components: [
{ name: "identityRegistry", type: "address" },
{ name: "reputationRegistry", type: "address" },
],
}],
}] as const;
const publicClient = createPublicClient({ transport: http("https://rpc-testnet.maroo.io") });
const { identityRegistry, reputationRegistry } = await publicClient.readContract({
address: AGENT_PRECOMPILE,
abi: agentAbi,
functionName: "getParams",
});
console.log("IdentityRegistry:", identityRegistry);
console.log("ReputationRegistry:", reputationRegistry); Decoding typed errors from the shared IPrecompile surface
All Agent precompile failures share the IPrecompile error set, so a single ABI covers every revert shape.
import { decodeErrorResult } from "viem";
const iPrecompileAbi = [
{ 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: AGENT_PRECOMPILE, abi: agentAbi, functionName: "getParams" });
} catch (err: any) {
if (err?.data) {
const decoded = decodeErrorResult({ abi: iPrecompileAbi, data: err.data });
console.error("getParams reverted:", decoded.errorName, decoded.args);
} else {
throw err;
}
}