### Install Smart Contracts Package Source: https://www.alchemy.com/docs/wallets/smart-contracts/other-accounts/light-account/getting-started Install the necessary smart contracts package using either npm or yarn. ```bash npm i @account-kit/smart-contracts ``` ```bash yarn add@account-kit/smart-contracts ``` -------------------------------- ### Get All Owners of Multi-Owner Light Account Source: https://www.alchemy.com/docs/wallets/smart-contracts/other-accounts/light-account/multi-owner-light-account Use the `getOwnerAddresses` method on the `MultiOwnerLightAccount` object accessed via a connected client to retrieve all current owner addresses. ```typescript import { multiOwnerLightAccountClient } from "./client"; const owners = await multiOwnerLightAccountClient.account.getOwnerAddresses(); ``` -------------------------------- ### Create MultiOwnerLightAccount Alchemy Client Source: https://www.alchemy.com/docs/wallets/smart-contracts/other-accounts/light-account/getting-started Initialize a MultiOwnerLightAccount client using the Alchemy transport and sepolia chain. Requires a private key signer. ```typescript import { createMultiOwnerLightAccountAlchemyClient } from "@account-kit/smart-contracts"; import { sepolia, alchemy } from "@account-kit/infra"; import { LocalAccountSigner } from "@aa-sdk/core"; import { generatePrivateKey } from "viem"; const lightAccountClient = await createMultiOwnerLightAccountAlchemyClient({ transport: alchemy({ apiKey: "your-api-key" }) chain: sepolia, signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey()), }); ``` -------------------------------- ### Create LightAccount Alchemy Client Source: https://www.alchemy.com/docs/wallets/smart-contracts/other-accounts/light-account/getting-started Initialize a LightAccount client using the Alchemy transport and sepolia chain. Requires a private key signer. ```typescript import { createLightAccountAlchemyClient } from "@account-kit/smart-contracts"; import { sepolia, alchemy } from "@account-kit/infra"; import { LocalAccountSigner } from "@aa-sdk/core"; import { generatePrivateKey } from "viem"; const lightAccountClient = await createLightAccountAlchemyClient({ transport: alchemy({ apiKey: "your-api-key" }) chain: sepolia, signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey()), }); ``` -------------------------------- ### Transfer Ownership using Client Action Source: https://www.alchemy.com/docs/wallets/smart-contracts/other-accounts/light-account/transfer-ownership-light-account Use this method to transfer ownership of a Light Account via the `transferOwnership` client action. Ensure you have the `lightAccountClient` initialized and the `newOwner` signer. After the transaction is mined, you can create a new client for the transferred account using the new owner's signer. ```typescript import { lightAccountClient } from "./client"; import { createLightAccountClient } from "@account-kit/smart-contracts"; // this will return the signer of the smart account you want to transfer ownerhip to const newOwner = LocalAccountSigner.mnemonicToAccountSigner(NEW_OWNER_MNEMONIC); const accountAddress = lightAccountClient.getAddress(); // [!code focus:99] const hash = lightAccountClient.transferOwnership({ newOwner, waitForTxn: true, }); // after transaction is mined on the network, // create a new light account client for the transferred Light Account const transferredClient = await createLightAccountClient({ transport: custom(smartAccountClient), chain: smartAccountClient.chain, signer: newOwner, accountAddress, // NOTE: you MUST specify the original smart account address to connect using the new owner/signer version: "v2.0.0", // NOTE: if the version of the light account is not v2.0.0, it must be specified here }); ``` -------------------------------- ### Transfer Ownership using sendUserOperation Source: https://www.alchemy.com/docs/wallets/smart-contracts/other-accounts/light-account/transfer-ownership-light-account This method allows direct execution of the ownership transfer by calling `sendUserOperation`. It requires encoding the `transferOwnership` function data and specifying the `accountAddress` as the recipient. Remember to wait for the user operation transaction to be mined. ```typescript import { encodeFunctionData } from "viem"; import { lightAccountClient } from "./client"; // this will return the address of the smart account you want to transfer ownerhip of const accountAddress = lightAccountClient.getAddress(); const newOwner = "0x..."; // the address of the new owner // [!code focus:99] const result = await lightAccountClient.sendUserOperation({ to: accountAddress, data: lightAccountClient.encodeTransferOwnership(newOwner), }); // wait for txn with UO to be mined await lightAccountClient.waitForUserOperationTransaction(result); ``` -------------------------------- ### Add or Remove Owners for Multi-Owner Light Account Source: https://www.alchemy.com/docs/wallets/smart-contracts/other-accounts/light-account/multi-owner-light-account Utilize the `updateOwners` method on the `multiOwnerLightAccountClientActions` extended smart account client to modify the owner list. Specify addresses to add and remove. The method returns an operation hash, which can be used to wait for the transaction to complete. ```typescript import { multiOwnerLightAccountClient } from "./client"; const ownersToAdd = []; // the addresses of owners to be added const ownersToRemove = []; // the addresses of owners to be removed const opHash = await multiOwnerLightAccountClient.updateOwners({ ownersToAdd, ownersToRemove, }); const txHash = await multiOwnerLightAccountClient.waitForUserOperationTransaction({ hash: opHash, }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.