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 | Declared in the shared IPrecompile error set as InvalidNumberOfArgs(uint256 expected, uint256 got), but getParams does not revert with it: it takes no arguments, and bytes after the selector are ignored. |
ABISetupFailed | ABISetupFailed | Reverts when the calldata cannot be decoded against the precompile's ABI, for example an unknown 4-byte selector from a stale ABI, which gives the reason no method with id: 0x…. Encoded as ABISetupFailed(string reason). An unknown selector does not revert with UnknownMethod, although the precompile declares it. |
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 { BaseError, ContractFunctionRevertedError, decodeErrorResult } from "viem";
const iPrecompileAbi = [
{ 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: AGENT_PRECOMPILE, abi: agentAbi, 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) {
const decoded = decodeErrorResult({ abi: iPrecompileAbi, data: revert.raw });
console.error("getParams reverted:", decoded.errorName, decoded.args);
} else {
throw err;
}
}