Core API
For the complete documentation index, see llms.txt. This page is also available as markdown.

Delegatecall

Archived version

You are viewing @zerodev/sdk v5.3.x documentation. View the latest documentation.

delegatecall is very dangerous. Unless you know exactly what you are doing, don't do it, or you might risk losing all your funds.

Impatient? Check out complete examples here.

delegatecall is a powerful EVM opcode that allows the calling contract to execute code in another contract, while keeping the storage context. You can read more about delegatecall here.

API

To send a UserOp that uses delegatecall, simply specify the callType of the UserOp:

const userOpHash = await kernelClient.sendUserOperation({
  userOperation: {
    callData: await kernelClient.account.encodeCallData({
      to: targetAdress,
      data: callData,
      value: 0n,
      callType: "delegatecall",
    }),
  },
})

On this page