Class Contract<ContractAbi>

A basic Contract class to encapsulate configuration and a potential address

Contract

Type Parameters

  • ContractAbi extends Abi

Hierarchy (view full)

Constructors

Properties

_config: Config
_address: undefined | `0x${string}`

The internally managed address for this contract

Accessors

Methods

  • A typed wrapper for (viem.getLogs)[https://viem.sh/docs/actions/public/getLogs#getlogs]. Accepts eventName and eventNames as optional parameters to narrow the returned log types.

    Type Parameters

    • event extends string
    • const abiEvent extends {
          name: event;
      } & AbiEvent = ExtractAbiEvent<ContractAbi, event>

    Parameters

    Returns Promise<GetLogsReturnType<abiEvent, abiEvent[]>>

    const logs = contract.getLogs({ eventName: 'EventName' })
    const logs = contract.getLogs({ eventNames: ['EventName'] })

    @public
    @async
    @template {ContractEvent} event
    @template {ExtractAbiEvent<
    ContractAbi,
    event
    >} [abiEvent=ExtractAbiEvent<ContractAbi, event>]
    @param {?Omit<
    GetLogsParams<ContractAbi, event, abiEvent, abiEvent[]>,
    'event' | 'events'
    > & {
    eventName?: event;
    eventNames?: event[];
    }} [params]
    @returns {Promise<GetLogsReturnType<abiEvent, abiEvent
  • A typed wrapper for wagmi.watchContractEvent

    Type Parameters

    • event extends string

    Parameters

    • cb: ((log: WatchContractEventOnLogsParameter<ContractAbi, event, true>[number]) => unknown)
        • (log): unknown
        • Parameters

          Returns unknown

    • Optionalparams: Partial<Omit<UnionCompute<WatchContractEventParameters<ContractAbi, event, undefined, WebSocketTransport> & ChainIdParameter<Config, number> & SyncConnectedChainParameter>, "address" | "abi">> & {
          eventName?: event;
      }

    Returns (() => void)

      • (): void
      • Returns void