encodeTransferOwnership
encodeTransferOwnership
is a static class method on the LightSmartContractAccount
which generates the call data necessary to send a UserOperation
calling transferOwnership
on the connected smart contract account.
Usage
ts
import { smartAccountClient } from "./smartAccountClient";
// encode transfer ownership
const newOwner = LocalAccountSigner.mnemonicToAccountSigner(NEW_OWNER_MNEMONIC);
const encodedTransferOwnershipData =
smartAccountClient.account.encodeTransferOwnership({ newOwner });
ts
import {
createLightAccount,
lightAccountClientActions,
} from "@alchemy/aa-accounts";
import {
LocalAccountSigner,
SmartAccountSigner,
createSmartAccountClient,
polygonMumbai,
} from "@alchemy/aa-core";
import { http } from "viem";
export const chain = polygonMumbai;
export const signer: SmartAccountSigner =
LocalAccountSigner.mnemonicToAccountSigner("YOUR_OWNER_MNEMONIC");
export const rpcTransport = http(
"https://polygon-mumbai.g.alchemy.com/v2/demo"
);
export const smartAccountClient = createSmartAccountClient({
transport: rpcTransport,
chain,
account: await createLightAccount({
transport: rpcTransport,
chain,
signer,
}),
}).extend(lightAccountClientActions);
Returns
Promise<Hex>
A Promise
containing the encoded Hex of thetransferOwnership
function call with the given parameter