Skip to content

toSmartAccount (ZKsync)

Creates a ZKsync Smart Account from a Contract Address and an array of owner(s).

Usage

import { privateKeyToAccount } from 'viem/accounts'
import { toSmartAccount } from 'viem/zksync'
 
const account = toSmartAccount({
  address: '0xf39Fd6e51aad8F6F4ce6aB8827279cffFb92266', 
  owners: [
    privateKeyToAccount('0x...'), 
    privateKeyToAccount('0x...')
  ]
})

Parameters

address

  • Type: Hex

Address of the deployed Account's Contract implementation.

const account = toSmartAccount({
  address: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', 
  owners: [
    privateKeyToAccount('0x...'), 
    privateKeyToAccount('0x...')
  ]
})

privateKeys

  • Type: LocalAccount[]

Owners of the Smart Account. Must be a set of Local Accounts (Private Key, Mnemonic, etc).

const account = toSmartAccount({
  address: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', 
  owners: [ 
    privateKeyToAccount('0x...'), 
    privateKeyToAccount('0x...') 
  ] 
})