IPcl.updateAddressList

updateAddressList(
  uint64 listId,
  address[] calldata add,
  address[] calldata remove
) external

Adds and/or removes members of an existing shared address list in a single atomic batch. Only the current list admin may call this; every other sender reverts with Unauthorized. Idempotent per address: re-adding an existing member or removing a non-member is a no-op and does not revert, but the add and remove arrays together must contain no duplicate addresses and must not both be empty. The call emits AddressListMembersAdded and/or AddressListMembersRemoved carrying only the addresses whose membership actually changed. A call that changes nothing (every add address is already a member and every remove address is not) succeeds without emitting either event, so confirm the call from the receipt status, not from an event. A policy bound to this list reflects the new membership on its next evaluation.

Parameters

Name Type Required Description
listId uint64 ✓ The target list's nonzero ID returned by createAddressList. An unknown ID reverts with AddressListNotFound(listId); ID 0 with InvalidAddressListConfig(0).
add address[] ✓ Addresses to add to the list. May be empty, provided remove is non-empty.
remove address[] ✓ Addresses to remove from the list. May be empty, provided add is non-empty. An address appearing in both add and remove is rejected as a duplicate.

Returns

Type: void

No return value. Observe AddressListMembersAdded / AddressListMembersRemoved events for the actual deltas — a call that changed nothing emits neither.

Errors

Code Name Description
Unauthorized Unauthorized Reverts when msg.sender is not the current admin of listId. Rotate the admin with changeAddressListAdmin before calling from a new address.
AddressListNotFound AddressListNotFound Reverts when no list with that ID exists (ID 0 reverts with InvalidAddressListConfig instead). Encoded as AddressListNotFound(uint64 listId).
InvalidParameter InvalidParameter Reverts when both arrays are empty, or when the same address appears more than once across add and remove. Carried as the chain-side empty or duplicate address list batch condition.
InvalidAddressListConfig InvalidAddressListConfig Reverts when the registry's stored metadata for the list fails integrity checks. Encoded as InvalidAddressListConfig(uint64 listId).
AddressListStorageError AddressListStorageError Reverts when the underlying registry store cannot be read or written. Encoded as AddressListStorageError(uint64 listId).
ABISetupFailed ABISetupFailed Inherited from IPrecompile. Reverts when calldata cannot be decoded against the precompile ABI.

Examples

Add two addresses and remove one from TypeScript

A single transaction applies the delta atomically; a policy that references listId sees the new membership on its next evaluation.

import { createWalletClient, http } 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),
});

// TODO: replace with the real list id returned by createAddressList.
const listId = 12n;
// TODO: replace with the real addresses before production.
const toAdd = [
  "0x8f3ac2b1d9e74c05a6b18fe27dc4913e5a0f7b62",
  "0x3a9c71e4b8d2f6a05c7e19b4d3f82a6c5e0b9d47",
] as const;
const toRemove = [
  "0x5ab7c1e40b8da46f9c7e29d3fa614e97b8f0ac21",
] as const;

await wallet.writeContract({
  address: PCL,
  abi: iPclAbi,
  functionName: "updateAddressList",
  args: [listId, toAdd, toRemove],
});

Call low-level from Solidity

A high-level IPcl(PCL).updateAddressList(...) call reverts with empty data because the precompile has no bytecode (solc checks code size for functions that return nothing). Use the same low-level pattern for every PCL method that returns nothing, such as changeAddressListAdmin and setAddressListStatus; createAddressList returns the new listId, so it keeps the normal call syntax.

// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.28;

import { IPcl } from "@maroo-chain/contracts/precompiles/pcl/IPcl.sol";

contract ListUpdater {
    address constant PCL = 0x1000000000000000000000000000000000000005;
    address public immutable owner;

    error NotOwner();

    constructor() { owner = msg.sender; }

    /// @dev This contract is the list's admin, so PCL checks THIS contract, not its caller —
    ///      without the owner check anyone could change the list through it.
    modifier onlyOwner() {
        if (msg.sender != owner) revert NotOwner();
        _;
    }

    /// @notice The PCL precompile has no EVM bytecode, so solc's extcodesize
    ///         check reverts a high-level call to a function that returns
    ///         nothing. Route updateAddressList through a low-level call and
    ///         bubble the revert data on failure.
    function addMembers(uint64 listId, address[] calldata toAdd) external onlyOwner {
        address[] memory toRemove = new address[](0);
        (bool ok, bytes memory ret) = PCL.call(
            abi.encodeCall(IPcl.updateAddressList, (listId, toAdd, toRemove))
        );
        if (!ok) {
            assembly { revert(add(ret, 32), mload(ret)) }
        }
    }
}
ESC
Type to search