Class SimpleAccountAPI

An implementation of the BaseAccountAPI using the SimpleAccountWallet contract.

  • contract deployer gets "entrypoint", "owner" addresses and "index" nonce
  • owner signs requests using normal "Ethereum Signed Message" (ether's signer.signMessage())
  • nonce method is "nonce()"
  • execute method is "execFromEntryPoint()"

Hierarchy

Index

Constructors

constructor

Properties

Optional accountAddress

accountAddress: string

Optional accountContract

accountContract: Contract

our account contract. should support the "execFromEntryPoint" and "nonce" methods

context

context: Context

entryPointAddress

entryPointAddress: string

Optional factory

factory: Contract

Optional factoryAddress

factoryAddress: string

factoryUsed

factoryUsed: Factory

index

index: number

Optional overheads

overheads: Partial<GasOverheads>

Optional paymasterAPI

paymasterAPI: PaymasterAPI

provider

provider: Provider

Readonly services

services: Context["services"]

Accessors

epView

error$

  • get error$(): ErrorSubject

state

state$

  • get state$(): BehaviorSubject<State>

supportedNetworks

  • get supportedNetworks(): Network[]

Methods

_getAccountContract

  • _getAccountContract(): Promise<Contract>
  • Returns Promise<Contract>

checkAccountPhantom

  • checkAccountPhantom(): Promise<boolean>

createSignedUserOp

createUnsignedUserOp

  • create a UserOperation, filling all details (except signature)

    • if account is not yet created, add initCode to deploy it.
    • if gas or nonce are missing, read them from the chain (note that we can't fill gaslimit before the account is created)

    Parameters

    Returns Promise<UserOperationStruct>

destroy

  • destroy(): void

encodeBatch

  • encodeBatch(targets: string[], values: BigNumberish[], datas: string[]): Promise<string>
  • Parameters

    • targets: string[]
    • values: BigNumberish[]
    • datas: string[]

    Returns Promise<string>

encodeExecute

  • encodeExecute(target: string, value: BigNumberish, data: string): Promise<string>
  • encode a method call from entryPoint to our contract

    Parameters

    • target: string
    • value: BigNumberish
    • data: string

    Returns Promise<string>

encodeUserOpCallDataAndGasLimit

  • encodeUserOpCallDataAndGasLimit(detailsForUserOp: TransactionDetailsForUserOp): Promise<{ callData: string; callGasLimit: BigNumber }>

estimateCreationGas

  • estimateCreationGas(initCode?: string): Promise<BigNumberish>

getAccountAddress

  • getAccountAddress(): Promise<string>
  • return the account's address. this value is valid even before deploying the contract.

    Returns Promise<string>

getAccountInitCode

  • getAccountInitCode(): Promise<string>
  • return the value to put into the "initCode" field, if the account is not yet deployed. this value holds the "factory" address, followed by this account's information

    Returns Promise<string>

getCounterFactualAddress

  • getCounterFactualAddress(): Promise<string>

getInitCode

  • getInitCode(): Promise<string>
  • return initCode value to into the UserOp. (either deployment code, or empty hex if contract already deployed)

    Returns Promise<string>

getNetworkChainId

getNonce

  • getNonce(key?: number): Promise<BigNumber>
  • Parameters

    • Default value key: number = 0

    Returns Promise<BigNumber>

getPreVerificationGas

getUserOpHash

  • return userOpHash for signing. This value matches entryPoint.getUserOpHash (calculated off-chain, to avoid a view call)

    Parameters

    Returns Promise<string>

getUserOpReceipt

  • getUserOpReceipt(userOpHash: string, timeout?: number, interval?: number): Promise<string | null>
  • get the transaction that has this userOpHash mined, or null if not found

    Parameters

    • userOpHash: string

      returned by sendUserOpToBundler (or by getUserOpHash..)

    • Default value timeout: number = 30000

      stop waiting after this timeout

    • Default value interval: number = 5000

      time to wait between polls.

    Returns Promise<string | null>

    the transactionHash this userOp was mined, or null if not found.

getVerificationGasLimit

  • getVerificationGasLimit(): Promise<BigNumberish>
  • return maximum gas used for verification. NOTE: createUnsignedUserOp will add to this value the cost of creation, if the contract is not yet created.

    Returns Promise<BigNumberish>

init

  • init(): Promise<this>

packUserOp

require

  • require(options?: { network?: boolean; wallet?: boolean }): Promise<void>
  • Parameters

    • Default value options: { network?: boolean; wallet?: boolean } = {}
      • Optional network?: boolean
      • Optional wallet?: boolean

    Returns Promise<void>

setPaymasterApi

  • setPaymasterApi(paymaster: PaymasterAPI | null): Promise<void>

signMessage

signTypedData

  • signTypedData(types: TypedDataField[], message: any): Promise<string>

signUserOp

signUserOpHash

  • signUserOpHash(userOpHash: string): Promise<string>
  • Parameters

    • userOpHash: string

    Returns Promise<string>

validateResolveName

  • validateResolveName(options?: { name?: string; network?: number }): Promise<void>
  • Parameters

    • Default value options: { name?: string; network?: number } = {}
      • Optional name?: string
      • Optional network?: number

    Returns Promise<void>