Upgrading Kernel
Kernel, our smart account implementation, receives updates from time to time to keep up with the latest standards and best practices. We do NOT recommend upgrading Kernel accounts unless you NEED TO, since there are many ways to accidentally screw up. But if you do need to upgrade, you can follow the steps here.
The tricky thing about upgrading a smart account is that it affects the deterministic address computation (i.e. CREATE2
), since a Kernel address is partially derived from the smart account implementation. Thankfully, the ZeroDev SDK offers a convenience function for upgrading Kernel accounts without messing up the deterministic address.
API
We currently offer an API for upgrading a ECDSA Kernel account. For other account types, reach out for assistance.
To migrate, replace the code that you used to set up the Kernel validator and account with a single createEcdsaKernelMigrationAccount
function:
import { KERNEL_V3_1, KERNEL_V3_2 } from "@zerodev/sdk/constants"
import { createEcdsaKernelMigrationAccount, signerToEcdsaValidator } from "@zerodev/ecdsa-validator"
import { createKernelAccount } from "@zerodev/sdk";
const originalKernelVersion = KERNEL_V3_1
const migrationVersion = KERNEL_V3_2
const ecdsaValidator = await signerToEcdsaValidator(publicClient, {
signer,
entryPoint,
kernelVersion: originalKernelVersion,
})
const account = await createKernelAccount(publicClient, {
plugins: {
sudo: ecdsaValidator,
},
entryPoint,
kernelVersion,
})
const migrationAccount = await createEcdsaKernelMigrationAccount(publicClient, {
entryPoint,
signer,
migrationVersion: {
from: originalKernelVersion,
to: migrationVersion,
},
})
Then you can use this account to set up a Kernel client as usual:
const migrationKernelClient = createKernelAccountClient({
account: migrationAccount,
// other params...
})