Skip to content

toSmartAccount (ZKsync)

Creates a ZKsync Smart Account from a Contract Address and a custom sign function.

Usage

import { toSmartAccount } from 'viem/zksync'
 
const account = toSmartAccount({
  address: '0xf39Fd6e51aad8F6F4ce6aB8827279cffFb92266', 
  async sign({ hash }) {
    // ... signing logic
    return '0x...'
  }
})

Parameters

address

  • Type: Hex

Address of the deployed Account's Contract implementation.

const account = toSmartAccount({
  address: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', 
  async sign({ hash }) {
    // ...
  }
})

sign

  • Type: ({ hash: Hex }) => Hex

Custom sign function for the Smart Account.

const account = toSmartAccount({
  address: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', 
  async sign({ hash }) { 
    // ...
  } 
})