Skip to content

Two docs examples don't match the current SDK (TypeScript tutorial, ERC-20 gas page) #101

Open

Description

@EchoPrism44

Hi, I was working through the docs and found two code examples that don't work with the
current packages. Both are small fixes. I checked them against @zerodev/sdk 5.5.12,
@zerodev/ecdsa-validator 5.4.9 and viem 2.58.0.

  1. ERC-20 gas page: chain is a number, then used as a chain object

File: docs/pages/smart-accounts/pay-gas-with-erc20s.mdx, line 38

// use whatever chain you want
const chain = mainnet.id

chain is then passed to createZeroDevPaymasterClient({ chain, ... }), which expects a
chain object, and read as chain.id on lines 50, 64, 79 and 113
(gasTokenAddresses[chain.id]['USDC']). Since chain is already the number 1,
chain.id is undefined, so the token lookup crashes:

TypeError: Cannot read properties of undefined (reading 'USDC')

Suggested fix:

// use whatever chain you want
const chain = mainnet

With that one change, the lookup returns the USDC address as expected.

  1. TypeScript tutorial: kernelVersion is missing

File: docs/pages/get-started/sdks/client-side/typescript.mdx, lines 83 and 100

const ecdsaValidator = await signerToEcdsaValidator(publicClient, {
  signer,
  entryPoint,
})

const account = await createKernelAccount(publicClient, {
  plugins: {
    sudo: ecdsaValidator,
  },
  entryPoint,
})

Both functions now require kernelVersion. As written, signerToEcdsaValidator throws:

Error: KernelVersion should be >= 0.2.2 and <= 0.2.4 for EntryPointV0.6 and >= 0.3.0 for EntryPointV0.7

The quickstart page (docs/pages/get-started/quickstart.mdx) already passes it, so the
tutorial just needs to match:

import { KERNEL_V3_1 } from "@zerodev/sdk/constants"

const kernelVersion = KERNEL_V3_1

const ecdsaValidator = await signerToEcdsaValidator(publicClient, {
  signer,
  entryPoint,
  kernelVersion,
})

const account = await createKernelAccount(publicClient, {
  plugins: {
    sudo: ecdsaValidator,
  },
  entryPoint,
  kernelVersion,
})

How I checked

I ran both examples against the latest published packages, before and after each fix.
The first needs no network. For the second, I confirmed the error above and that the fix
gets past it and creates the validator; I didn't run the full account creation against a
live network.

I found similar mismatches on some other pages (a few partner sign-in guides and the
smart routing address pages). Happy to share the list or open a PR for these two if
that's useful.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions