signUserOperation (Smart Account)
Signs a User Operation with the Smart Account's Owner.
Usage
// @filename: config.ts
import { createPublicClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { mainnet } from 'viem/chains'
export const client = createPublicClient({
chain: mainnet,
transport: http()
})
export const owner = privateKeyToAccount('0x...')
// @filename: example.ts
// ---cut---
import { toCoinbaseSmartAccount } from 'viem/account-abstraction'
import { client, owner } from './config'
export const account = await toCoinbaseSmartAccount({
client,
owners: [owner],
version: '1.1',
})
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.
// @filename: config.ts
import { createPublicClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { mainnet } from 'viem/chains'
export const client = createPublicClient({
chain: mainnet,
transport: http()
})
export const owner = privateKeyToAccount('0x...')
// @filename: example.ts
// ---cut---
import { toCoinbaseSmartAccount } from 'viem/account-abstraction'
import { client, owner } from './config'
export const account = await toCoinbaseSmartAccount({
client,
owners: [owner],
version: '1.1',
})
// ---cut---
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.
// @filename: config.ts
import { createPublicClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { mainnet } from 'viem/chains'
export const client = createPublicClient({
chain: mainnet,
transport: http()
})
export const owner = privateKeyToAccount('0x...')
// @filename: example.ts
// ---cut---
import { toCoinbaseSmartAccount } from 'viem/account-abstraction'
import { client, owner } from './config'
export const account = await toCoinbaseSmartAccount({
client,
owners: [owner],
version: '1.1',
})
// ---cut---
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.
// @filename: config.ts
import { createPublicClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { mainnet } from 'viem/chains'
export const client = createPublicClient({
chain: mainnet,
transport: http()
})
export const owner = privateKeyToAccount('0x...')
// @filename: example.ts
// ---cut---
import { toCoinbaseSmartAccount } from 'viem/account-abstraction'
import { client, owner } from './config'
export const account = await toCoinbaseSmartAccount({
client,
owners: [owner],
version: '1.1',
})
// ---cut---
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.
// @filename: config.ts
import { createPublicClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { mainnet } from 'viem/chains'
export const client = createPublicClient({
chain: mainnet,
transport: http()
})
export const owner = privateKeyToAccount('0x...')
// @filename: example.ts
// ---cut---
import { toCoinbaseSmartAccount } from 'viem/account-abstraction'
import { client, owner } from './config'
export const account = await toCoinbaseSmartAccount({
client,
owners: [owner],
version: '1.1',
})
// ---cut---
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.
// @filename: config.ts
import { createPublicClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { mainnet } from 'viem/chains'
export const client = createPublicClient({
chain: mainnet,
transport: http()
})
export const owner = privateKeyToAccount('0x...')
// @filename: example.ts
// ---cut---
import { toCoinbaseSmartAccount } from 'viem/account-abstraction'
import { client, owner } from './config'
export const account = await toCoinbaseSmartAccount({
client,
owners: [owner],
version: '1.1',
})
// ---cut---
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.
// @filename: config.ts
import { createPublicClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { mainnet } from 'viem/chains'
export const client = createPublicClient({
chain: mainnet,
transport: http()
})
export const owner = privateKeyToAccount('0x...')
// @filename: example.ts
// ---cut---
import { toCoinbaseSmartAccount } from 'viem/account-abstraction'
import { client, owner } from './config'
export const account = await toCoinbaseSmartAccount({
client,
owners: [owner],
version: '1.1',
})
// ---cut---
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.
// @filename: config.ts
import { createPublicClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { mainnet } from 'viem/chains'
export const client = createPublicClient({
chain: mainnet,
transport: http()
})
export const owner = privateKeyToAccount('0x...')
// @filename: example.ts
// ---cut---
import { toCoinbaseSmartAccount } from 'viem/account-abstraction'
import { client, owner } from './config'
export const account = await toCoinbaseSmartAccount({
client,
owners: [owner],
version: '1.1',
})
// ---cut---
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.
// @filename: config.ts
import { createPublicClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { mainnet } from 'viem/chains'
export const client = createPublicClient({
chain: mainnet,
transport: http()
})
export const owner = privateKeyToAccount('0x...')
// @filename: example.ts
// ---cut---
import { toCoinbaseSmartAccount } from 'viem/account-abstraction'
import { client, owner } from './config'
export const account = await toCoinbaseSmartAccount({
client,
owners: [owner],
version: '1.1',
})
// ---cut---
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.
// @filename: config.ts
import { createPublicClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { mainnet } from 'viem/chains'
export const client = createPublicClient({
chain: mainnet,
transport: http()
})
export const owner = privateKeyToAccount('0x...')
// @filename: example.ts
// ---cut---
import { toCoinbaseSmartAccount } from 'viem/account-abstraction'
import { client, owner } from './config'
export const account = await toCoinbaseSmartAccount({
client,
owners: [owner],
version: '1.1',
})
// ---cut---
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.
// @filename: config.ts
import { createPublicClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { mainnet } from 'viem/chains'
export const client = createPublicClient({
chain: mainnet,
transport: http()
})
export const owner = privateKeyToAccount('0x...')
// @filename: example.ts
// ---cut---
import { toCoinbaseSmartAccount } from 'viem/account-abstraction'
import { client, owner } from './config'
export const account = await toCoinbaseSmartAccount({
client,
owners: [owner],
version: '1.1',
})
// ---cut---
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.
// @filename: config.ts
import { createPublicClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { mainnet } from 'viem/chains'
export const client = createPublicClient({
chain: mainnet,
transport: http()
})
export const owner = privateKeyToAccount('0x...')
// @filename: example.ts
// ---cut---
import { toCoinbaseSmartAccount } from 'viem/account-abstraction'
import { client, owner } from './config'
export const account = await toCoinbaseSmartAccount({
client,
owners: [owner],
version: '1.1',
})
// ---cut---
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.
// @filename: config.ts
import { createPublicClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { mainnet } from 'viem/chains'
export const client = createPublicClient({
chain: mainnet,
transport: http()
})
export const owner = privateKeyToAccount('0x...')
// @filename: example.ts
// ---cut---
import { toCoinbaseSmartAccount } from 'viem/account-abstraction'
import { client, owner } from './config'
export const account = await toCoinbaseSmartAccount({
client,
owners: [owner],
version: '1.1',
})
// ---cut---
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.
// @filename: config.ts
import { createPublicClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { mainnet } from 'viem/chains'
export const client = createPublicClient({
chain: mainnet,
transport: http()
})
export const owner = privateKeyToAccount('0x...')
// @filename: example.ts
// ---cut---
import { toCoinbaseSmartAccount } from 'viem/account-abstraction'
import { client, owner } from './config'
export const account = await toCoinbaseSmartAccount({
client,
owners: [owner],
version: '1.1',
})
// ---cut---
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.
// @filename: config.ts
import { createPublicClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { mainnet } from 'viem/chains'
export const client = createPublicClient({
chain: mainnet,
transport: http()
})
export const owner = privateKeyToAccount('0x...')
// @filename: example.ts
// ---cut---
import { toCoinbaseSmartAccount } from 'viem/account-abstraction'
import { client, owner } from './config'
export const account = await toCoinbaseSmartAccount({
client,
owners: [owner],
version: '1.1',
})
// ---cut---
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,
})