IPcl.createAddressList
createAddressList() external returns (uint64 listId) Allocates a new shared address list and assigns the caller as its administrator. There is no role check — any account or contract may call it. Returns the nonzero listId, which ALLOW_LIST_POLICY and DENY_LIST_POLICY reference via their listId field. The returned list is created with status Active and empty membership; populate it with updateAddressList before binding a policy that references it. The PCL precompile has no EVM bytecode, so a Solidity high-level call to a precompile function that returns a value still works, but callers that want to reach the registry without knowing the ABI shape must call it low-level and decode the returned uint64.
Parameters
This method has no parameters.
Returns
uint64 The newly allocated list ID. IDs are nonzero, strictly increasing and never reused.
Errors
| Code | Name | Description |
|---|---|---|
InvalidAddressListConfig | InvalidAddressListConfig | Reverts when the caller is the zero address or when the registry's stored ID counter or ID sequence is inconsistent. Encoded as InvalidAddressListConfig(uint64 listId); for allocation failures listId is 0. |
AddressListStorageError | AddressListStorageError | Reverts when the underlying registry store cannot be read or written. Encoded as AddressListStorageError(uint64 listId). Rarely surfaces; indicates a node-level storage fault. |
ABISetupFailed | ABISetupFailed | Inherited from IPrecompile. Reverts when the calldata cannot be decoded against the precompile ABI — typically a stale or mismatched ABI. |
Examples
Create a shared list from TypeScript with viem
writeContract returns a transaction hash; read the allocated listId from the AddressListCreated event (indexed listId, indexed admin). The call itself returns uint64, but on-chain transaction return values are not exposed via JSON-RPC, so events are the correct read path.
import { createWalletClient, createPublicClient, http, parseEventLogs } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { iPclAbi } from "@maroo-chain/contracts/abi/precompiles/pcl/IPcl";
const PCL = "0x1000000000000000000000000000000000000005" as const;
const admin = privateKeyToAccount(process.env.LIST_ADMIN_KEY as `0x${string}`);
const wallet = createWalletClient({
account: admin,
transport: http(process.env.MAROO_RPC_URL),
});
const publicClient = createPublicClient({ transport: http(process.env.MAROO_RPC_URL) });
const hash = await wallet.writeContract({
address: PCL,
abi: iPclAbi,
functionName: "createAddressList",
args: [],
});
const receipt = await publicClient.waitForTransactionReceipt({ hash });
const [created] = parseEventLogs({
abi: iPclAbi,
eventName: "AddressListCreated",
logs: receipt.logs,
});
if (!created) throw new Error("AddressListCreated event not emitted");
const listId = created.args.listId;
console.log("new listId:", listId); Create a shared list from Solidity (low-level)
The contract that calls createAddressList becomes the list's admin, so a factory hands the list to its caller with changeAddressListAdmin before returning. Only the current admin can do that, so the caller could not take it over in a later transaction.
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.28;
import { IPcl } from "@maroo-chain/contracts/precompiles/pcl/IPcl.sol";
contract ListFactory {
address constant PCL = 0x1000000000000000000000000000000000000005;
/// @notice Allocate a new address list, hand its admin to the caller, and return its id.
/// PCL makes THIS contract the admin (it called createAddressList), so the
/// hand-over has to happen here — the caller cannot do it afterwards.
function createList() external returns (uint64 listId) {
// createAddressList returns a value, so a high-level call works on the
// bytecode-less precompile; we keep it low-level here only to show the
// explicit decode. The alternative is: listId = IPcl(PCL).createAddressList();
(bool ok, bytes memory ret) = PCL.call(
abi.encodeCall(IPcl.createAddressList, ())
);
if (!ok) {
assembly { revert(add(ret, 32), mload(ret)) }
}
listId = abi.decode(ret, (uint64));
// changeAddressListAdmin returns nothing → low-level call (PCL has no bytecode).
(ok, ret) = PCL.call(
abi.encodeCall(IPcl.changeAddressListAdmin, (listId, msg.sender))
);
if (!ok) {
assembly { revert(add(ret, 32), mload(ret)) }
}
}
}