Skip to content

signUserOperation (Smart Account)

Signs a User Operation with the Smart Account's Owner.

Usage

example.ts
import { toCoinbaseSmartAccount } from 'viem/account-abstraction'
import { client, owner } from './config'
 
export const account = await toCoinbaseSmartAccount({
  client,
  owners: [owner],
})
 
const signature = await account.signUserOperation({ 
  callData: '0xdeadbeef',
  callGasLimit: 141653n,
  factory: '0xfb6dab6200b8958c2655c3747708f82243d3f32e',
  factoryData: '0xf14ddffc000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000000',
  maxFeePerGas: 15000000000n,
  maxPriorityFeePerGas: 2000000000n,
  nonce: 0n,
  paymasterPostOpGasLimit: 0n,
  paymasterVerificationGasLimit: 0n,
  preVerificationGas: 53438n,
  sender: '0xE911628bF8428C23f179a07b081325cAe376DE1f',
  verificationGasLimit: 259350n,
})

Returns

Hex

The User Operation signature.

Parameters

callData

  • Type: Hex

The data to pass to the sender during the main execution call.

const signature = await account.signUserOperation({
  callData: '0xdeadbeef', 
  callGasLimit: 141653n,
  factory: '0xfb6dab6200b8958c2655c3747708f82243d3f32e',
  factoryData: '0xf14ddffc000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000000',
  maxFeePerGas: 15000000000n,
  maxPriorityFeePerGas: 2000000000n,
  nonce: 0n,
  paymasterPostOpGasLimit: 0n,
  paymasterVerificationGasLimit: 0n,
  preVerificationGas: 53438n,
  sender: '0xE911628bF8428C23f179a07b081325cAe376DE1f',
  verificationGasLimit: 259350n,
})

callGasLimit

  • Type: bigint

The amount of gas to allocate the main execution call.

const signature = await account.signUserOperation({
  callData: '0xdeadbeef',
  callGasLimit: 141653n, 
  factory: '0xfb6dab6200b8958c2655c3747708f82243d3f32e',
  factoryData: '0xf14ddffc000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000000',
  maxFeePerGas: 15000000000n,
  maxPriorityFeePerGas: 2000000000n,
  nonce: 0n,
  paymasterPostOpGasLimit: 0n,
  paymasterVerificationGasLimit: 0n,
  preVerificationGas: 53438n,
  sender: '0xE911628bF8428C23f179a07b081325cAe376DE1f',
  verificationGasLimit: 259350n,
})

factory

  • Type: Address

Account factory. Only for new accounts.

const signature = await account.signUserOperation({
  callData: '0xdeadbeef',
  callGasLimit: 141653n,
  factory: '0xfb6dab6200b8958c2655c3747708f82243d3f32e', 
  factoryData: '0xf14ddffc000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000000',
  maxFeePerGas: 15000000000n,
  maxPriorityFeePerGas: 2000000000n,
  nonce: 0n,
  paymasterPostOpGasLimit: 0n,
  paymasterVerificationGasLimit: 0n,
  preVerificationGas: 53438n,
  sender: '0xE911628bF8428C23f179a07b081325cAe376DE1f',
  verificationGasLimit: 259350n,
})

factoryData

  • Type: Hex

Data for account factory.

const signature = await account.signUserOperation({
  callData: '0xdeadbeef',
  callGasLimit: 141653n,
  factory: '0xfb6dab6200b8958c2655c3747708f82243d3f32e',
  factoryData: '0xf14ddffc000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000000', 
  maxFeePerGas: 15000000000n,
  maxPriorityFeePerGas: 2000000000n,
  nonce: 0n,
  paymasterPostOpGasLimit: 0n,
  paymasterVerificationGasLimit: 0n,
  preVerificationGas: 53438n,
  sender: '0xE911628bF8428C23f179a07b081325cAe376DE1f',
  verificationGasLimit: 259350n,
})

maxFeePerGas

  • Type: bigint

Maximum fee per gas.

const signature = await account.signUserOperation({
  callData: '0xdeadbeef',
  callGasLimit: 141653n,
  factory: '0xfb6dab6200b8958c2655c3747708f82243d3f32e',
  factoryData: '0xf14ddffc000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000000',
  maxFeePerGas: 15000000000n, 
  maxPriorityFeePerGas: 2000000000n,
  nonce: 0n,
  paymasterPostOpGasLimit: 0n,
  paymasterVerificationGasLimit: 0n,
  preVerificationGas: 53438n,
  sender: '0xE911628bF8428C23f179a07b081325cAe376DE1f',
  verificationGasLimit: 259350n,
})

maxPriorityFeePerGas

  • Type: bigint

Maximum priority fee per gas.

const signature = await account.signUserOperation({
  callData: '0xdeadbeef',
  callGasLimit: 141653n,
  factory: '0xfb6dab6200b8958c2655c3747708f82243d3f32e',
  factoryData: '0xf14ddffc000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000000',
  maxFeePerGas: 15000000000n,
  maxPriorityFeePerGas: 2000000000n,

  nonce: 0n,
  paymasterPostOpGasLimit: 0n,
  paymasterVerificationGasLimit: 0n,
  preVerificationGas: 53438n,
  sender: '0xE911628bF8428C23f179a07b081325cAe376DE1f',
  verificationGasLimit: 259350n,
})

nonce

  • Type: bigint

Anti-replay parameter.

const signature = await account.signUserOperation({
  callData: '0xdeadbeef',
  callGasLimit: 141653n,
  factory: '0xfb6dab6200b8958c2655c3747708f82243d3f32e',
  factoryData: '0xf14ddffc000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000000',
  maxFeePerGas: 15000000000n,
  maxPriorityFeePerGas: 2000000000n,
  nonce: 0n, 
  paymasterPostOpGasLimit: 0n,
  paymasterVerificationGasLimit: 0n,
  preVerificationGas: 53438n,
  sender: '0xE911628bF8428C23f179a07b081325cAe376DE1f',
  verificationGasLimit: 259350n,
})

paymaster

  • Type: Address

Address of paymaster contract.

const signature = await account.signUserOperation({
  callData: '0xdeadbeef',
  callGasLimit: 141653n,
  factory: '0xfb6dab6200b8958c2655c3747708f82243d3f32e',
  factoryData: '0xf14ddffc000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000000',
  maxFeePerGas: 15000000000n,
  maxPriorityFeePerGas: 2000000000n,
  nonce: 0n,
  paymaster: '0xE911628bF8428C23f179a07b081325cAe376DE1f', 
  paymasterData: '0xdeadbeef',
  paymasterPostOpGasLimit: 0n,
  paymasterVerificationGasLimit: 0n,
  preVerificationGas: 53438n,
  sender: '0xE911628bF8428C23f179a07b081325cAe376DE1f',
  verificationGasLimit: 259350n,
})

paymasterData

  • Type: Hex

Data for paymaster.

const signature = await account.signUserOperation({
  callData: '0xdeadbeef',
  callGasLimit: 141653n,
  factory: '0xfb6dab6200b8958c2655c3747708f82243d3f32e',
  factoryData: '0xf14ddffc000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000000',
  maxFeePerGas: 15000000000n,
  maxPriorityFeePerGas: 2000000000n,
  nonce: 0n,
  paymaster: '0xE911628bF8428C23f179a07b081325cAe376DE1f',
  paymasterData: '0xdeadbeef', 
  paymasterPostOpGasLimit: 0n,
  paymasterVerificationGasLimit: 0n,
  preVerificationGas: 53438n,
  sender: '0xE911628bF8428C23f179a07b081325cAe376DE1f',
  verificationGasLimit: 259350n,
})

paymasterPostOpGasLimit

  • Type: bigint

The amount of gas to allocate for the paymaster post-operation code.

const signature = await account.signUserOperation({
  callData: '0xdeadbeef',
  callGasLimit: 141653n,
  factory: '0xfb6dab6200b8958c2655c3747708f82243d3f32e',
  factoryData: '0xf14ddffc000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000000',
  maxFeePerGas: 15000000000n,
  maxPriorityFeePerGas: 2000000000n,
  nonce: 0n,
  paymaster: '0xE911628bF8428C23f179a07b081325cAe376DE1f',
  paymasterData: '0xdeadbeef',
  paymasterPostOpGasLimit: 69420n, 
  paymasterVerificationGasLimit: 0n,
  preVerificationGas: 53438n,
  sender: '0xE911628bF8428C23f179a07b081325cAe376DE1f',
  verificationGasLimit: 259350n,
})

paymasterVerificationGasLimit

  • Type: bigint

The amount of gas to allocate for the paymaster validation code.

const signature = await account.signUserOperation({
  callData: '0xdeadbeef',
  callGasLimit: 141653n,
  factory: '0xfb6dab6200b8958c2655c3747708f82243d3f32e',
  factoryData: '0xf14ddffc000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000000',
  maxFeePerGas: 15000000000n,
  maxPriorityFeePerGas: 2000000000n,
  nonce: 0n,
  paymaster: '0xE911628bF8428C23f179a07b081325cAe376DE1f',
  paymasterData: '0xdeadbeef',
  paymasterPostOpGasLimit: 69420n,
  paymasterVerificationGasLimit: 69420n, 
  preVerificationGas: 53438n,
  sender: '0xE911628bF8428C23f179a07b081325cAe376DE1f',
  verificationGasLimit: 259350n,
})

preVerificationGas

  • Type: bigint

Extra gas to pay the Bundler.

const signature = await account.signUserOperation({
  callData: '0xdeadbeef',
  callGasLimit: 141653n,
  factory: '0xfb6dab6200b8958c2655c3747708f82243d3f32e',
  factoryData: '0xf14ddffc000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000000',
  maxFeePerGas: 15000000000n,
  maxPriorityFeePerGas: 2000000000n,
  nonce: 0n,
  paymaster: '0xE911628bF8428C23f179a07b081325cAe376DE1f',
  paymasterData: '0xdeadbeef',
  paymasterPostOpGasLimit: 69420n,
  paymasterVerificationGasLimit: 69420n,
  preVerificationGas: 53438n, 
  sender: '0xE911628bF8428C23f179a07b081325cAe376DE1f',
  verificationGasLimit: 259350n,
})

sender

  • Type: Address

The account making the operation.

const signature = await account.signUserOperation({
  callData: '0xdeadbeef',
  callGasLimit: 141653n,
  factory: '0xfb6dab6200b8958c2655c3747708f82243d3f32e',
  factoryData: '0xf14ddffc000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000000',
  maxFeePerGas: 15000000000n,
  maxPriorityFeePerGas: 2000000000n,
  nonce: 0n,
  paymaster: '0xE911628bF8428C23f179a07b081325cAe376DE1f',
  paymasterData: '0xdeadbeef',
  paymasterPostOpGasLimit: 69420n,
  paymasterVerificationGasLimit: 69420n,
  preVerificationGas: 53438n,
  sender: '0xE911628bF8428C23f179a07b081325cAe376DE1f', 
  verificationGasLimit: 259350n,
})

verificationGasLimit

  • Type: bigint

The amount of gas to allocate for the verification step.

const signature = await account.signUserOperation({
  callData: '0xdeadbeef',
  callGasLimit: 141653n,
  factory: '0xfb6dab6200b8958c2655c3747708f82243d3f32e',
  factoryData: '0xf14ddffc000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000000',
  maxFeePerGas: 15000000000n,
  maxPriorityFeePerGas: 2000000000n,
  nonce: 0n,
  paymaster: '0xE911628bF8428C23f179a07b081325cAe376DE1f',
  paymasterData: '0xdeadbeef',
  paymasterPostOpGasLimit: 69420n,
  paymasterVerificationGasLimit: 69420n,
  preVerificationGas: 53438n,
  sender: '0xE911628bF8428C23f179a07b081325cAe376DE1f',
  verificationGasLimit: 259350n, 
})