How to manage ownership of a Multi-Owner Light Account
A Multi-Owner Light Acocunt has one or more ECDSA or SCA owners. This lets your account integrate with multiple signers at once, and supports recovering your account if one signer is lost.
The Multi-Owner Light Account is able to:
- Update (add or remove) owners for an account.
- Show all owners of an account.
- Validate signed signatures of ERC-4337 enabled user operations as well as regular transactions.
When you connect your Multi-Owner Light Account to SmartAccountClient
you can extend the client with multiOwnerLightAccountClientActions
, which exposes a set of methods available to call the Multi-Owner Light Account with the client connected to the account.
Note
When using createMultiOwnerLightAccountAlchemyClient
in @alchemy/aa-alchemy
, the SmartAccountClient
comes automatically extended with multiOwnerLightAccountClientActions
as defaults available for use.
1. Get all current owners of a Multi-Owner Light Account
You can use the getOwnerAddresses
method on the MultiOwnerLightAccount
object, which can be accessed from a connected client.
import { smartAccountClient } from "./smartAccountClient";
const owners = await smartContractClient.account.getOwnerAddresses();
<<< @/snippets/aa-alchemy/multi-owner-light-account-client.ts [smartAccountClient.ts]
2. Add or remove owners for a Multi-Owner Light Account
You can use the updateOwners
method on the multiOwnerLightAccountClientActions
extended smart account client to add or remove owners from the Multi-Owner Light Account.
import { lightAccountClient } from "./multiOwnerLIghtAcocuntClient";
import { multiOwnerPluginActions } from "@alchemy/aa-accounts";
import { type Address } from "viem";
const ownersToAdd: Address[] = []; // the addresses of owners to be added
const ownersToRemove: Address[] = []; // the addresses of owners to be removed
const opHash = await lightAccountClient.updateOwners({
ownersToAdd,
ownersToRemove,
});
const txHash = await lightAccountClient.waitForUserOperationTransaction({ hash: opHash });
import { createMultiOwnerLightAccountAlchemyClient } from "@alchemy/aa-alchemy";
import { LocalAccountSigner, sepolia } from "@alchemy/aa-core";
export const lightAccountClient =
await createMultiOwnerLightAccountAlchemyClient({
apiKey: "YOUR_API_KEY",
chain: sepolia,
signer: LocalAccountSigner.mnemonicToAccountSigner("OWNER_MNEMONIC"),
// Additional initial owners can be listed here.
owners: [],
});