Interface ISmartContractAccount<TSigner>

interface ISmartContractAccount<TSigner> {
    encodeUpgradeToAndCall: ((upgradeToImplAddress: `0x${string}`, upgradeToInitData: `0x${string}`) => Promise<`0x${string}`>);
    extend: (<R>(extendFn: ((self: this) => R)) => ISmartContractAccount<TSigner> & R);
    rpcProvider: {
        account: undefined;
        batch?: {
            multicall?: boolean | {
                batchSize?: number;
                wait?: number;
            };
        };
        cacheTime: number;
        call: ((parameters: CallParameters<undefined | Chain>) => Promise<CallReturnType>);
        chain: undefined | Chain;
        createBlockFilter: (() => Promise<{
            id: `0x${string}`;
            request: EIP1193RequestFn<readonly [{
                Method: "eth_getFilterChanges";
                Parameters: [filterId: `0x${string}`];
                ReturnType: `0x${string}`[] | RpcLog[];
            }, {
                Method: "eth_getFilterLogs";
                Parameters: [filterId: `0x${string}`];
                ReturnType: RpcLog[];
            }, {
                Method: "eth_uninstallFilter";
                Parameters: [filterId: `0x${string}`];
                ReturnType: boolean;
            }]>;
            type: "block";
        }>);
        createContractEventFilter: (<const TAbi, TEventName, TArgs, TStrict, TFromBlock, TToBlock>(args: CreateContractEventFilterParameters<TAbi, TEventName, TArgs, TStrict, TFromBlock, TToBlock>) => Promise<CreateContractEventFilterReturnType<TAbi, TEventName, TArgs, TStrict, TFromBlock, TToBlock>>);
        createEventFilter: (<const TAbiEvent, const TAbiEvents, TStrict, TFromBlock, TToBlock, _EventName, _Args>(args?: CreateEventFilterParameters<TAbiEvent, TAbiEvents, TStrict, TFromBlock, TToBlock, _EventName, _Args>) => Promise<{
            [K in string | number | symbol]: Filter<"event", TAbiEvents, _EventName, _Args, TStrict, TFromBlock, TToBlock>[K]
        }>);
        createPendingTransactionFilter: (() => Promise<{
            id: `0x${string}`;
            request: EIP1193RequestFn<readonly [{
                Method: "eth_getFilterChanges";
                Parameters: [filterId: `0x${string}`];
                ReturnType: `0x${string}`[] | RpcLog[];
            }, {
                Method: "eth_getFilterLogs";
                Parameters: [filterId: `0x${string}`];
                ReturnType: RpcLog[];
            }, {
                Method: "eth_uninstallFilter";
                Parameters: [filterId: `0x${string}`];
                ReturnType: boolean;
            }]>;
            type: "transaction";
        }>);
        estimateContractGas: (<TChain, const abi, functionName, args>(args: EstimateContractGasParameters<abi, functionName, args, TChain>) => Promise<bigint>);
        estimateFeesPerGas: (<TChainOverride, TType>(args?: EstimateFeesPerGasParameters<undefined | Chain, TChainOverride, TType>) => Promise<EstimateFeesPerGasReturnType>);
        estimateGas: ((args: EstimateGasParameters<undefined | Chain>) => Promise<bigint>);
        estimateMaxPriorityFeePerGas: (<TChainOverride>(args?: {
            chain: null | TChainOverride;
        }) => Promise<bigint>);
        extend: (<const client>(fn: ((client: Client<Transport, undefined | Chain, undefined, PublicRpcSchema, PublicActions<Transport, undefined | Chain>>) => client)) => Client<Transport, undefined | Chain, undefined, PublicRpcSchema, {
            [K in string | number | symbol]: client[K]
        } & PublicActions<Transport, undefined | Chain>>);
        getBalance: ((args: GetBalanceParameters) => Promise<bigint>);
        getBlobBaseFee: (() => Promise<bigint>);
        getBlock: (<TIncludeTransactions, TBlockTag>(args?: GetBlockParameters<TIncludeTransactions, TBlockTag>) => Promise<{
            baseFeePerGas: null | bigint;
            blobGasUsed: bigint;
            difficulty: bigint;
            excessBlobGas: bigint;
            extraData: `0x${string}`;
            gasLimit: bigint;
            gasUsed: bigint;
            hash: TBlockTag extends "pending"
                ? null
                : `0x${string}`;
            logsBloom: TBlockTag extends "pending"
                ? null
                : `0x${string}`;
            miner: `0x${string}`;
            mixHash: `0x${string}`;
            nonce: TBlockTag extends "pending"
                ? null
                : `0x${string}`;
            number: TBlockTag extends "pending"
                ? null
                : bigint;
            parentHash: `0x${string}`;
            receiptsRoot: `0x${string}`;
            sealFields: `0x${string}`[];
            sha3Uncles: `0x${string}`;
            size: bigint;
            stateRoot: `0x${string}`;
            timestamp: bigint;
            totalDifficulty: null | bigint;
            transactions: TIncludeTransactions extends true
                ? (
                    | {
                        accessList?: undefined;
                        blobVersionedHashes?: undefined;
                        blockHash: (TBlockTag extends "pending"
                                ? true
                                : false) extends true
                            ? null
                            : `0x${string}`;
                        blockNumber: (TBlockTag extends "pending"
                                ? true
                                : false) extends true
                            ? null
                            : bigint;
                        chainId?: number;
                        from: `0x${string}`;
                        gas: bigint;
                        gasPrice: bigint;
                        hash: `0x${string}`;
                        input: `0x${string}`;
                        maxFeePerBlobGas?: undefined;
                        maxFeePerGas?: undefined;
                        maxPriorityFeePerGas?: undefined;
                        nonce: number;
                        r: `0x${string}`;
                        s: `0x${string}`;
                        to: null | `0x${string}`;
                        transactionIndex: (TBlockTag extends "pending"
                                ? true
                                : false) extends true
                            ? null
                            : number;
                        type: "legacy";
                        typeHex: null | `0x${string}`;
                        v: bigint;
                        value: bigint;
                        yParity?: undefined;
                    }
                    | {
                        accessList: AccessList;
                        blobVersionedHashes?: undefined;
                        blockHash: (TBlockTag extends "pending"
                                ? true
                                : false) extends true
                            ? null
                            : `0x${string}`;
                        blockNumber: (TBlockTag extends "pending"
                                ? true
                                : false) extends true
                            ? null
                            : bigint;
                        chainId: number;
                        from: `0x${string}`;
                        gas: bigint;
                        gasPrice: bigint;
                        hash: `0x${string}`;
                        input: `0x${string}`;
                        maxFeePerBlobGas?: undefined;
                        maxFeePerGas?: undefined;
                        maxPriorityFeePerGas?: undefined;
                        nonce: number;
                        r: `0x${string}`;
                        s: `0x${string}`;
                        to: null | `0x${string}`;
                        transactionIndex: (TBlockTag extends "pending"
                                ? true
                                : false) extends true
                            ? null
                            : number;
                        type: "eip2930";
                        typeHex: null | `0x${string}`;
                        v: bigint;
                        value: bigint;
                        yParity: number;
                    }
                    | {
                        accessList: AccessList;
                        blobVersionedHashes?: undefined;
                        blockHash: (TBlockTag extends "pending"
                                ? true
                                : false) extends true
                            ? null
                            : `0x${string}`;
                        blockNumber: (TBlockTag extends "pending"
                                ? true
                                : false) extends true
                            ? null
                            : bigint;
                        chainId: number;
                        from: `0x${string}`;
                        gas: bigint;
                        gasPrice?: undefined;
                        hash: `0x${string}`;
                        input: `0x${string}`;
                        maxFeePerBlobGas?: undefined;
                        maxFeePerGas: bigint;
                        maxPriorityFeePerGas: bigint;
                        nonce: number;
                        r: `0x${string}`;
                        s: `0x${string}`;
                        to: null | `0x${string}`;
                        transactionIndex: (TBlockTag extends "pending"
                                ? true
                                : false) extends true
                            ? null
                            : number;
                        type: "eip1559";
                        typeHex: null | `0x${string}`;
                        v: bigint;
                        value: bigint;
                        yParity: number;
                    }
                    | {
                        accessList: AccessList;
                        blobVersionedHashes: `0x${string}`[];
                        blockHash: (TBlockTag extends "pending"
                                ? true
                                : false) extends true
                            ? null
                            : `0x${string}`;
                        blockNumber: (TBlockTag extends "pending"
                                ? true
                                : false) extends true
                            ? null
                            : bigint;
                        chainId: number;
                        from: `0x${string}`;
                        gas: bigint;
                        gasPrice?: undefined;
                        hash: `0x${string}`;
                        input: `0x${string}`;
                        maxFeePerBlobGas: bigint;
                        maxFeePerGas: bigint;
                        maxPriorityFeePerGas: bigint;
                        nonce: number;
                        r: `0x${string}`;
                        s: `0x${string}`;
                        to: null | `0x${string}`;
                        transactionIndex: (TBlockTag extends "pending"
                                ? true
                                : false) extends true
                            ? null
                            : number;
                        type: "eip4844";
                        typeHex: null | `0x${string}`;
                        v: bigint;
                        value: bigint;
                        yParity: number;
                    })[]
                : `0x${string}`[];
            transactionsRoot: `0x${string}`;
            uncles: `0x${string}`[];
            withdrawals?: Withdrawal[];
            withdrawalsRoot?: `0x${string}`;
        }>);
        getBlockNumber: ((args?: GetBlockNumberParameters) => Promise<bigint>);
        getBlockTransactionCount: ((args?: GetBlockTransactionCountParameters) => Promise<number>);
        getBytecode: ((args: GetBytecodeParameters) => Promise<GetBytecodeReturnType>);
        getChainId: (() => Promise<number>);
        getContractEvents: (<const abi, eventName, strict, fromBlock, toBlock>(args: GetContractEventsParameters<abi, eventName, strict, fromBlock, toBlock>) => Promise<GetContractEventsReturnType<abi, eventName, strict, fromBlock, toBlock>>);
        getEnsAddress: ((args: {
            blockNumber?: bigint;
            blockTag?: BlockTag;
            coinType?: number;
            gatewayUrls?: string[];
            name: string;
            strict?: boolean;
            universalResolverAddress?: `0x${string}`;
        }) => Promise<GetEnsAddressReturnType>);
        getEnsAvatar: ((args: {
            assetGatewayUrls?: AssetGatewayUrls;
            blockNumber?: bigint;
            blockTag?: BlockTag;
            gatewayUrls?: string[];
            name: string;
            strict?: boolean;
            universalResolverAddress?: `0x${string}`;
        }) => Promise<GetEnsAvatarReturnType>);
        getEnsName: ((args: {
            address: `0x${string}`;
            blockNumber?: bigint;
            blockTag?: BlockTag;
            gatewayUrls?: string[];
            strict?: boolean;
            universalResolverAddress?: `0x${string}`;
        }) => Promise<GetEnsNameReturnType>);
        getEnsResolver: ((args: {
            blockNumber?: bigint;
            blockTag?: BlockTag;
            name: string;
            universalResolverAddress?: `0x${string}`;
        }) => Promise<`0x${string}`>);
        getEnsText: ((args: {
            blockNumber?: bigint;
            blockTag?: BlockTag;
            gatewayUrls?: string[];
            key: string;
            name: string;
            strict?: boolean;
            universalResolverAddress?: `0x${string}`;
        }) => Promise<GetEnsTextReturnType>);
        getFeeHistory: ((args: GetFeeHistoryParameters) => Promise<GetFeeHistoryReturnType>);
        getFilterChanges: (<TFilterType, const TAbi, TEventName, TStrict, TFromBlock, TToBlock>(args: GetFilterChangesParameters<TFilterType, TAbi, TEventName, TStrict, TFromBlock, TToBlock>) => Promise<GetFilterChangesReturnType<TFilterType, TAbi, TEventName, TStrict, TFromBlock, TToBlock>>);
        getFilterLogs: (<const TAbi, TEventName, TStrict, TFromBlock, TToBlock>(args: GetFilterLogsParameters<TAbi, TEventName, TStrict, TFromBlock, TToBlock>) => Promise<GetFilterLogsReturnType<TAbi, TEventName, TStrict, TFromBlock, TToBlock>>);
        getGasPrice: (() => Promise<bigint>);
        getLogs: (<const TAbiEvent, const TAbiEvents, TStrict, TFromBlock, TToBlock>(args?: GetLogsParameters<TAbiEvent, TAbiEvents, TStrict, TFromBlock, TToBlock>) => Promise<GetLogsReturnType<TAbiEvent, TAbiEvents, TStrict, TFromBlock, TToBlock>>);
        getProof: ((args: GetProofParameters) => Promise<GetProofReturnType>);
        getStorageAt: ((args: GetStorageAtParameters) => Promise<GetStorageAtReturnType>);
        getTransaction: (<TBlockTag>(args: GetTransactionParameters<TBlockTag>) => Promise<
            | {
                accessList?: undefined;
                blobVersionedHashes?: undefined;
                blockHash: (TBlockTag extends "pending"
                        ? true
                        : false) extends true
                    ? null
                    : `0x${string}`;
                blockNumber: (TBlockTag extends "pending"
                        ? true
                        : false) extends true
                    ? null
                    : bigint;
                chainId?: number;
                from: `0x${string}`;
                gas: bigint;
                gasPrice: bigint;
                hash: `0x${string}`;
                input: `0x${string}`;
                maxFeePerBlobGas?: undefined;
                maxFeePerGas?: undefined;
                maxPriorityFeePerGas?: undefined;
                nonce: number;
                r: `0x${string}`;
                s: `0x${string}`;
                to: null | `0x${string}`;
                transactionIndex: (TBlockTag extends "pending"
                        ? true
                        : false) extends true
                    ? null
                    : number;
                type: "legacy";
                typeHex: null | `0x${string}`;
                v: bigint;
                value: bigint;
                yParity?: undefined;
            }
            | {
                accessList: AccessList;
                blobVersionedHashes?: undefined;
                blockHash: (TBlockTag extends "pending"
                        ? true
                        : false) extends true
                    ? null
                    : `0x${string}`;
                blockNumber: (TBlockTag extends "pending"
                        ? true
                        : false) extends true
                    ? null
                    : bigint;
                chainId: number;
                from: `0x${string}`;
                gas: bigint;
                gasPrice: bigint;
                hash: `0x${string}`;
                input: `0x${string}`;
                maxFeePerBlobGas?: undefined;
                maxFeePerGas?: undefined;
                maxPriorityFeePerGas?: undefined;
                nonce: number;
                r: `0x${string}`;
                s: `0x${string}`;
                to: null | `0x${string}`;
                transactionIndex: (TBlockTag extends "pending"
                        ? true
                        : false) extends true
                    ? null
                    : number;
                type: "eip2930";
                typeHex: null | `0x${string}`;
                v: bigint;
                value: bigint;
                yParity: number;
            }
            | {
                accessList: AccessList;
                blobVersionedHashes?: undefined;
                blockHash: (TBlockTag extends "pending"
                        ? true
                        : false) extends true
                    ? null
                    : `0x${string}`;
                blockNumber: (TBlockTag extends "pending"
                        ? true
                        : false) extends true
                    ? null
                    : bigint;
                chainId: number;
                from: `0x${string}`;
                gas: bigint;
                gasPrice?: undefined;
                hash: `0x${string}`;
                input: `0x${string}`;
                maxFeePerBlobGas?: undefined;
                maxFeePerGas: bigint;
                maxPriorityFeePerGas: bigint;
                nonce: number;
                r: `0x${string}`;
                s: `0x${string}`;
                to: null | `0x${string}`;
                transactionIndex: (TBlockTag extends "pending"
                        ? true
                        : false) extends true
                    ? null
                    : number;
                type: "eip1559";
                typeHex: null | `0x${string}`;
                v: bigint;
                value: bigint;
                yParity: number;
            }
            | {
                accessList: AccessList;
                blobVersionedHashes: `0x${string}`[];
                blockHash: (TBlockTag extends "pending"
                        ? true
                        : false) extends true
                    ? null
                    : `0x${string}`;
                blockNumber: (TBlockTag extends "pending"
                        ? true
                        : false) extends true
                    ? null
                    : bigint;
                chainId: number;
                from: `0x${string}`;
                gas: bigint;
                gasPrice?: undefined;
                hash: `0x${string}`;
                input: `0x${string}`;
                maxFeePerBlobGas: bigint;
                maxFeePerGas: bigint;
                maxPriorityFeePerGas: bigint;
                nonce: number;
                r: `0x${string}`;
                s: `0x${string}`;
                to: null | `0x${string}`;
                transactionIndex: (TBlockTag extends "pending"
                        ? true
                        : false) extends true
                    ? null
                    : number;
                type: "eip4844";
                typeHex: null | `0x${string}`;
                v: bigint;
                value: bigint;
                yParity: number;
            }>);
        getTransactionConfirmations: ((args: GetTransactionConfirmationsParameters<undefined | Chain>) => Promise<bigint>);
        getTransactionCount: ((args: GetTransactionCountParameters) => Promise<number>);
        getTransactionReceipt: ((args: GetTransactionReceiptParameters) => Promise<TransactionReceipt>);
        key: string;
        multicall: (<const contracts, allowFailure>(args: MulticallParameters<contracts, allowFailure>) => Promise<MulticallReturnType<contracts, allowFailure>>);
        name: string;
        pollingInterval: number;
        prepareTransactionRequest: (<const TRequest, TChainOverride, TAccountOverride>(args: PrepareTransactionRequestParameters<undefined | Chain, undefined | Account, TChainOverride, TAccountOverride, TRequest>) => Promise<{
            [K in string | number | symbol]: (UnionRequiredBy<Extract<UnionOmit<(...), (...)> & ((...) extends (...)
                ? (...)
                : (...)) & ((...) extends (...)
                ? (...)
                : (...)), IsNever<(...)> extends true
                ? unknown
                : ExactPartial<(...)>> & {
                chainId?: number;
            }, ParameterTypeToParameters<TRequest["parameters"] extends PrepareTransactionRequestParameterType[]
                ? any[any][number]
                : PrepareTransactionRequestParameterType>> & (unknown extends TRequest["kzg"]
                ? {}
                : Pick<TRequest, "kzg">))[K]
        }>);
        readContract: (<const abi, functionName, args>(args: ReadContractParameters<abi, functionName, args>) => Promise<ReadContractReturnType<abi, functionName, args>>);
        request: EIP1193RequestFn<PublicRpcSchema>;
        sendRawTransaction: ((args: SendRawTransactionParameters) => Promise<`0x${string}`>);
        simulateContract: (<const abi, functionName, args, chainOverride, accountOverride>(args: SimulateContractParameters<abi, functionName, args, undefined | Chain, chainOverride, accountOverride>) => Promise<SimulateContractReturnType<abi, functionName, args, undefined | Chain, undefined | Account, chainOverride, accountOverride>>);
        transport: TransportConfig<string, EIP1193RequestFn> & Record<string, any>;
        type: string;
        uid: string;
        uninstallFilter: ((args: UninstallFilterParameters) => Promise<boolean>);
        verifyMessage: ((args: VerifyMessageParameters) => Promise<boolean>);
        verifyTypedData: ((args: VerifyTypedDataParameters) => Promise<boolean>);
        waitForTransactionReceipt: ((args: WaitForTransactionReceiptParameters<undefined | Chain>) => Promise<TransactionReceipt>);
        watchBlockNumber: ((args: WatchBlockNumberParameters) => WatchBlockNumberReturnType);
        watchBlocks: (<TIncludeTransactions, TBlockTag>(args: WatchBlocksParameters<Transport, undefined | Chain, TIncludeTransactions, TBlockTag>) => WatchBlocksReturnType);
        watchContractEvent: (<const TAbi, TEventName, TStrict>(args: WatchContractEventParameters<TAbi, TEventName, TStrict, Transport>) => WatchContractEventReturnType);
        watchEvent: (<const TAbiEvent, const TAbiEvents, TStrict>(args: WatchEventParameters<TAbiEvent, TAbiEvents, TStrict, Transport>) => WatchEventReturnType);
        watchPendingTransactions: ((args: WatchPendingTransactionsParameters<Transport>) => WatchPendingTransactionsReturnType);
    };
    encodeBatchExecute(txs: BatchUserOperationCallData): Promise<`0x${string}`>;
    encodeExecute(target: string, value: bigint, data: string): Promise<`0x${string}`>;
    getAddress(): Promise<`0x${string}`>;
    getDummySignature(): `0x${string}`;
    getEntryPointAddress(): `0x${string}`;
    getFactoryAddress(): `0x${string}`;
    getInitCode(): Promise<`0x${string}`>;
    getNonce(): Promise<bigint>;
    getSigner(): TSigner;
    signMessage(msg: string | Uint8Array): Promise<`0x${string}`>;
    signMessageWith6492(msg: string | Uint8Array): Promise<`0x${string}`>;
    signTypedData(params: SignTypedDataParams): Promise<`0x${string}`>;
    signTypedDataWith6492(params: SignTypedDataParams): Promise<`0x${string}`>;
    signUserOperationHash(uoHash: `0x${string}`): Promise<`0x${string}`>;
}

Type Parameters

Implemented by

Properties

encodeUpgradeToAndCall: ((upgradeToImplAddress: `0x${string}`, upgradeToInitData: `0x${string}`) => Promise<`0x${string}`>)
extend: (<R>(extendFn: ((self: this) => R)) => ISmartContractAccount<TSigner> & R)

Allows you to add additional functionality and utility methods to this account via a decorator pattern.

NOTE: this method does not allow you to override existing methods on the account.

Type declaration

    • <R>(extendFn): ISmartContractAccount<TSigner> & R
    • Type Parameters

      • R

      Parameters

      • extendFn: ((self: this) => R)

        this function gives you access to the created account instance and returns an object with the extension methods

          • (self): R
          • Parameters

            • self: this

            Returns R

      Returns ISmartContractAccount<TSigner> & R

      -- the account with the extension methods added

const account = new BaseSmartCobntractAccount(...).extend((account) => ({
readAccountState: async (...args) => {
return this.rpcProvider.readContract({
address: await this.getAddress(),
abi: ThisContractsAbi
args: args
});
}
}));

account.debugSendUserOperation(...);
rpcProvider: {
    account: undefined;
    batch?: {
        multicall?: boolean | {
            batchSize?: number;
            wait?: number;
        };
    };
    cacheTime: number;
    call: ((parameters: CallParameters<undefined | Chain>) => Promise<CallReturnType>);
    chain: undefined | Chain;
    createBlockFilter: (() => Promise<{
        id: `0x${string}`;
        request: EIP1193RequestFn<readonly [{
            Method: "eth_getFilterChanges";
            Parameters: [filterId: `0x${string}`];
            ReturnType: `0x${string}`[] | RpcLog[];
        }, {
            Method: "eth_getFilterLogs";
            Parameters: [filterId: `0x${string}`];
            ReturnType: RpcLog[];
        }, {
            Method: "eth_uninstallFilter";
            Parameters: [filterId: `0x${string}`];
            ReturnType: boolean;
        }]>;
        type: "block";
    }>);
    createContractEventFilter: (<const TAbi, TEventName, TArgs, TStrict, TFromBlock, TToBlock>(args: CreateContractEventFilterParameters<TAbi, TEventName, TArgs, TStrict, TFromBlock, TToBlock>) => Promise<CreateContractEventFilterReturnType<TAbi, TEventName, TArgs, TStrict, TFromBlock, TToBlock>>);
    createEventFilter: (<const TAbiEvent, const TAbiEvents, TStrict, TFromBlock, TToBlock, _EventName, _Args>(args?: CreateEventFilterParameters<TAbiEvent, TAbiEvents, TStrict, TFromBlock, TToBlock, _EventName, _Args>) => Promise<{
        [K in string | number | symbol]: Filter<"event", TAbiEvents, _EventName, _Args, TStrict, TFromBlock, TToBlock>[K]
    }>);
    createPendingTransactionFilter: (() => Promise<{
        id: `0x${string}`;
        request: EIP1193RequestFn<readonly [{
            Method: "eth_getFilterChanges";
            Parameters: [filterId: `0x${string}`];
            ReturnType: `0x${string}`[] | RpcLog[];
        }, {
            Method: "eth_getFilterLogs";
            Parameters: [filterId: `0x${string}`];
            ReturnType: RpcLog[];
        }, {
            Method: "eth_uninstallFilter";
            Parameters: [filterId: `0x${string}`];
            ReturnType: boolean;
        }]>;
        type: "transaction";
    }>);
    estimateContractGas: (<TChain, const abi, functionName, args>(args: EstimateContractGasParameters<abi, functionName, args, TChain>) => Promise<bigint>);
    estimateFeesPerGas: (<TChainOverride, TType>(args?: EstimateFeesPerGasParameters<undefined | Chain, TChainOverride, TType>) => Promise<EstimateFeesPerGasReturnType>);
    estimateGas: ((args: EstimateGasParameters<undefined | Chain>) => Promise<bigint>);
    estimateMaxPriorityFeePerGas: (<TChainOverride>(args?: {
        chain: null | TChainOverride;
    }) => Promise<bigint>);
    extend: (<const client>(fn: ((client: Client<Transport, undefined | Chain, undefined, PublicRpcSchema, PublicActions<Transport, undefined | Chain>>) => client)) => Client<Transport, undefined | Chain, undefined, PublicRpcSchema, {
        [K in string | number | symbol]: client[K]
    } & PublicActions<Transport, undefined | Chain>>);
    getBalance: ((args: GetBalanceParameters) => Promise<bigint>);
    getBlobBaseFee: (() => Promise<bigint>);
    getBlock: (<TIncludeTransactions, TBlockTag>(args?: GetBlockParameters<TIncludeTransactions, TBlockTag>) => Promise<{
        baseFeePerGas: null | bigint;
        blobGasUsed: bigint;
        difficulty: bigint;
        excessBlobGas: bigint;
        extraData: `0x${string}`;
        gasLimit: bigint;
        gasUsed: bigint;
        hash: TBlockTag extends "pending"
            ? null
            : `0x${string}`;
        logsBloom: TBlockTag extends "pending"
            ? null
            : `0x${string}`;
        miner: `0x${string}`;
        mixHash: `0x${string}`;
        nonce: TBlockTag extends "pending"
            ? null
            : `0x${string}`;
        number: TBlockTag extends "pending"
            ? null
            : bigint;
        parentHash: `0x${string}`;
        receiptsRoot: `0x${string}`;
        sealFields: `0x${string}`[];
        sha3Uncles: `0x${string}`;
        size: bigint;
        stateRoot: `0x${string}`;
        timestamp: bigint;
        totalDifficulty: null | bigint;
        transactions: TIncludeTransactions extends true
            ? (
                | {
                    accessList?: undefined;
                    blobVersionedHashes?: undefined;
                    blockHash: (TBlockTag extends "pending"
                            ? true
                            : false) extends true
                        ? null
                        : `0x${string}`;
                    blockNumber: (TBlockTag extends "pending"
                            ? true
                            : false) extends true
                        ? null
                        : bigint;
                    chainId?: number;
                    from: `0x${string}`;
                    gas: bigint;
                    gasPrice: bigint;
                    hash: `0x${string}`;
                    input: `0x${string}`;
                    maxFeePerBlobGas?: undefined;
                    maxFeePerGas?: undefined;
                    maxPriorityFeePerGas?: undefined;
                    nonce: number;
                    r: `0x${string}`;
                    s: `0x${string}`;
                    to: null | `0x${string}`;
                    transactionIndex: (TBlockTag extends "pending"
                            ? true
                            : false) extends true
                        ? null
                        : number;
                    type: "legacy";
                    typeHex: null | `0x${string}`;
                    v: bigint;
                    value: bigint;
                    yParity?: undefined;
                }
                | {
                    accessList: AccessList;
                    blobVersionedHashes?: undefined;
                    blockHash: (TBlockTag extends "pending"
                            ? true
                            : false) extends true
                        ? null
                        : `0x${string}`;
                    blockNumber: (TBlockTag extends "pending"
                            ? true
                            : false) extends true
                        ? null
                        : bigint;
                    chainId: number;
                    from: `0x${string}`;
                    gas: bigint;
                    gasPrice: bigint;
                    hash: `0x${string}`;
                    input: `0x${string}`;
                    maxFeePerBlobGas?: undefined;
                    maxFeePerGas?: undefined;
                    maxPriorityFeePerGas?: undefined;
                    nonce: number;
                    r: `0x${string}`;
                    s: `0x${string}`;
                    to: null | `0x${string}`;
                    transactionIndex: (TBlockTag extends "pending"
                            ? true
                            : false) extends true
                        ? null
                        : number;
                    type: "eip2930";
                    typeHex: null | `0x${string}`;
                    v: bigint;
                    value: bigint;
                    yParity: number;
                }
                | {
                    accessList: AccessList;
                    blobVersionedHashes?: undefined;
                    blockHash: (TBlockTag extends "pending"
                            ? true
                            : false) extends true
                        ? null
                        : `0x${string}`;
                    blockNumber: (TBlockTag extends "pending"
                            ? true
                            : false) extends true
                        ? null
                        : bigint;
                    chainId: number;
                    from: `0x${string}`;
                    gas: bigint;
                    gasPrice?: undefined;
                    hash: `0x${string}`;
                    input: `0x${string}`;
                    maxFeePerBlobGas?: undefined;
                    maxFeePerGas: bigint;
                    maxPriorityFeePerGas: bigint;
                    nonce: number;
                    r: `0x${string}`;
                    s: `0x${string}`;
                    to: null | `0x${string}`;
                    transactionIndex: (TBlockTag extends "pending"
                            ? true
                            : false) extends true
                        ? null
                        : number;
                    type: "eip1559";
                    typeHex: null | `0x${string}`;
                    v: bigint;
                    value: bigint;
                    yParity: number;
                }
                | {
                    accessList: AccessList;
                    blobVersionedHashes: `0x${string}`[];
                    blockHash: (TBlockTag extends "pending"
                            ? true
                            : false) extends true
                        ? null
                        : `0x${string}`;
                    blockNumber: (TBlockTag extends "pending"
                            ? true
                            : false) extends true
                        ? null
                        : bigint;
                    chainId: number;
                    from: `0x${string}`;
                    gas: bigint;
                    gasPrice?: undefined;
                    hash: `0x${string}`;
                    input: `0x${string}`;
                    maxFeePerBlobGas: bigint;
                    maxFeePerGas: bigint;
                    maxPriorityFeePerGas: bigint;
                    nonce: number;
                    r: `0x${string}`;
                    s: `0x${string}`;
                    to: null | `0x${string}`;
                    transactionIndex: (TBlockTag extends "pending"
                            ? true
                            : false) extends true
                        ? null
                        : number;
                    type: "eip4844";
                    typeHex: null | `0x${string}`;
                    v: bigint;
                    value: bigint;
                    yParity: number;
                })[]
            : `0x${string}`[];
        transactionsRoot: `0x${string}`;
        uncles: `0x${string}`[];
        withdrawals?: Withdrawal[];
        withdrawalsRoot?: `0x${string}`;
    }>);
    getBlockNumber: ((args?: GetBlockNumberParameters) => Promise<bigint>);
    getBlockTransactionCount: ((args?: GetBlockTransactionCountParameters) => Promise<number>);
    getBytecode: ((args: GetBytecodeParameters) => Promise<GetBytecodeReturnType>);
    getChainId: (() => Promise<number>);
    getContractEvents: (<const abi, eventName, strict, fromBlock, toBlock>(args: GetContractEventsParameters<abi, eventName, strict, fromBlock, toBlock>) => Promise<GetContractEventsReturnType<abi, eventName, strict, fromBlock, toBlock>>);
    getEnsAddress: ((args: {
        blockNumber?: bigint;
        blockTag?: BlockTag;
        coinType?: number;
        gatewayUrls?: string[];
        name: string;
        strict?: boolean;
        universalResolverAddress?: `0x${string}`;
    }) => Promise<GetEnsAddressReturnType>);
    getEnsAvatar: ((args: {
        assetGatewayUrls?: AssetGatewayUrls;
        blockNumber?: bigint;
        blockTag?: BlockTag;
        gatewayUrls?: string[];
        name: string;
        strict?: boolean;
        universalResolverAddress?: `0x${string}`;
    }) => Promise<GetEnsAvatarReturnType>);
    getEnsName: ((args: {
        address: `0x${string}`;
        blockNumber?: bigint;
        blockTag?: BlockTag;
        gatewayUrls?: string[];
        strict?: boolean;
        universalResolverAddress?: `0x${string}`;
    }) => Promise<GetEnsNameReturnType>);
    getEnsResolver: ((args: {
        blockNumber?: bigint;
        blockTag?: BlockTag;
        name: string;
        universalResolverAddress?: `0x${string}`;
    }) => Promise<`0x${string}`>);
    getEnsText: ((args: {
        blockNumber?: bigint;
        blockTag?: BlockTag;
        gatewayUrls?: string[];
        key: string;
        name: string;
        strict?: boolean;
        universalResolverAddress?: `0x${string}`;
    }) => Promise<GetEnsTextReturnType>);
    getFeeHistory: ((args: GetFeeHistoryParameters) => Promise<GetFeeHistoryReturnType>);
    getFilterChanges: (<TFilterType, const TAbi, TEventName, TStrict, TFromBlock, TToBlock>(args: GetFilterChangesParameters<TFilterType, TAbi, TEventName, TStrict, TFromBlock, TToBlock>) => Promise<GetFilterChangesReturnType<TFilterType, TAbi, TEventName, TStrict, TFromBlock, TToBlock>>);
    getFilterLogs: (<const TAbi, TEventName, TStrict, TFromBlock, TToBlock>(args: GetFilterLogsParameters<TAbi, TEventName, TStrict, TFromBlock, TToBlock>) => Promise<GetFilterLogsReturnType<TAbi, TEventName, TStrict, TFromBlock, TToBlock>>);
    getGasPrice: (() => Promise<bigint>);
    getLogs: (<const TAbiEvent, const TAbiEvents, TStrict, TFromBlock, TToBlock>(args?: GetLogsParameters<TAbiEvent, TAbiEvents, TStrict, TFromBlock, TToBlock>) => Promise<GetLogsReturnType<TAbiEvent, TAbiEvents, TStrict, TFromBlock, TToBlock>>);
    getProof: ((args: GetProofParameters) => Promise<GetProofReturnType>);
    getStorageAt: ((args: GetStorageAtParameters) => Promise<GetStorageAtReturnType>);
    getTransaction: (<TBlockTag>(args: GetTransactionParameters<TBlockTag>) => Promise<
        | {
            accessList?: undefined;
            blobVersionedHashes?: undefined;
            blockHash: (TBlockTag extends "pending"
                    ? true
                    : false) extends true
                ? null
                : `0x${string}`;
            blockNumber: (TBlockTag extends "pending"
                    ? true
                    : false) extends true
                ? null
                : bigint;
            chainId?: number;
            from: `0x${string}`;
            gas: bigint;
            gasPrice: bigint;
            hash: `0x${string}`;
            input: `0x${string}`;
            maxFeePerBlobGas?: undefined;
            maxFeePerGas?: undefined;
            maxPriorityFeePerGas?: undefined;
            nonce: number;
            r: `0x${string}`;
            s: `0x${string}`;
            to: null | `0x${string}`;
            transactionIndex: (TBlockTag extends "pending"
                    ? true
                    : false) extends true
                ? null
                : number;
            type: "legacy";
            typeHex: null | `0x${string}`;
            v: bigint;
            value: bigint;
            yParity?: undefined;
        }
        | {
            accessList: AccessList;
            blobVersionedHashes?: undefined;
            blockHash: (TBlockTag extends "pending"
                    ? true
                    : false) extends true
                ? null
                : `0x${string}`;
            blockNumber: (TBlockTag extends "pending"
                    ? true
                    : false) extends true
                ? null
                : bigint;
            chainId: number;
            from: `0x${string}`;
            gas: bigint;
            gasPrice: bigint;
            hash: `0x${string}`;
            input: `0x${string}`;
            maxFeePerBlobGas?: undefined;
            maxFeePerGas?: undefined;
            maxPriorityFeePerGas?: undefined;
            nonce: number;
            r: `0x${string}`;
            s: `0x${string}`;
            to: null | `0x${string}`;
            transactionIndex: (TBlockTag extends "pending"
                    ? true
                    : false) extends true
                ? null
                : number;
            type: "eip2930";
            typeHex: null | `0x${string}`;
            v: bigint;
            value: bigint;
            yParity: number;
        }
        | {
            accessList: AccessList;
            blobVersionedHashes?: undefined;
            blockHash: (TBlockTag extends "pending"
                    ? true
                    : false) extends true
                ? null
                : `0x${string}`;
            blockNumber: (TBlockTag extends "pending"
                    ? true
                    : false) extends true
                ? null
                : bigint;
            chainId: number;
            from: `0x${string}`;
            gas: bigint;
            gasPrice?: undefined;
            hash: `0x${string}`;
            input: `0x${string}`;
            maxFeePerBlobGas?: undefined;
            maxFeePerGas: bigint;
            maxPriorityFeePerGas: bigint;
            nonce: number;
            r: `0x${string}`;
            s: `0x${string}`;
            to: null | `0x${string}`;
            transactionIndex: (TBlockTag extends "pending"
                    ? true
                    : false) extends true
                ? null
                : number;
            type: "eip1559";
            typeHex: null | `0x${string}`;
            v: bigint;
            value: bigint;
            yParity: number;
        }
        | {
            accessList: AccessList;
            blobVersionedHashes: `0x${string}`[];
            blockHash: (TBlockTag extends "pending"
                    ? true
                    : false) extends true
                ? null
                : `0x${string}`;
            blockNumber: (TBlockTag extends "pending"
                    ? true
                    : false) extends true
                ? null
                : bigint;
            chainId: number;
            from: `0x${string}`;
            gas: bigint;
            gasPrice?: undefined;
            hash: `0x${string}`;
            input: `0x${string}`;
            maxFeePerBlobGas: bigint;
            maxFeePerGas: bigint;
            maxPriorityFeePerGas: bigint;
            nonce: number;
            r: `0x${string}`;
            s: `0x${string}`;
            to: null | `0x${string}`;
            transactionIndex: (TBlockTag extends "pending"
                    ? true
                    : false) extends true
                ? null
                : number;
            type: "eip4844";
            typeHex: null | `0x${string}`;
            v: bigint;
            value: bigint;
            yParity: number;
        }>);
    getTransactionConfirmations: ((args: GetTransactionConfirmationsParameters<undefined | Chain>) => Promise<bigint>);
    getTransactionCount: ((args: GetTransactionCountParameters) => Promise<number>);
    getTransactionReceipt: ((args: GetTransactionReceiptParameters) => Promise<TransactionReceipt>);
    key: string;
    multicall: (<const contracts, allowFailure>(args: MulticallParameters<contracts, allowFailure>) => Promise<MulticallReturnType<contracts, allowFailure>>);
    name: string;
    pollingInterval: number;
    prepareTransactionRequest: (<const TRequest, TChainOverride, TAccountOverride>(args: PrepareTransactionRequestParameters<undefined | Chain, undefined | Account, TChainOverride, TAccountOverride, TRequest>) => Promise<{
        [K in string | number | symbol]: (UnionRequiredBy<Extract<UnionOmit<(...), (...)> & ((...) extends (...)
            ? (...)
            : (...)) & ((...) extends (...)
            ? (...)
            : (...)), IsNever<(...)> extends true
            ? unknown
            : ExactPartial<(...)>> & {
            chainId?: number;
        }, ParameterTypeToParameters<TRequest["parameters"] extends PrepareTransactionRequestParameterType[]
            ? any[any][number]
            : PrepareTransactionRequestParameterType>> & (unknown extends TRequest["kzg"]
            ? {}
            : Pick<TRequest, "kzg">))[K]
    }>);
    readContract: (<const abi, functionName, args>(args: ReadContractParameters<abi, functionName, args>) => Promise<ReadContractReturnType<abi, functionName, args>>);
    request: EIP1193RequestFn<PublicRpcSchema>;
    sendRawTransaction: ((args: SendRawTransactionParameters) => Promise<`0x${string}`>);
    simulateContract: (<const abi, functionName, args, chainOverride, accountOverride>(args: SimulateContractParameters<abi, functionName, args, undefined | Chain, chainOverride, accountOverride>) => Promise<SimulateContractReturnType<abi, functionName, args, undefined | Chain, undefined | Account, chainOverride, accountOverride>>);
    transport: TransportConfig<string, EIP1193RequestFn> & Record<string, any>;
    type: string;
    uid: string;
    uninstallFilter: ((args: UninstallFilterParameters) => Promise<boolean>);
    verifyMessage: ((args: VerifyMessageParameters) => Promise<boolean>);
    verifyTypedData: ((args: VerifyTypedDataParameters) => Promise<boolean>);
    waitForTransactionReceipt: ((args: WaitForTransactionReceiptParameters<undefined | Chain>) => Promise<TransactionReceipt>);
    watchBlockNumber: ((args: WatchBlockNumberParameters) => WatchBlockNumberReturnType);
    watchBlocks: (<TIncludeTransactions, TBlockTag>(args: WatchBlocksParameters<Transport, undefined | Chain, TIncludeTransactions, TBlockTag>) => WatchBlocksReturnType);
    watchContractEvent: (<const TAbi, TEventName, TStrict>(args: WatchContractEventParameters<TAbi, TEventName, TStrict, Transport>) => WatchContractEventReturnType);
    watchEvent: (<const TAbiEvent, const TAbiEvents, TStrict>(args: WatchEventParameters<TAbiEvent, TAbiEvents, TStrict, Transport>) => WatchEventReturnType);
    watchPendingTransactions: ((args: WatchPendingTransactionsParameters<Transport>) => WatchPendingTransactionsReturnType);
}

The RPC provider the account uses to make RPC calls

Type declaration

  • account: undefined

    The Account of the Client.

  • Optionalbatch?: {
        multicall?: boolean | {
            batchSize?: number;
            wait?: number;
        };
    }

    Flags for batch settings.

    • Optionalmulticall?: boolean | {
          batchSize?: number;
          wait?: number;
      }

      Toggle to enable eth_call multicall aggregation.

  • cacheTime: number

    Time (in ms) that cached data will remain in memory.

  • call: ((parameters: CallParameters<undefined | Chain>) => Promise<CallReturnType>)

    Executes a new message call immediately without submitting a transaction to the network.

    import { createPublicClient, http } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const data = await client.call({
    account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
    data: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
    to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
    })
  • chain: undefined | Chain

    Chain for the client.

  • createBlockFilter: (() => Promise<{
        id: `0x${string}`;
        request: EIP1193RequestFn<readonly [{
            Method: "eth_getFilterChanges";
            Parameters: [filterId: `0x${string}`];
            ReturnType: `0x${string}`[] | RpcLog[];
        }, {
            Method: "eth_getFilterLogs";
            Parameters: [filterId: `0x${string}`];
            ReturnType: RpcLog[];
        }, {
            Method: "eth_uninstallFilter";
            Parameters: [filterId: `0x${string}`];
            ReturnType: boolean;
        }]>;
        type: "block";
    }>)

    Creates a Filter to listen for new block hashes that can be used with getFilterChanges.

    import { createPublicClient, createBlockFilter, http } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const filter = await createBlockFilter(client)
    // { id: "0x345a6572337856574a76364e457a4366", type: 'block' }
      • (): Promise<{
            id: `0x${string}`;
            request: EIP1193RequestFn<readonly [{
                Method: "eth_getFilterChanges";
                Parameters: [filterId: `0x${string}`];
                ReturnType: `0x${string}`[] | RpcLog[];
            }, {
                Method: "eth_getFilterLogs";
                Parameters: [filterId: `0x${string}`];
                ReturnType: RpcLog[];
            }, {
                Method: "eth_uninstallFilter";
                Parameters: [filterId: `0x${string}`];
                ReturnType: boolean;
            }]>;
            type: "block";
        }>
      • Returns Promise<{
            id: `0x${string}`;
            request: EIP1193RequestFn<readonly [{
                Method: "eth_getFilterChanges";
                Parameters: [filterId: `0x${string}`];
                ReturnType: `0x${string}`[] | RpcLog[];
            }, {
                Method: "eth_getFilterLogs";
                Parameters: [filterId: `0x${string}`];
                ReturnType: RpcLog[];
            }, {
                Method: "eth_uninstallFilter";
                Parameters: [filterId: `0x${string}`];
                ReturnType: boolean;
            }]>;
            type: "block";
        }>

        Filter. CreateBlockFilterReturnType

  • createContractEventFilter: (<const TAbi, TEventName, TArgs, TStrict, TFromBlock, TToBlock>(args: CreateContractEventFilterParameters<TAbi, TEventName, TArgs, TStrict, TFromBlock, TToBlock>) => Promise<CreateContractEventFilterReturnType<TAbi, TEventName, TArgs, TStrict, TFromBlock, TToBlock>>)

    Creates a Filter to retrieve event logs that can be used with getFilterChanges or getFilterLogs.

    import { createPublicClient, http, parseAbi } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const filter = await client.createContractEventFilter({
    abi: parseAbi(['event Transfer(address indexed, address indexed, uint256)']),
    })
  • createEventFilter: (<const TAbiEvent, const TAbiEvents, TStrict, TFromBlock, TToBlock, _EventName, _Args>(args?: CreateEventFilterParameters<TAbiEvent, TAbiEvents, TStrict, TFromBlock, TToBlock, _EventName, _Args>) => Promise<{
        [K in string | number | symbol]: Filter<"event", TAbiEvents, _EventName, _Args, TStrict, TFromBlock, TToBlock>[K]
    }>)

    Creates a Filter to listen for new events that can be used with getFilterChanges.

    import { createPublicClient, http } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const filter = await client.createEventFilter({
    address: '0xfba3912ca04dd458c843e2ee08967fc04f3579c2',
    })
  • createPendingTransactionFilter: (() => Promise<{
        id: `0x${string}`;
        request: EIP1193RequestFn<readonly [{
            Method: "eth_getFilterChanges";
            Parameters: [filterId: `0x${string}`];
            ReturnType: `0x${string}`[] | RpcLog[];
        }, {
            Method: "eth_getFilterLogs";
            Parameters: [filterId: `0x${string}`];
            ReturnType: RpcLog[];
        }, {
            Method: "eth_uninstallFilter";
            Parameters: [filterId: `0x${string}`];
            ReturnType: boolean;
        }]>;
        type: "transaction";
    }>)

    Creates a Filter to listen for new pending transaction hashes that can be used with getFilterChanges.

    import { createPublicClient, http } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const filter = await client.createPendingTransactionFilter()
    // { id: "0x345a6572337856574a76364e457a4366", type: 'transaction' }
      • (): Promise<{
            id: `0x${string}`;
            request: EIP1193RequestFn<readonly [{
                Method: "eth_getFilterChanges";
                Parameters: [filterId: `0x${string}`];
                ReturnType: `0x${string}`[] | RpcLog[];
            }, {
                Method: "eth_getFilterLogs";
                Parameters: [filterId: `0x${string}`];
                ReturnType: RpcLog[];
            }, {
                Method: "eth_uninstallFilter";
                Parameters: [filterId: `0x${string}`];
                ReturnType: boolean;
            }]>;
            type: "transaction";
        }>
      • Returns Promise<{
            id: `0x${string}`;
            request: EIP1193RequestFn<readonly [{
                Method: "eth_getFilterChanges";
                Parameters: [filterId: `0x${string}`];
                ReturnType: `0x${string}`[] | RpcLog[];
            }, {
                Method: "eth_getFilterLogs";
                Parameters: [filterId: `0x${string}`];
                ReturnType: RpcLog[];
            }, {
                Method: "eth_uninstallFilter";
                Parameters: [filterId: `0x${string}`];
                ReturnType: boolean;
            }]>;
            type: "transaction";
        }>

        Filter. CreateBlockFilterReturnType

  • estimateContractGas: (<TChain, const abi, functionName, args>(args: EstimateContractGasParameters<abi, functionName, args, TChain>) => Promise<bigint>)

    Estimates the gas required to successfully execute a contract write function call.

    Internally, uses a Public Client to call the estimateGas action with ABI-encoded data.

    import { createPublicClient, http, parseAbi } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const gas = await client.estimateContractGas({
    address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
    abi: parseAbi(['function mint() public']),
    functionName: 'mint',
    account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
    })
  • estimateFeesPerGas: (<TChainOverride, TType>(args?: EstimateFeesPerGasParameters<undefined | Chain, TChainOverride, TType>) => Promise<EstimateFeesPerGasReturnType>)

    Returns an estimate for the fees per gas for a transaction to be included in the next block.

    import { createPublicClient, http } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const maxPriorityFeePerGas = await client.estimateFeesPerGas()
    // { maxFeePerGas: ..., maxPriorityFeePerGas: ... }
  • estimateGas: ((args: EstimateGasParameters<undefined | Chain>) => Promise<bigint>)

    Estimates the gas necessary to complete a transaction without submitting it to the network.

    import { createPublicClient, http, parseEther } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const gasEstimate = await client.estimateGas({
    account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
    to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
    value: parseEther('1'),
    })
  • estimateMaxPriorityFeePerGas: (<TChainOverride>(args?: {
        chain: null | TChainOverride;
    }) => Promise<bigint>)

    Returns an estimate for the max priority fee per gas (in wei) for a transaction to be included in the next block.

    import { createPublicClient, http } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const maxPriorityFeePerGas = await client.estimateMaxPriorityFeePerGas()
    // 10000000n
  • extend: (<const client>(fn: ((client: Client<Transport, undefined | Chain, undefined, PublicRpcSchema, PublicActions<Transport, undefined | Chain>>) => client)) => Client<Transport, undefined | Chain, undefined, PublicRpcSchema, {
        [K in string | number | symbol]: client[K]
    } & PublicActions<Transport, undefined | Chain>>)
  • getBalance: ((args: GetBalanceParameters) => Promise<bigint>)

    Returns the balance of an address in wei.

    You can convert the balance to ether units with formatEther.

    const balance = await getBalance(client, {
    address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
    blockTag: 'safe'
    })
    const balanceAsEther = formatEther(balance)
    // "6.942"
    import { createPublicClient, http } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const balance = await client.getBalance({
    address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
    })
    // 10000000000000000000000n (wei)
  • getBlobBaseFee: (() => Promise<bigint>)

    Returns the base fee per blob gas in wei.

    import { createPublicClient, http } from 'viem'
    import { mainnet } from 'viem/chains'
    import { getBlobBaseFee } from 'viem/public'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const blobBaseFee = await client.getBlobBaseFee()
  • getBlock: (<TIncludeTransactions, TBlockTag>(args?: GetBlockParameters<TIncludeTransactions, TBlockTag>) => Promise<{
        baseFeePerGas: null | bigint;
        blobGasUsed: bigint;
        difficulty: bigint;
        excessBlobGas: bigint;
        extraData: `0x${string}`;
        gasLimit: bigint;
        gasUsed: bigint;
        hash: TBlockTag extends "pending"
            ? null
            : `0x${string}`;
        logsBloom: TBlockTag extends "pending"
            ? null
            : `0x${string}`;
        miner: `0x${string}`;
        mixHash: `0x${string}`;
        nonce: TBlockTag extends "pending"
            ? null
            : `0x${string}`;
        number: TBlockTag extends "pending"
            ? null
            : bigint;
        parentHash: `0x${string}`;
        receiptsRoot: `0x${string}`;
        sealFields: `0x${string}`[];
        sha3Uncles: `0x${string}`;
        size: bigint;
        stateRoot: `0x${string}`;
        timestamp: bigint;
        totalDifficulty: null | bigint;
        transactions: TIncludeTransactions extends true
            ? (
                | {
                    accessList?: undefined;
                    blobVersionedHashes?: undefined;
                    blockHash: (TBlockTag extends "pending"
                            ? true
                            : false) extends true
                        ? null
                        : `0x${string}`;
                    blockNumber: (TBlockTag extends "pending"
                            ? true
                            : false) extends true
                        ? null
                        : bigint;
                    chainId?: number;
                    from: `0x${string}`;
                    gas: bigint;
                    gasPrice: bigint;
                    hash: `0x${string}`;
                    input: `0x${string}`;
                    maxFeePerBlobGas?: undefined;
                    maxFeePerGas?: undefined;
                    maxPriorityFeePerGas?: undefined;
                    nonce: number;
                    r: `0x${string}`;
                    s: `0x${string}`;
                    to: null | `0x${string}`;
                    transactionIndex: (TBlockTag extends "pending"
                            ? true
                            : false) extends true
                        ? null
                        : number;
                    type: "legacy";
                    typeHex: null | `0x${string}`;
                    v: bigint;
                    value: bigint;
                    yParity?: undefined;
                }
                | {
                    accessList: AccessList;
                    blobVersionedHashes?: undefined;
                    blockHash: (TBlockTag extends "pending"
                            ? true
                            : false) extends true
                        ? null
                        : `0x${string}`;
                    blockNumber: (TBlockTag extends "pending"
                            ? true
                            : false) extends true
                        ? null
                        : bigint;
                    chainId: number;
                    from: `0x${string}`;
                    gas: bigint;
                    gasPrice: bigint;
                    hash: `0x${string}`;
                    input: `0x${string}`;
                    maxFeePerBlobGas?: undefined;
                    maxFeePerGas?: undefined;
                    maxPriorityFeePerGas?: undefined;
                    nonce: number;
                    r: `0x${string}`;
                    s: `0x${string}`;
                    to: null | `0x${string}`;
                    transactionIndex: (TBlockTag extends "pending"
                            ? true
                            : false) extends true
                        ? null
                        : number;
                    type: "eip2930";
                    typeHex: null | `0x${string}`;
                    v: bigint;
                    value: bigint;
                    yParity: number;
                }
                | {
                    accessList: AccessList;
                    blobVersionedHashes?: undefined;
                    blockHash: (TBlockTag extends "pending"
                            ? true
                            : false) extends true
                        ? null
                        : `0x${string}`;
                    blockNumber: (TBlockTag extends "pending"
                            ? true
                            : false) extends true
                        ? null
                        : bigint;
                    chainId: number;
                    from: `0x${string}`;
                    gas: bigint;
                    gasPrice?: undefined;
                    hash: `0x${string}`;
                    input: `0x${string}`;
                    maxFeePerBlobGas?: undefined;
                    maxFeePerGas: bigint;
                    maxPriorityFeePerGas: bigint;
                    nonce: number;
                    r: `0x${string}`;
                    s: `0x${string}`;
                    to: null | `0x${string}`;
                    transactionIndex: (TBlockTag extends "pending"
                            ? true
                            : false) extends true
                        ? null
                        : number;
                    type: "eip1559";
                    typeHex: null | `0x${string}`;
                    v: bigint;
                    value: bigint;
                    yParity: number;
                }
                | {
                    accessList: AccessList;
                    blobVersionedHashes: `0x${string}`[];
                    blockHash: (TBlockTag extends "pending"
                            ? true
                            : false) extends true
                        ? null
                        : `0x${string}`;
                    blockNumber: (TBlockTag extends "pending"
                            ? true
                            : false) extends true
                        ? null
                        : bigint;
                    chainId: number;
                    from: `0x${string}`;
                    gas: bigint;
                    gasPrice?: undefined;
                    hash: `0x${string}`;
                    input: `0x${string}`;
                    maxFeePerBlobGas: bigint;
                    maxFeePerGas: bigint;
                    maxPriorityFeePerGas: bigint;
                    nonce: number;
                    r: `0x${string}`;
                    s: `0x${string}`;
                    to: null | `0x${string}`;
                    transactionIndex: (TBlockTag extends "pending"
                            ? true
                            : false) extends true
                        ? null
                        : number;
                    type: "eip4844";
                    typeHex: null | `0x${string}`;
                    v: bigint;
                    value: bigint;
                    yParity: number;
                })[]
            : `0x${string}`[];
        transactionsRoot: `0x${string}`;
        uncles: `0x${string}`[];
        withdrawals?: Withdrawal[];
        withdrawalsRoot?: `0x${string}`;
    }>)

    Returns information about a block at a block number, hash, or tag.

    import { createPublicClient, http } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const block = await client.getBlock()
      • <TIncludeTransactions, TBlockTag>(args?): Promise<{
            baseFeePerGas: null | bigint;
            blobGasUsed: bigint;
            difficulty: bigint;
            excessBlobGas: bigint;
            extraData: `0x${string}`;
            gasLimit: bigint;
            gasUsed: bigint;
            hash: TBlockTag extends "pending"
                ? null
                : `0x${string}`;
            logsBloom: TBlockTag extends "pending"
                ? null
                : `0x${string}`;
            miner: `0x${string}`;
            mixHash: `0x${string}`;
            nonce: TBlockTag extends "pending"
                ? null
                : `0x${string}`;
            number: TBlockTag extends "pending"
                ? null
                : bigint;
            parentHash: `0x${string}`;
            receiptsRoot: `0x${string}`;
            sealFields: `0x${string}`[];
            sha3Uncles: `0x${string}`;
            size: bigint;
            stateRoot: `0x${string}`;
            timestamp: bigint;
            totalDifficulty: null | bigint;
            transactions: TIncludeTransactions extends true
                ? (
                    | {
                        accessList?: undefined;
                        blobVersionedHashes?: undefined;
                        blockHash: (TBlockTag extends "pending"
                                ? true
                                : false) extends true
                            ? null
                            : `0x${string}`;
                        blockNumber: (TBlockTag extends "pending"
                                ? true
                                : false) extends true
                            ? null
                            : bigint;
                        chainId?: number;
                        from: `0x${string}`;
                        gas: bigint;
                        gasPrice: bigint;
                        hash: `0x${string}`;
                        input: `0x${string}`;
                        maxFeePerBlobGas?: undefined;
                        maxFeePerGas?: undefined;
                        maxPriorityFeePerGas?: undefined;
                        nonce: number;
                        r: `0x${string}`;
                        s: `0x${string}`;
                        to: null | `0x${string}`;
                        transactionIndex: (TBlockTag extends "pending"
                                ? true
                                : false) extends true
                            ? null
                            : number;
                        type: "legacy";
                        typeHex: null | `0x${string}`;
                        v: bigint;
                        value: bigint;
                        yParity?: undefined;
                    }
                    | {
                        accessList: AccessList;
                        blobVersionedHashes?: undefined;
                        blockHash: (TBlockTag extends "pending"
                                ? true
                                : false) extends true
                            ? null
                            : `0x${string}`;
                        blockNumber: (TBlockTag extends "pending"
                                ? true
                                : false) extends true
                            ? null
                            : bigint;
                        chainId: number;
                        from: `0x${string}`;
                        gas: bigint;
                        gasPrice: bigint;
                        hash: `0x${string}`;
                        input: `0x${string}`;
                        maxFeePerBlobGas?: undefined;
                        maxFeePerGas?: undefined;
                        maxPriorityFeePerGas?: undefined;
                        nonce: number;
                        r: `0x${string}`;
                        s: `0x${string}`;
                        to: null | `0x${string}`;
                        transactionIndex: (TBlockTag extends "pending"
                                ? true
                                : false) extends true
                            ? null
                            : number;
                        type: "eip2930";
                        typeHex: null | `0x${string}`;
                        v: bigint;
                        value: bigint;
                        yParity: number;
                    }
                    | {
                        accessList: AccessList;
                        blobVersionedHashes?: undefined;
                        blockHash: (TBlockTag extends "pending"
                                ? true
                                : false) extends true
                            ? null
                            : `0x${string}`;
                        blockNumber: (TBlockTag extends "pending"
                                ? true
                                : false) extends true
                            ? null
                            : bigint;
                        chainId: number;
                        from: `0x${string}`;
                        gas: bigint;
                        gasPrice?: undefined;
                        hash: `0x${string}`;
                        input: `0x${string}`;
                        maxFeePerBlobGas?: undefined;
                        maxFeePerGas: bigint;
                        maxPriorityFeePerGas: bigint;
                        nonce: number;
                        r: `0x${string}`;
                        s: `0x${string}`;
                        to: null | `0x${string}`;
                        transactionIndex: (TBlockTag extends "pending"
                                ? true
                                : false) extends true
                            ? null
                            : number;
                        type: "eip1559";
                        typeHex: null | `0x${string}`;
                        v: bigint;
                        value: bigint;
                        yParity: number;
                    }
                    | {
                        accessList: AccessList;
                        blobVersionedHashes: `0x${string}`[];
                        blockHash: (TBlockTag extends "pending"
                                ? true
                                : false) extends true
                            ? null
                            : `0x${string}`;
                        blockNumber: (TBlockTag extends "pending"
                                ? true
                                : false) extends true
                            ? null
                            : bigint;
                        chainId: number;
                        from: `0x${string}`;
                        gas: bigint;
                        gasPrice?: undefined;
                        hash: `0x${string}`;
                        input: `0x${string}`;
                        maxFeePerBlobGas: bigint;
                        maxFeePerGas: bigint;
                        maxPriorityFeePerGas: bigint;
                        nonce: number;
                        r: `0x${string}`;
                        s: `0x${string}`;
                        to: null | `0x${string}`;
                        transactionIndex: (TBlockTag extends "pending"
                                ? true
                                : false) extends true
                            ? null
                            : number;
                        type: "eip4844";
                        typeHex: null | `0x${string}`;
                        v: bigint;
                        value: bigint;
                        yParity: number;
                    })[]
                : `0x${string}`[];
            transactionsRoot: `0x${string}`;
            uncles: `0x${string}`[];
            withdrawals?: Withdrawal[];
            withdrawalsRoot?: `0x${string}`;
        }>
      • Type Parameters

        • TIncludeTransactions extends boolean = false
        • TBlockTag extends BlockTag = "latest"

        Returns Promise<{
            baseFeePerGas: null | bigint;
            blobGasUsed: bigint;
            difficulty: bigint;
            excessBlobGas: bigint;
            extraData: `0x${string}`;
            gasLimit: bigint;
            gasUsed: bigint;
            hash: TBlockTag extends "pending"
                ? null
                : `0x${string}`;
            logsBloom: TBlockTag extends "pending"
                ? null
                : `0x${string}`;
            miner: `0x${string}`;
            mixHash: `0x${string}`;
            nonce: TBlockTag extends "pending"
                ? null
                : `0x${string}`;
            number: TBlockTag extends "pending"
                ? null
                : bigint;
            parentHash: `0x${string}`;
            receiptsRoot: `0x${string}`;
            sealFields: `0x${string}`[];
            sha3Uncles: `0x${string}`;
            size: bigint;
            stateRoot: `0x${string}`;
            timestamp: bigint;
            totalDifficulty: null | bigint;
            transactions: TIncludeTransactions extends true
                ? (
                    | {
                        accessList?: undefined;
                        blobVersionedHashes?: undefined;
                        blockHash: (TBlockTag extends "pending"
                                ? true
                                : false) extends true
                            ? null
                            : `0x${string}`;
                        blockNumber: (TBlockTag extends "pending"
                                ? true
                                : false) extends true
                            ? null
                            : bigint;
                        chainId?: number;
                        from: `0x${string}`;
                        gas: bigint;
                        gasPrice: bigint;
                        hash: `0x${string}`;
                        input: `0x${string}`;
                        maxFeePerBlobGas?: undefined;
                        maxFeePerGas?: undefined;
                        maxPriorityFeePerGas?: undefined;
                        nonce: number;
                        r: `0x${string}`;
                        s: `0x${string}`;
                        to: null | `0x${string}`;
                        transactionIndex: (TBlockTag extends "pending"
                                ? true
                                : false) extends true
                            ? null
                            : number;
                        type: "legacy";
                        typeHex: null | `0x${string}`;
                        v: bigint;
                        value: bigint;
                        yParity?: undefined;
                    }
                    | {
                        accessList: AccessList;
                        blobVersionedHashes?: undefined;
                        blockHash: (TBlockTag extends "pending"
                                ? true
                                : false) extends true
                            ? null
                            : `0x${string}`;
                        blockNumber: (TBlockTag extends "pending"
                                ? true
                                : false) extends true
                            ? null
                            : bigint;
                        chainId: number;
                        from: `0x${string}`;
                        gas: bigint;
                        gasPrice: bigint;
                        hash: `0x${string}`;
                        input: `0x${string}`;
                        maxFeePerBlobGas?: undefined;
                        maxFeePerGas?: undefined;
                        maxPriorityFeePerGas?: undefined;
                        nonce: number;
                        r: `0x${string}`;
                        s: `0x${string}`;
                        to: null | `0x${string}`;
                        transactionIndex: (TBlockTag extends "pending"
                                ? true
                                : false) extends true
                            ? null
                            : number;
                        type: "eip2930";
                        typeHex: null | `0x${string}`;
                        v: bigint;
                        value: bigint;
                        yParity: number;
                    }
                    | {
                        accessList: AccessList;
                        blobVersionedHashes?: undefined;
                        blockHash: (TBlockTag extends "pending"
                                ? true
                                : false) extends true
                            ? null
                            : `0x${string}`;
                        blockNumber: (TBlockTag extends "pending"
                                ? true
                                : false) extends true
                            ? null
                            : bigint;
                        chainId: number;
                        from: `0x${string}`;
                        gas: bigint;
                        gasPrice?: undefined;
                        hash: `0x${string}`;
                        input: `0x${string}`;
                        maxFeePerBlobGas?: undefined;
                        maxFeePerGas: bigint;
                        maxPriorityFeePerGas: bigint;
                        nonce: number;
                        r: `0x${string}`;
                        s: `0x${string}`;
                        to: null | `0x${string}`;
                        transactionIndex: (TBlockTag extends "pending"
                                ? true
                                : false) extends true
                            ? null
                            : number;
                        type: "eip1559";
                        typeHex: null | `0x${string}`;
                        v: bigint;
                        value: bigint;
                        yParity: number;
                    }
                    | {
                        accessList: AccessList;
                        blobVersionedHashes: `0x${string}`[];
                        blockHash: (TBlockTag extends "pending"
                                ? true
                                : false) extends true
                            ? null
                            : `0x${string}`;
                        blockNumber: (TBlockTag extends "pending"
                                ? true
                                : false) extends true
                            ? null
                            : bigint;
                        chainId: number;
                        from: `0x${string}`;
                        gas: bigint;
                        gasPrice?: undefined;
                        hash: `0x${string}`;
                        input: `0x${string}`;
                        maxFeePerBlobGas: bigint;
                        maxFeePerGas: bigint;
                        maxPriorityFeePerGas: bigint;
                        nonce: number;
                        r: `0x${string}`;
                        s: `0x${string}`;
                        to: null | `0x${string}`;
                        transactionIndex: (TBlockTag extends "pending"
                                ? true
                                : false) extends true
                            ? null
                            : number;
                        type: "eip4844";
                        typeHex: null | `0x${string}`;
                        v: bigint;
                        value: bigint;
                        yParity: number;
                    })[]
                : `0x${string}`[];
            transactionsRoot: `0x${string}`;
            uncles: `0x${string}`[];
            withdrawals?: Withdrawal[];
            withdrawalsRoot?: `0x${string}`;
        }>

        Information about the block. GetBlockReturnType

  • getBlockNumber: ((args?: GetBlockNumberParameters) => Promise<bigint>)
    import { createPublicClient, http } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const blockNumber = await client.getBlockNumber()
    // 69420n
  • getBlockTransactionCount: ((args?: GetBlockTransactionCountParameters) => Promise<number>)

    Returns the number of Transactions at a block number, hash, or tag.

    import { createPublicClient, http } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const count = await client.getBlockTransactionCount()
  • getBytecode: ((args: GetBytecodeParameters) => Promise<GetBytecodeReturnType>)

    Retrieves the bytecode at an address.

    import { createPublicClient, http } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const code = await client.getBytecode({
    address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
    })
  • getChainId: (() => Promise<number>)

    Returns the chain ID associated with the current network.

    import { createPublicClient, http } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const chainId = await client.getChainId()
    // 1
  • getContractEvents: (<const abi, eventName, strict, fromBlock, toBlock>(args: GetContractEventsParameters<abi, eventName, strict, fromBlock, toBlock>) => Promise<GetContractEventsReturnType<abi, eventName, strict, fromBlock, toBlock>>)

    Returns a list of event logs emitted by a contract.

    import { createPublicClient, http } from 'viem'
    import { mainnet } from 'viem/chains'
    import { wagmiAbi } from './abi'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const logs = await client.getContractEvents(client, {
    address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
    abi: wagmiAbi,
    eventName: 'Transfer'
    })
  • getEnsAddress: ((args: {
        blockNumber?: bigint;
        blockTag?: BlockTag;
        coinType?: number;
        gatewayUrls?: string[];
        name: string;
        strict?: boolean;
        universalResolverAddress?: `0x${string}`;
    }) => Promise<GetEnsAddressReturnType>)

    Calls resolve(bytes, bytes) on ENS Universal Resolver Contract.

    Since ENS names prohibit certain forbidden characters (e.g. underscore) and have other validation rules, you likely want to normalize ENS names with UTS-46 normalization before passing them to getEnsAddress. You can use the built-in normalize function for this.

    import { createPublicClient, http } from 'viem'
    import { mainnet } from 'viem/chains'
    import { normalize } from 'viem/ens'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const ensAddress = await client.getEnsAddress({
    name: normalize('wevm.eth'),
    })
    // '0xd2135CfB216b74109775236E36d4b433F1DF507B'
      • (args): Promise<GetEnsAddressReturnType>
      • Parameters

        • args: {
              blockNumber?: bigint;
              blockTag?: BlockTag;
              coinType?: number;
              gatewayUrls?: string[];
              name: string;
              strict?: boolean;
              universalResolverAddress?: `0x${string}`;
          }
          • OptionalblockNumber?: bigint

            The balance of the account at a block number.

          • OptionalblockTag?: BlockTag

            The balance of the account at a block tag.

            'latest'
            
          • OptionalcoinType?: number

            ENSIP-9 compliant coinType used to resolve addresses for other chains

          • OptionalgatewayUrls?: string[]

            Universal Resolver gateway URLs to use for resolving CCIP-read requests.

          • name: string

            Name to get the address for.

          • Optionalstrict?: boolean

            Whether or not to throw errors propagated from the ENS Universal Resolver Contract.

          • OptionaluniversalResolverAddress?: `0x${string}`

            Address of ENS Universal Resolver Contract.

        Returns Promise<GetEnsAddressReturnType>

        Address for ENS name or null if not found. GetEnsAddressReturnType

  • getEnsAvatar: ((args: {
        assetGatewayUrls?: AssetGatewayUrls;
        blockNumber?: bigint;
        blockTag?: BlockTag;
        gatewayUrls?: string[];
        name: string;
        strict?: boolean;
        universalResolverAddress?: `0x${string}`;
    }) => Promise<GetEnsAvatarReturnType>)

    Calls getEnsText with key set to 'avatar'.

    Since ENS names prohibit certain forbidden characters (e.g. underscore) and have other validation rules, you likely want to normalize ENS names with UTS-46 normalization before passing them to getEnsAddress. You can use the built-in normalize function for this.

    import { createPublicClient, http } from 'viem'
    import { mainnet } from 'viem/chains'
    import { normalize } from 'viem/ens'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const ensAvatar = await client.getEnsAvatar({
    name: normalize('wevm.eth'),
    })
    // 'https://ipfs.io/ipfs/Qma8mnp6xV3J2cRNf3mTth5C8nV11CAnceVinc3y8jSbio'
      • (args): Promise<GetEnsAvatarReturnType>
      • Parameters

        • args: {
              assetGatewayUrls?: AssetGatewayUrls;
              blockNumber?: bigint;
              blockTag?: BlockTag;
              gatewayUrls?: string[];
              name: string;
              strict?: boolean;
              universalResolverAddress?: `0x${string}`;
          }
          • OptionalassetGatewayUrls?: AssetGatewayUrls

            Gateway urls to resolve IPFS and/or Arweave assets.

          • OptionalblockNumber?: bigint

            The balance of the account at a block number.

          • OptionalblockTag?: BlockTag

            The balance of the account at a block tag.

            'latest'
            
          • OptionalgatewayUrls?: string[]

            Universal Resolver gateway URLs to use for resolving CCIP-read requests.

          • name: string

            ENS name to get Text for.

          • Optionalstrict?: boolean

            Whether or not to throw errors propagated from the ENS Universal Resolver Contract.

          • OptionaluniversalResolverAddress?: `0x${string}`

            Address of ENS Universal Resolver Contract.

        Returns Promise<GetEnsAvatarReturnType>

        Avatar URI or null if not found. GetEnsAvatarReturnType

  • getEnsName: ((args: {
        address: `0x${string}`;
        blockNumber?: bigint;
        blockTag?: BlockTag;
        gatewayUrls?: string[];
        strict?: boolean;
        universalResolverAddress?: `0x${string}`;
    }) => Promise<GetEnsNameReturnType>)

    Calls reverse(bytes) on ENS Universal Resolver Contract to "reverse resolve" the address to the primary ENS name.

    import { createPublicClient, http } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const ensName = await client.getEnsName({
    address: '0xd2135CfB216b74109775236E36d4b433F1DF507B',
    })
    // 'wevm.eth'
      • (args): Promise<GetEnsNameReturnType>
      • Parameters

        • args: {
              address: `0x${string}`;
              blockNumber?: bigint;
              blockTag?: BlockTag;
              gatewayUrls?: string[];
              strict?: boolean;
              universalResolverAddress?: `0x${string}`;
          }
          • address: `0x${string}`

            Address to get ENS name for.

          • OptionalblockNumber?: bigint

            The balance of the account at a block number.

          • OptionalblockTag?: BlockTag

            The balance of the account at a block tag.

            'latest'
            
          • OptionalgatewayUrls?: string[]

            Universal Resolver gateway URLs to use for resolving CCIP-read requests.

          • Optionalstrict?: boolean

            Whether or not to throw errors propagated from the ENS Universal Resolver Contract.

          • OptionaluniversalResolverAddress?: `0x${string}`

            Address of ENS Universal Resolver Contract.

        Returns Promise<GetEnsNameReturnType>

        Name or null if not found. GetEnsNameReturnType

  • getEnsResolver: ((args: {
        blockNumber?: bigint;
        blockTag?: BlockTag;
        name: string;
        universalResolverAddress?: `0x${string}`;
    }) => Promise<`0x${string}`>)

    Calls findResolver(bytes) on ENS Universal Resolver Contract to retrieve the resolver of an ENS name.

    Since ENS names prohibit certain forbidden characters (e.g. underscore) and have other validation rules, you likely want to normalize ENS names with UTS-46 normalization before passing them to getEnsAddress. You can use the built-in normalize function for this.

    import { createPublicClient, http } from 'viem'
    import { mainnet } from 'viem/chains'
    import { normalize } from 'viem/ens'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const resolverAddress = await client.getEnsResolver({
    name: normalize('wevm.eth'),
    })
    // '0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41'
      • (args): Promise<`0x${string}`>
      • Parameters

        • args: {
              blockNumber?: bigint;
              blockTag?: BlockTag;
              name: string;
              universalResolverAddress?: `0x${string}`;
          }
          • OptionalblockNumber?: bigint

            The balance of the account at a block number.

          • OptionalblockTag?: BlockTag

            The balance of the account at a block tag.

            'latest'
            
          • name: string

            Name to get the address for.

          • OptionaluniversalResolverAddress?: `0x${string}`

            Address of ENS Universal Resolver Contract.

        Returns Promise<`0x${string}`>

        Address for ENS resolver. GetEnsResolverReturnType

  • getEnsText: ((args: {
        blockNumber?: bigint;
        blockTag?: BlockTag;
        gatewayUrls?: string[];
        key: string;
        name: string;
        strict?: boolean;
        universalResolverAddress?: `0x${string}`;
    }) => Promise<GetEnsTextReturnType>)

    Calls resolve(bytes, bytes) on ENS Universal Resolver Contract.

    Since ENS names prohibit certain forbidden characters (e.g. underscore) and have other validation rules, you likely want to normalize ENS names with UTS-46 normalization before passing them to getEnsAddress. You can use the built-in normalize function for this.

    import { createPublicClient, http } from 'viem'
    import { mainnet } from 'viem/chains'
    import { normalize } from 'viem/ens'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const twitterRecord = await client.getEnsText({
    name: normalize('wevm.eth'),
    key: 'com.twitter',
    })
    // 'wagmi_sh'
      • (args): Promise<GetEnsTextReturnType>
      • Parameters

        • args: {
              blockNumber?: bigint;
              blockTag?: BlockTag;
              gatewayUrls?: string[];
              key: string;
              name: string;
              strict?: boolean;
              universalResolverAddress?: `0x${string}`;
          }
          • OptionalblockNumber?: bigint

            The balance of the account at a block number.

          • OptionalblockTag?: BlockTag

            The balance of the account at a block tag.

            'latest'
            
          • OptionalgatewayUrls?: string[]

            Universal Resolver gateway URLs to use for resolving CCIP-read requests.

          • key: string

            Text record to retrieve.

          • name: string

            ENS name to get Text for.

          • Optionalstrict?: boolean

            Whether or not to throw errors propagated from the ENS Universal Resolver Contract.

          • OptionaluniversalResolverAddress?: `0x${string}`

            Address of ENS Universal Resolver Contract.

        Returns Promise<GetEnsTextReturnType>

        Address for ENS resolver. GetEnsTextReturnType

  • getFeeHistory: ((args: GetFeeHistoryParameters) => Promise<GetFeeHistoryReturnType>)

    Returns a collection of historical gas information.

    import { createPublicClient, http } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const feeHistory = await client.getFeeHistory({
    blockCount: 4,
    rewardPercentiles: [25, 75],
    })
  • getFilterChanges: (<TFilterType, const TAbi, TEventName, TStrict, TFromBlock, TToBlock>(args: GetFilterChangesParameters<TFilterType, TAbi, TEventName, TStrict, TFromBlock, TToBlock>) => Promise<GetFilterChangesReturnType<TFilterType, TAbi, TEventName, TStrict, TFromBlock, TToBlock>>)

    Returns a list of logs or hashes based on a Filter since the last time it was called.

    A Filter can be created from the following actions:

    Depending on the type of filter, the return value will be different:

    • If the filter was created with createContractEventFilter or createEventFilter, it returns a list of logs.
    • If the filter was created with createPendingTransactionFilter, it returns a list of transaction hashes.
    • If the filter was created with createBlockFilter, it returns a list of block hashes.
    // Blocks
    import { createPublicClient, http } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const filter = await client.createBlockFilter()
    const hashes = await client.getFilterChanges({ filter })
    // Contract Events
    import { createPublicClient, http, parseAbi } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const filter = await client.createContractEventFilter({
    address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
    abi: parseAbi(['event Transfer(address indexed, address indexed, uint256)']),
    eventName: 'Transfer',
    })
    const logs = await client.getFilterChanges({ filter })
    // Raw Events
    import { createPublicClient, http, parseAbiItem } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const filter = await client.createEventFilter({
    address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
    event: parseAbiItem('event Transfer(address indexed, address indexed, uint256)'),
    })
    const logs = await client.getFilterChanges({ filter })
    // Transactions
    import { createPublicClient, http } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const filter = await client.createPendingTransactionFilter()
    const hashes = await client.getFilterChanges({ filter })
  • getFilterLogs: (<const TAbi, TEventName, TStrict, TFromBlock, TToBlock>(args: GetFilterLogsParameters<TAbi, TEventName, TStrict, TFromBlock, TToBlock>) => Promise<GetFilterLogsReturnType<TAbi, TEventName, TStrict, TFromBlock, TToBlock>>)

    Returns a list of event logs since the filter was created.

    getFilterLogs is only compatible with event filters.

    import { createPublicClient, http, parseAbiItem } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const filter = await client.createEventFilter({
    address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
    event: parseAbiItem('event Transfer(address indexed, address indexed, uint256)'),
    })
    const logs = await client.getFilterLogs({ filter })
  • getGasPrice: (() => Promise<bigint>)

    Returns the current price of gas (in wei).

    import { createPublicClient, http } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const gasPrice = await client.getGasPrice()
  • getLogs: (<const TAbiEvent, const TAbiEvents, TStrict, TFromBlock, TToBlock>(args?: GetLogsParameters<TAbiEvent, TAbiEvents, TStrict, TFromBlock, TToBlock>) => Promise<GetLogsReturnType<TAbiEvent, TAbiEvents, TStrict, TFromBlock, TToBlock>>)

    Returns a list of event logs matching the provided parameters.

    import { createPublicClient, http, parseAbiItem } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const logs = await client.getLogs()
  • getProof: ((args: GetProofParameters) => Promise<GetProofReturnType>)

    Returns the account and storage values of the specified account including the Merkle-proof.

    import { createPublicClient, http } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const block = await client.getProof({
    address: '0x...',
    storageKeys: ['0x...'],
    })
  • getStorageAt: ((args: GetStorageAtParameters) => Promise<GetStorageAtReturnType>)

    Returns the value from a storage slot at a given address.

    import { createPublicClient, http } from 'viem'
    import { mainnet } from 'viem/chains'
    import { getStorageAt } from 'viem/contract'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const code = await client.getStorageAt({
    address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
    slot: toHex(0),
    })
  • getTransaction: (<TBlockTag>(args: GetTransactionParameters<TBlockTag>) => Promise<
        | {
            accessList?: undefined;
            blobVersionedHashes?: undefined;
            blockHash: (TBlockTag extends "pending"
                    ? true
                    : false) extends true
                ? null
                : `0x${string}`;
            blockNumber: (TBlockTag extends "pending"
                    ? true
                    : false) extends true
                ? null
                : bigint;
            chainId?: number;
            from: `0x${string}`;
            gas: bigint;
            gasPrice: bigint;
            hash: `0x${string}`;
            input: `0x${string}`;
            maxFeePerBlobGas?: undefined;
            maxFeePerGas?: undefined;
            maxPriorityFeePerGas?: undefined;
            nonce: number;
            r: `0x${string}`;
            s: `0x${string}`;
            to: null | `0x${string}`;
            transactionIndex: (TBlockTag extends "pending"
                    ? true
                    : false) extends true
                ? null
                : number;
            type: "legacy";
            typeHex: null | `0x${string}`;
            v: bigint;
            value: bigint;
            yParity?: undefined;
        }
        | {
            accessList: AccessList;
            blobVersionedHashes?: undefined;
            blockHash: (TBlockTag extends "pending"
                    ? true
                    : false) extends true
                ? null
                : `0x${string}`;
            blockNumber: (TBlockTag extends "pending"
                    ? true
                    : false) extends true
                ? null
                : bigint;
            chainId: number;
            from: `0x${string}`;
            gas: bigint;
            gasPrice: bigint;
            hash: `0x${string}`;
            input: `0x${string}`;
            maxFeePerBlobGas?: undefined;
            maxFeePerGas?: undefined;
            maxPriorityFeePerGas?: undefined;
            nonce: number;
            r: `0x${string}`;
            s: `0x${string}`;
            to: null | `0x${string}`;
            transactionIndex: (TBlockTag extends "pending"
                    ? true
                    : false) extends true
                ? null
                : number;
            type: "eip2930";
            typeHex: null | `0x${string}`;
            v: bigint;
            value: bigint;
            yParity: number;
        }
        | {
            accessList: AccessList;
            blobVersionedHashes?: undefined;
            blockHash: (TBlockTag extends "pending"
                    ? true
                    : false) extends true
                ? null
                : `0x${string}`;
            blockNumber: (TBlockTag extends "pending"
                    ? true
                    : false) extends true
                ? null
                : bigint;
            chainId: number;
            from: `0x${string}`;
            gas: bigint;
            gasPrice?: undefined;
            hash: `0x${string}`;
            input: `0x${string}`;
            maxFeePerBlobGas?: undefined;
            maxFeePerGas: bigint;
            maxPriorityFeePerGas: bigint;
            nonce: number;
            r: `0x${string}`;
            s: `0x${string}`;
            to: null | `0x${string}`;
            transactionIndex: (TBlockTag extends "pending"
                    ? true
                    : false) extends true
                ? null
                : number;
            type: "eip1559";
            typeHex: null | `0x${string}`;
            v: bigint;
            value: bigint;
            yParity: number;
        }
        | {
            accessList: AccessList;
            blobVersionedHashes: `0x${string}`[];
            blockHash: (TBlockTag extends "pending"
                    ? true
                    : false) extends true
                ? null
                : `0x${string}`;
            blockNumber: (TBlockTag extends "pending"
                    ? true
                    : false) extends true
                ? null
                : bigint;
            chainId: number;
            from: `0x${string}`;
            gas: bigint;
            gasPrice?: undefined;
            hash: `0x${string}`;
            input: `0x${string}`;
            maxFeePerBlobGas: bigint;
            maxFeePerGas: bigint;
            maxPriorityFeePerGas: bigint;
            nonce: number;
            r: `0x${string}`;
            s: `0x${string}`;
            to: null | `0x${string}`;
            transactionIndex: (TBlockTag extends "pending"
                    ? true
                    : false) extends true
                ? null
                : number;
            type: "eip4844";
            typeHex: null | `0x${string}`;
            v: bigint;
            value: bigint;
            yParity: number;
        }>)
    import { createPublicClient, http } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const transaction = await client.getTransaction({
    hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d',
    })
      • <TBlockTag>(args): Promise<
            | {
                accessList?: undefined;
                blobVersionedHashes?: undefined;
                blockHash: (TBlockTag extends "pending"
                        ? true
                        : false) extends true
                    ? null
                    : `0x${string}`;
                blockNumber: (TBlockTag extends "pending"
                        ? true
                        : false) extends true
                    ? null
                    : bigint;
                chainId?: number;
                from: `0x${string}`;
                gas: bigint;
                gasPrice: bigint;
                hash: `0x${string}`;
                input: `0x${string}`;
                maxFeePerBlobGas?: undefined;
                maxFeePerGas?: undefined;
                maxPriorityFeePerGas?: undefined;
                nonce: number;
                r: `0x${string}`;
                s: `0x${string}`;
                to: null | `0x${string}`;
                transactionIndex: (TBlockTag extends "pending"
                        ? true
                        : false) extends true
                    ? null
                    : number;
                type: "legacy";
                typeHex: null | `0x${string}`;
                v: bigint;
                value: bigint;
                yParity?: undefined;
            }
            | {
                accessList: AccessList;
                blobVersionedHashes?: undefined;
                blockHash: (TBlockTag extends "pending"
                        ? true
                        : false) extends true
                    ? null
                    : `0x${string}`;
                blockNumber: (TBlockTag extends "pending"
                        ? true
                        : false) extends true
                    ? null
                    : bigint;
                chainId: number;
                from: `0x${string}`;
                gas: bigint;
                gasPrice: bigint;
                hash: `0x${string}`;
                input: `0x${string}`;
                maxFeePerBlobGas?: undefined;
                maxFeePerGas?: undefined;
                maxPriorityFeePerGas?: undefined;
                nonce: number;
                r: `0x${string}`;
                s: `0x${string}`;
                to: null | `0x${string}`;
                transactionIndex: (TBlockTag extends "pending"
                        ? true
                        : false) extends true
                    ? null
                    : number;
                type: "eip2930";
                typeHex: null | `0x${string}`;
                v: bigint;
                value: bigint;
                yParity: number;
            }
            | {
                accessList: AccessList;
                blobVersionedHashes?: undefined;
                blockHash: (TBlockTag extends "pending"
                        ? true
                        : false) extends true
                    ? null
                    : `0x${string}`;
                blockNumber: (TBlockTag extends "pending"
                        ? true
                        : false) extends true
                    ? null
                    : bigint;
                chainId: number;
                from: `0x${string}`;
                gas: bigint;
                gasPrice?: undefined;
                hash: `0x${string}`;
                input: `0x${string}`;
                maxFeePerBlobGas?: undefined;
                maxFeePerGas: bigint;
                maxPriorityFeePerGas: bigint;
                nonce: number;
                r: `0x${string}`;
                s: `0x${string}`;
                to: null | `0x${string}`;
                transactionIndex: (TBlockTag extends "pending"
                        ? true
                        : false) extends true
                    ? null
                    : number;
                type: "eip1559";
                typeHex: null | `0x${string}`;
                v: bigint;
                value: bigint;
                yParity: number;
            }
            | {
                accessList: AccessList;
                blobVersionedHashes: `0x${string}`[];
                blockHash: (TBlockTag extends "pending"
                        ? true
                        : false) extends true
                    ? null
                    : `0x${string}`;
                blockNumber: (TBlockTag extends "pending"
                        ? true
                        : false) extends true
                    ? null
                    : bigint;
                chainId: number;
                from: `0x${string}`;
                gas: bigint;
                gasPrice?: undefined;
                hash: `0x${string}`;
                input: `0x${string}`;
                maxFeePerBlobGas: bigint;
                maxFeePerGas: bigint;
                maxPriorityFeePerGas: bigint;
                nonce: number;
                r: `0x${string}`;
                s: `0x${string}`;
                to: null | `0x${string}`;
                transactionIndex: (TBlockTag extends "pending"
                        ? true
                        : false) extends true
                    ? null
                    : number;
                type: "eip4844";
                typeHex: null | `0x${string}`;
                v: bigint;
                value: bigint;
                yParity: number;
            }>
      • Type Parameters

        Returns Promise<
            | {
                accessList?: undefined;
                blobVersionedHashes?: undefined;
                blockHash: (TBlockTag extends "pending"
                        ? true
                        : false) extends true
                    ? null
                    : `0x${string}`;
                blockNumber: (TBlockTag extends "pending"
                        ? true
                        : false) extends true
                    ? null
                    : bigint;
                chainId?: number;
                from: `0x${string}`;
                gas: bigint;
                gasPrice: bigint;
                hash: `0x${string}`;
                input: `0x${string}`;
                maxFeePerBlobGas?: undefined;
                maxFeePerGas?: undefined;
                maxPriorityFeePerGas?: undefined;
                nonce: number;
                r: `0x${string}`;
                s: `0x${string}`;
                to: null | `0x${string}`;
                transactionIndex: (TBlockTag extends "pending"
                        ? true
                        : false) extends true
                    ? null
                    : number;
                type: "legacy";
                typeHex: null | `0x${string}`;
                v: bigint;
                value: bigint;
                yParity?: undefined;
            }
            | {
                accessList: AccessList;
                blobVersionedHashes?: undefined;
                blockHash: (TBlockTag extends "pending"
                        ? true
                        : false) extends true
                    ? null
                    : `0x${string}`;
                blockNumber: (TBlockTag extends "pending"
                        ? true
                        : false) extends true
                    ? null
                    : bigint;
                chainId: number;
                from: `0x${string}`;
                gas: bigint;
                gasPrice: bigint;
                hash: `0x${string}`;
                input: `0x${string}`;
                maxFeePerBlobGas?: undefined;
                maxFeePerGas?: undefined;
                maxPriorityFeePerGas?: undefined;
                nonce: number;
                r: `0x${string}`;
                s: `0x${string}`;
                to: null | `0x${string}`;
                transactionIndex: (TBlockTag extends "pending"
                        ? true
                        : false) extends true
                    ? null
                    : number;
                type: "eip2930";
                typeHex: null | `0x${string}`;
                v: bigint;
                value: bigint;
                yParity: number;
            }
            | {
                accessList: AccessList;
                blobVersionedHashes?: undefined;
                blockHash: (TBlockTag extends "pending"
                        ? true
                        : false) extends true
                    ? null
                    : `0x${string}`;
                blockNumber: (TBlockTag extends "pending"
                        ? true
                        : false) extends true
                    ? null
                    : bigint;
                chainId: number;
                from: `0x${string}`;
                gas: bigint;
                gasPrice?: undefined;
                hash: `0x${string}`;
                input: `0x${string}`;
                maxFeePerBlobGas?: undefined;
                maxFeePerGas: bigint;
                maxPriorityFeePerGas: bigint;
                nonce: number;
                r: `0x${string}`;
                s: `0x${string}`;
                to: null | `0x${string}`;
                transactionIndex: (TBlockTag extends "pending"
                        ? true
                        : false) extends true
                    ? null
                    : number;
                type: "eip1559";
                typeHex: null | `0x${string}`;
                v: bigint;
                value: bigint;
                yParity: number;
            }
            | {
                accessList: AccessList;
                blobVersionedHashes: `0x${string}`[];
                blockHash: (TBlockTag extends "pending"
                        ? true
                        : false) extends true
                    ? null
                    : `0x${string}`;
                blockNumber: (TBlockTag extends "pending"
                        ? true
                        : false) extends true
                    ? null
                    : bigint;
                chainId: number;
                from: `0x${string}`;
                gas: bigint;
                gasPrice?: undefined;
                hash: `0x${string}`;
                input: `0x${string}`;
                maxFeePerBlobGas: bigint;
                maxFeePerGas: bigint;
                maxPriorityFeePerGas: bigint;
                nonce: number;
                r: `0x${string}`;
                s: `0x${string}`;
                to: null | `0x${string}`;
                transactionIndex: (TBlockTag extends "pending"
                        ? true
                        : false) extends true
                    ? null
                    : number;
                type: "eip4844";
                typeHex: null | `0x${string}`;
                v: bigint;
                value: bigint;
                yParity: number;
            }>

        The transaction information. GetTransactionReturnType

  • getTransactionConfirmations: ((args: GetTransactionConfirmationsParameters<undefined | Chain>) => Promise<bigint>)

    Returns the number of blocks passed (confirmations) since the transaction was processed on a block.

    import { createPublicClient, http } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const confirmations = await client.getTransactionConfirmations({
    hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d',
    })
  • getTransactionCount: ((args: GetTransactionCountParameters) => Promise<number>)

    Returns the number of Transactions an Account has broadcast / sent.

    import { createPublicClient, http } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const transactionCount = await client.getTransactionCount({
    address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
    })
  • getTransactionReceipt: ((args: GetTransactionReceiptParameters) => Promise<TransactionReceipt>)
    import { createPublicClient, http } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const transactionReceipt = await client.getTransactionReceipt({
    hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d',
    })
  • key: string

    A key for the client.

  • multicall: (<const contracts, allowFailure>(args: MulticallParameters<contracts, allowFailure>) => Promise<MulticallReturnType<contracts, allowFailure>>)

    Similar to readContract, but batches up multiple functions on a contract in a single RPC call via the multicall3 contract.

    import { createPublicClient, http, parseAbi } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const abi = parseAbi([
    'function balanceOf(address) view returns (uint256)',
    'function totalSupply() view returns (uint256)',
    ])
    const result = await client.multicall({
    contracts: [
    {
    address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
    abi,
    functionName: 'balanceOf',
    args: ['0xA0Cf798816D4b9b9866b5330EEa46a18382f251e'],
    },
    {
    address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
    abi,
    functionName: 'totalSupply',
    },
    ],
    })
    // [{ result: 424122n, status: 'success' }, { result: 1000000n, status: 'success' }]
  • name: string

    A name for the client.

  • pollingInterval: number

    Frequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds.

  • prepareTransactionRequest: (<const TRequest, TChainOverride, TAccountOverride>(args: PrepareTransactionRequestParameters<undefined | Chain, undefined | Account, TChainOverride, TAccountOverride, TRequest>) => Promise<{
        [K in string | number | symbol]: (UnionRequiredBy<Extract<UnionOmit<(...), (...)> & ((...) extends (...)
            ? (...)
            : (...)) & ((...) extends (...)
            ? (...)
            : (...)), IsNever<(...)> extends true
            ? unknown
            : ExactPartial<(...)>> & {
            chainId?: number;
        }, ParameterTypeToParameters<TRequest["parameters"] extends PrepareTransactionRequestParameterType[]
            ? any[any][number]
            : PrepareTransactionRequestParameterType>> & (unknown extends TRequest["kzg"]
            ? {}
            : Pick<TRequest, "kzg">))[K]
    }>)

    Prepares a transaction request for signing.

    import { createWalletClient, custom } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createWalletClient({
    chain: mainnet,
    transport: custom(window.ethereum),
    })
    const request = await client.prepareTransactionRequest({
    account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
    to: '0x0000000000000000000000000000000000000000',
    value: 1n,
    })
    // Account Hoisting
    import { createWalletClient, http } from 'viem'
    import { privateKeyToAccount } from 'viem/accounts'
    import { mainnet } from 'viem/chains'

    const client = createWalletClient({
    account: privateKeyToAccount('0x…'),
    chain: mainnet,
    transport: custom(window.ethereum),
    })
    const request = await client.prepareTransactionRequest({
    to: '0x0000000000000000000000000000000000000000',
    value: 1n,
    })
      • <const TRequest, TChainOverride, TAccountOverride>(args): Promise<{
            [K in string | number | symbol]: (UnionRequiredBy<Extract<UnionOmit<(...), (...)> & ((...) extends (...)
                ? (...)
                : (...)) & ((...) extends (...)
                ? (...)
                : (...)), IsNever<(...)> extends true
                ? unknown
                : ExactPartial<(...)>> & {
                chainId?: number;
            }, ParameterTypeToParameters<TRequest["parameters"] extends PrepareTransactionRequestParameterType[]
                ? any[any][number]
                : PrepareTransactionRequestParameterType>> & (unknown extends TRequest["kzg"]
                ? {}
                : Pick<TRequest, "kzg">))[K]
        }>
      • Type Parameters

        • const TRequest extends (
              | Omit<{
                  accessList?: undefined;
                  blobs?: undefined;
                  data?: `0x${string}`;
                  from: `0x${string}`;
                  gas?: bigint;
                  gasPrice?: bigint;
                  maxFeePerBlobGas?: undefined;
                  maxFeePerGas?: undefined;
                  maxPriorityFeePerGas?: undefined;
                  nonce?: number;
                  to?: null | `0x${string}`;
                  type?: "legacy";
                  value?: bigint;
              }, "from">
              | Omit<{
                  accessList?: AccessList;
                  blobs?: undefined;
                  data?: `0x${string}`;
                  from: `0x${string}`;
                  gas?: bigint;
                  gasPrice?: bigint;
                  maxFeePerBlobGas?: undefined;
                  maxFeePerGas?: undefined;
                  maxPriorityFeePerGas?: undefined;
                  nonce?: number;
                  to?: null | `0x${string}`;
                  type?: "eip2930";
                  value?: bigint;
              }, "from">
              | Omit<{
                  accessList?: AccessList;
                  blobs?: undefined;
                  data?: `0x${string}`;
                  from: `0x${string}`;
                  gas?: bigint;
                  gasPrice?: undefined;
                  maxFeePerBlobGas?: undefined;
                  maxFeePerGas?: bigint;
                  maxPriorityFeePerGas?: bigint;
                  nonce?: number;
                  to?: null | `0x${string}`;
                  type?: "eip1559";
                  value?: bigint;
              }, "from">
              | Omit<{
                  accessList?: AccessList;
                  blobs: readonly `0x${string}`[] | readonly Uint8Array[];
                  data?: `0x${string}`;
                  from: `0x${string}`;
                  gas?: bigint;
                  gasPrice?: undefined;
                  maxFeePerBlobGas: bigint;
                  maxFeePerGas?: bigint;
                  maxPriorityFeePerGas?: bigint;
                  nonce?: number;
                  to: null | `0x${string}`;
                  type?: "eip4844";
                  value?: bigint;
              }, "from">) & {
              kzg?: Kzg;
          } & {
              parameters?: PrepareTransactionRequestParameterType[];
          }
        • TChainOverride extends undefined | Chain = undefined
        • TAccountOverride extends undefined | `0x${string}` | Account = undefined

        Returns Promise<{
            [K in string | number | symbol]: (UnionRequiredBy<Extract<UnionOmit<(...), (...)> & ((...) extends (...)
                ? (...)
                : (...)) & ((...) extends (...)
                ? (...)
                : (...)), IsNever<(...)> extends true
                ? unknown
                : ExactPartial<(...)>> & {
                chainId?: number;
            }, ParameterTypeToParameters<TRequest["parameters"] extends PrepareTransactionRequestParameterType[]
                ? any[any][number]
                : PrepareTransactionRequestParameterType>> & (unknown extends TRequest["kzg"]
                ? {}
                : Pick<TRequest, "kzg">))[K]
        }>

        The transaction request. PrepareTransactionRequestReturnType

  • readContract: (<const abi, functionName, args>(args: ReadContractParameters<abi, functionName, args>) => Promise<ReadContractReturnType<abi, functionName, args>>)

    Calls a read-only function on a contract, and returns the response.

    A "read-only" function (constant function) on a Solidity contract is denoted by a view or pure keyword. They can only read the state of the contract, and cannot make any changes to it. Since read-only methods do not change the state of the contract, they do not require any gas to be executed, and can be called by any user without the need to pay for gas.

    Internally, uses a Public Client to call the call action with ABI-encoded data.

    import { createPublicClient, http, parseAbi } from 'viem'
    import { mainnet } from 'viem/chains'
    import { readContract } from 'viem/contract'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const result = await client.readContract({
    address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
    abi: parseAbi(['function balanceOf(address) view returns (uint256)']),
    functionName: 'balanceOf',
    args: ['0xA0Cf798816D4b9b9866b5330EEa46a18382f251e'],
    })
    // 424122n
  • request: EIP1193RequestFn<PublicRpcSchema>

    Request function wrapped with friendly error handling

  • sendRawTransaction: ((args: SendRawTransactionParameters) => Promise<`0x${string}`>)

    Sends a signed transaction to the network

    import { createWalletClient, custom } from 'viem'
    import { mainnet } from 'viem/chains'
    import { sendRawTransaction } from 'viem/wallet'

    const client = createWalletClient({
    chain: mainnet,
    transport: custom(window.ethereum),
    })

    const hash = await client.sendRawTransaction({
    serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33'
    })
  • simulateContract: (<const abi, functionName, args, chainOverride, accountOverride>(args: SimulateContractParameters<abi, functionName, args, undefined | Chain, chainOverride, accountOverride>) => Promise<SimulateContractReturnType<abi, functionName, args, undefined | Chain, undefined | Account, chainOverride, accountOverride>>)

    Simulates/validates a contract interaction. This is useful for retrieving return data and revert reasons of contract write functions.

    This function does not require gas to execute and does not change the state of the blockchain. It is almost identical to readContract, but also supports contract write functions.

    Internally, uses a Public Client to call the call action with ABI-encoded data.

    import { createPublicClient, http } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const result = await client.simulateContract({
    address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
    abi: parseAbi(['function mint(uint32) view returns (uint32)']),
    functionName: 'mint',
    args: ['69420'],
    account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
    })
  • transport: TransportConfig<string, EIP1193RequestFn> & Record<string, any>

    The RPC transport

  • type: string

    The type of client.

  • uid: string

    A unique ID for the client.

  • uninstallFilter: ((args: UninstallFilterParameters) => Promise<boolean>)

    Destroys a Filter that was created from one of the following Actions:

    import { createPublicClient, http } from 'viem'
    import { mainnet } from 'viem/chains'
    import { createPendingTransactionFilter, uninstallFilter } from 'viem/public'

    const filter = await client.createPendingTransactionFilter()
    const uninstalled = await client.uninstallFilter({ filter })
    // true
  • verifyMessage: ((args: VerifyMessageParameters) => Promise<boolean>)
  • verifyTypedData: ((args: VerifyTypedDataParameters) => Promise<boolean>)
  • waitForTransactionReceipt: ((args: WaitForTransactionReceiptParameters<undefined | Chain>) => Promise<TransactionReceipt>)

    Waits for the Transaction to be included on a Block (one confirmation), and then returns the Transaction Receipt. If the Transaction reverts, then the action will throw an error.

    The waitForTransactionReceipt action additionally supports Replacement detection (e.g. sped up Transactions).

    Transactions can be replaced when a user modifies their transaction in their wallet (to speed up or cancel). Transactions are replaced when they are sent from the same nonce.

    There are 3 types of Transaction Replacement reasons:

    • repriced: The gas price has been modified (e.g. different maxFeePerGas)
    • cancelled: The Transaction has been cancelled (e.g. value === 0n)
    • replaced: The Transaction has been replaced (e.g. different value or data)
    import { createPublicClient, http } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const transactionReceipt = await client.waitForTransactionReceipt({
    hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d',
    })
  • watchBlockNumber: ((args: WatchBlockNumberParameters) => WatchBlockNumberReturnType)

    Watches and returns incoming block numbers.

    import { createPublicClient, http } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const unwatch = await client.watchBlockNumber({
    onBlockNumber: (blockNumber) => console.log(blockNumber),
    })
  • watchBlocks: (<TIncludeTransactions, TBlockTag>(args: WatchBlocksParameters<Transport, undefined | Chain, TIncludeTransactions, TBlockTag>) => WatchBlocksReturnType)

    Watches and returns information for incoming blocks.

    import { createPublicClient, http } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const unwatch = await client.watchBlocks({
    onBlock: (block) => console.log(block),
    })
  • watchContractEvent: (<const TAbi, TEventName, TStrict>(args: WatchContractEventParameters<TAbi, TEventName, TStrict, Transport>) => WatchContractEventReturnType)

    Watches and returns emitted contract event logs.

    This Action will batch up all the event logs found within the pollingInterval, and invoke them via onLogs.

    watchContractEvent will attempt to create an Event Filter and listen to changes to the Filter per polling interval, however, if the RPC Provider does not support Filters (e.g. eth_newFilter), then watchContractEvent will fall back to using getLogs instead.

    import { createPublicClient, http, parseAbi } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const unwatch = client.watchContractEvent({
    address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
    abi: parseAbi(['event Transfer(address indexed from, address indexed to, uint256 value)']),
    eventName: 'Transfer',
    args: { from: '0xc961145a54C96E3aE9bAA048c4F4D6b04C13916b' },
    onLogs: (logs) => console.log(logs),
    })
  • watchEvent: (<const TAbiEvent, const TAbiEvents, TStrict>(args: WatchEventParameters<TAbiEvent, TAbiEvents, TStrict, Transport>) => WatchEventReturnType)

    Watches and returns emitted Event Logs.

    This Action will batch up all the Event Logs found within the pollingInterval, and invoke them via onLogs.

    watchEvent will attempt to create an Event Filter and listen to changes to the Filter per polling interval, however, if the RPC Provider does not support Filters (e.g. eth_newFilter), then watchEvent will fall back to using getLogs instead.

    import { createPublicClient, http } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const unwatch = client.watchEvent({
    onLogs: (logs) => console.log(logs),
    })
  • watchPendingTransactions: ((args: WatchPendingTransactionsParameters<Transport>) => WatchPendingTransactionsReturnType)

    Watches and returns pending transaction hashes.

    This Action will batch up all the pending transactions found within the pollingInterval, and invoke them via onTransactions.

    import { createPublicClient, http } from 'viem'
    import { mainnet } from 'viem/chains'

    const client = createPublicClient({
    chain: mainnet,
    transport: http(),
    })
    const unwatch = await client.watchPendingTransactions({
    onTransactions: (hashes) => console.log(hashes),
    })

Methods

  • Encodes a batch of transactions to the account's batch execute function. NOTE: not all accounts support batching.

    Parameters

    Returns Promise<`0x${string}`>

    the encoded callData for a UserOperation

  • Encodes a call to the account's execute function.

    Parameters

    • target: string

      the address receiving the call data

    • value: bigint

      optionally the amount of native token to send

    • data: string

      the call data or "0x" if empty

    Returns Promise<`0x${string}`>

  • Returns Promise<`0x${string}`>

    the address of the account

  • This is useful for estimating gas costs. It should return a signature that doesn't cause the account to revert when validation is run during estimation.

    Returns `0x${string}`

    a dummy signature that doesn't cause the account to revert during estimation

  • Returns `0x${string}`

    the address of the entry point contract for the smart account

  • Returns `0x${string}`

    the address of the factory contract for the smart account

  • Returns Promise<`0x${string}`>

    the init code for the account

  • Returns Promise<bigint>

    the nonce of the account

  • Returns TSigner

    the current account signer instance that the smart account client operations are being signed with.

    The signer is expected to be the owner or one of the owners of the account for the signatures to be valid for the acting account.

  • Returns a signed and prefixed message.

    Parameters

    • msg: string | Uint8Array

      the message to sign

    Returns Promise<`0x${string}`>

    the signature of the message

  • If the account is not deployed, it will sign the message and then wrap it in 6492 format

    Parameters

    • msg: string | Uint8Array

      the message to sign

    Returns Promise<`0x${string}`>

    ths signature wrapped in 6492 format

  • Signs a typed data object as per ERC-712

    Returns Promise<`0x${string}`>

    the signed hash for the message passed

  • If the account is not deployed, it will sign the typed data blob and then wrap it in 6492 format

    Returns Promise<`0x${string}`>

    the signed hash for the params passed in wrapped in 6492 format

  • If your account handles 1271 signatures of personal_sign differently than it does UserOperations, you can implement two different approaches to signing

    Parameters

    • uoHash: `0x${string}`

      The hash of the UserOperation to sign

    Returns Promise<`0x${string}`>

    the signature of the UserOperation