Overview
Utilities for deriving Kernel v3.3 smart account addresses from EOA owners and accessing ZeroDev Kernel constants.
Functions
deriveKernelAddressV3_3FromEOA
Derives a deterministic Kernel v3.3 smart account address from an EOA (Externally Owned Account) owner address.
function deriveKernelAddressV3_3FromEOA(
owner: Address,
index: bigint
): Address
The EOA address that will own the Kernel smart account
The account index for deriving multiple accounts from the same owner (typically 0n for the first account)
The deterministic Kernel v3.3 smart account address
Example:
import { deriveKernelAddressV3_3FromEOA } from "@/lib/kernel/deriveKernelAddress";
const ownerAddress = "0x1234...";
const kernelAddress = deriveKernelAddressV3_3FromEOA(ownerAddress, 0n);
Implementation Details:
- Uses CREATE2 opcode for deterministic address derivation
- Encodes Kernel v3.3 initialization data with ECDSA validator
- Combines init data with index to create a unique salt
- Computes contract address from factory, bytecode hash, and salt
encodeKernelExecuteCalls
Encodes Kernel v3.3 execute(bytes32 execMode, bytes executionCalldata) for single or batched calls using the ZeroDev SDK.
async function encodeKernelExecuteCalls(
calls: readonly KernelCall[]
): Promise<Hex>
calls
readonly KernelCall[]
required
Array of calls to execute through the Kernel account
Encoded calldata for Kernel.execute() supporting single or batch execution
KernelCall Type:
type KernelCall = {
target: Address;
value?: bigint | undefined;
callData?: Hex | undefined;
};
Example - Single Call:
import { encodeKernelExecuteCalls } from "@/lib/protocols/kernel";
import { encodeErc20Transfer } from "@/lib/protocols/erc20";
const kernelCallData = await encodeKernelExecuteCalls([
{
target: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
callData: encodeErc20Transfer(recipientAddress, 1000000n)
}
]);
Example - Batched Calls (Aave Repay):
import { encodeKernelExecuteCalls } from "@/lib/protocols/kernel";
import { encodeErc20Approve } from "@/lib/protocols/erc20";
import { encodeAaveRepay, MAX_UINT256 } from "@/lib/protocols/aave";
// Batch approve + repay into single UserOperation
const kernelCallData = await encodeKernelExecuteCalls([
{
target: usdcAddress,
callData: encodeErc20Approve(aavePoolAddress, MAX_UINT256)
},
{
target: aavePoolAddress,
callData: encodeAaveRepay({
asset: usdcAddress,
amount: MAX_UINT256,
interestRateMode: 2n,
onBehalfOf: kernelAddress
})
}
]);
Constants
KERNEL_V3_3_FACTORY_ADDRESS
export const KERNEL_V3_3_FACTORY_ADDRESS: Address
The factory contract address used to deploy Kernel v3.3 accounts via CREATE2.
KERNEL_V3_3_IMPLEMENTATION_ADDRESS
export const KERNEL_V3_3_IMPLEMENTATION_ADDRESS: Address
The implementation contract address for Kernel v3.3 accounts (proxy pattern).
KERNEL_V3_3_INIT_CODE_HASH
export const KERNEL_V3_3_INIT_CODE_HASH: Hex
The initialization code hash for Kernel v3.3, used in CREATE2 address derivation.
ECDSA_VALIDATOR_ADDRESS
export const ECDSA_VALIDATOR_ADDRESS: Address
The validator contract address for ECDSA signature validation in Kernel v3.3 accounts. This validator is used as the default SECONDARY validator during account initialization.
Derived from:
- EntryPoint v0.7
- Kernel version v3.3
Type Definitions
Address
type Address = `0x${string}`
Ethereum address format (checksummed hex string).
Hex
Hexadecimal string format.