Skip to content

Provider

Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/provider.d.ts:1087

A Provider is the primary method to interact with the read-only content on Ethereum.

It allows access to details about accounts, blocks and transactions and the ability to query event logs and simulate contract execution.

Account data includes the balance, transaction count, code and state trie storage.

Simulating execution can be used to call, estimate gas and get transaction results.

The [[broadcastTransaction]] is the only method which allows updating the blockchain, but it is usually accessed by a [[Signer]], since a private key must be used to sign the transaction before it can be broadcast.

provider: Provider;

Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/provider.d.ts:1095

The provider iteself.

This is part of the necessary API for executing a contract, as it provides a common property on any [[ContractRunner]] that can be used to access the read-only portion of the runner.

ContractRunner.provider


optional sendTransaction: (tx) => Promise<TransactionResponse>;

Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/contracts.d.ts:34

Required for state mutating calls

ParameterType
txTransactionRequest

Promise<TransactionResponse>

ContractRunner.sendTransaction

addListener(event, listener): Promise<Provider>;

Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/utils/events.d.ts:46

Alias for [[on]].

ParameterType
eventProviderEvent
listenerListener

Promise<Provider>

EventEmitterable.addListener


broadcastTransaction(signedTx): Promise<TransactionResponse>;

Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/provider.d.ts:1161

Broadcasts the %%signedTx%% to the network, adding it to the memory pool of any node for which the transaction meets the rebroadcast requirements.

ParameterType
signedTxstring

Promise<TransactionResponse>


call(tx): Promise<string>;

Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/provider.d.ts:1155

Simulate the execution of %%tx%%. If the call reverts, it will throw a [[CallExceptionError]] which includes the revert data.

ParameterType
txTransactionRequest

Promise<string>

ContractRunner.call

destroy(): void;

Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/provider.d.ts:1100

Shutdown any resources this provider is using. No additional calls should be made to this provider after calling this.

void


emit(event, ...args): Promise<boolean>;

Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/utils/events.d.ts:25

Triggers each listener for %%event%% with the %%args%%.

ParameterType
eventProviderEvent
argsany[]

Promise<boolean>

EventEmitterable.emit


estimateGas(tx): Promise<bigint>;

Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/provider.d.ts:1150

Estimates the amount of gas required to execute %%tx%%.

ParameterType
txTransactionRequest

Promise<bigint>

ContractRunner.estimateGas

getBalance(address, blockTag?): Promise<bigint>;

Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/provider.d.ts:1121

Get the account balance (in wei) of %%address%%. If %%blockTag%% is specified and the node supports archive access for that %%blockTag%%, the balance is as of that [[BlockTag]].

ParameterType
addressAddressLike
blockTag?BlockTag

Promise<bigint>

On nodes without archive access enabled, the %%blockTag%% may be silently ignored by the node, which may cause issues if relied on.


getBlock(blockHashOrBlockTag, prefetchTxs?): Promise<null | Block>;

Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/provider.d.ts:1170

Resolves to the block for %%blockHashOrBlockTag%%.

If %%prefetchTxs%%, and the backend supports including transactions with block requests, all transactions will be included and the [[Block]] object will not need to make remote calls for getting transactions.

ParameterType
blockHashOrBlockTagBlockTag
prefetchTxs?boolean

Promise<null | Block>


getBlockNumber(): Promise<number>;

Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/provider.d.ts:1104

Get the current block number.

Promise<number>


getCode(address, blockTag?): Promise<string>;

Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/provider.d.ts:1139

Get the bytecode for %%address%%.

ParameterType
addressAddressLike
blockTag?BlockTag

Promise<string>

On nodes without archive access enabled, the %%blockTag%% may be silently ignored by the node, which may cause issues if relied on.


getFeeData(): Promise<FeeData>;

Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/provider.d.ts:1112

Get the best guess at the recommended [[FeeData]].

Promise<FeeData>


getLogs(filter): Promise<Log[]>;

Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/provider.d.ts:1196

Resolves to the list of Logs that match %%filter%%

ParameterType
filter| Filter | FilterByBlockHash

Promise<Log[]>


getNetwork(): Promise<Network>;

Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/provider.d.ts:1108

Get the connected [[Network]].

Promise<Network>


getStorage(
address,
position,
blockTag?): Promise<string>;

Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/provider.d.ts:1146

Get the storage slot value for %%address%% at slot %%position%%.

ParameterType
addressAddressLike
positionBigNumberish
blockTag?BlockTag

Promise<string>

On nodes without archive access enabled, the %%blockTag%% may be silently ignored by the node, which may cause issues if relied on.


getTransaction(hash): Promise<
| null
| TransactionResponse>;

Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/provider.d.ts:1177

Resolves to the transaction for %%hash%%.

If the transaction is unknown or on pruning nodes which discard old transactions this resolves to null.

ParameterType
hashstring

Promise< | null | TransactionResponse>


getTransactionCount(address, blockTag?): Promise<number>;

Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/provider.d.ts:1132

Get the number of transactions ever sent for %%address%%, which is used as the nonce when sending a transaction. If %%blockTag%% is specified and the node supports archive access for that %%blockTag%%, the transaction count is as of that [[BlockTag]].

ParameterType
addressAddressLike
blockTag?BlockTag

Promise<number>

On nodes without archive access enabled, the %%blockTag%% may be silently ignored by the node, which may cause issues if relied on.


getTransactionReceipt(hash): Promise<
| null
| TransactionReceipt>;

Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/provider.d.ts:1185

Resolves to the transaction receipt for %%hash%%, if mined.

If the transaction has not been mined, is unknown or on pruning nodes which discard old transactions this resolves to null.

ParameterType
hashstring

Promise< | null | TransactionReceipt>


getTransactionResult(hash): Promise<null | string>;

Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/provider.d.ts:1192

Resolves to the result returned by the executions of %%hash%%.

This is only supported on nodes with archive access and with the necessary debug APIs enabled.

ParameterType
hashstring

Promise<null | string>


listenerCount(event?): Promise<number>;

Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/utils/events.d.ts:29

Resolves to the number of listeners for %%event%%.

ParameterType
event?ProviderEvent

Promise<number>

EventEmitterable.listenerCount


listeners(event?): Promise<Listener[]>;

Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/utils/events.d.ts:33

Resolves to the listeners for %%event%%.

ParameterType
event?ProviderEvent

Promise<Listener[]>

EventEmitterable.listeners


lookupAddress(address): Promise<null | string>;

Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/provider.d.ts:1209

Resolves to the ENS name associated for the %%address%% or null if the //primary name// is not configured.

Users must perform additional steps to configure a //primary name//, which is not currently common.

ParameterType
addressstring

Promise<null | string>


off(event, listener?): Promise<Provider>;

Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/utils/events.d.ts:38

Unregister the %%listener%% for %%event%%. If %%listener%% is unspecified, all listeners are unregistered.

ParameterType
eventProviderEvent
listener?Listener

Promise<Provider>

EventEmitterable.off


on(event, listener): Promise<Provider>;

Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/utils/events.d.ts:16

Registers a %%listener%% that is called whenever the %%event%% occurs until unregistered.

ParameterType
eventProviderEvent
listenerListener

Promise<Provider>

EventEmitterable.on


once(event, listener): Promise<Provider>;

Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/utils/events.d.ts:21

Registers a %%listener%% that is called the next time %%event%% occurs.

ParameterType
eventProviderEvent
listenerListener

Promise<Provider>

EventEmitterable.once


removeAllListeners(event?): Promise<Provider>;

Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/utils/events.d.ts:42

Unregister all listeners for %%event%%.

ParameterType
event?ProviderEvent

Promise<Provider>

EventEmitterable.removeAllListeners


removeListener(event, listener): Promise<Provider>;

Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/utils/events.d.ts:50

Alias for [[off]].

ParameterType
eventProviderEvent
listenerListener

Promise<Provider>

EventEmitterable.removeListener


resolveName(ensName): Promise<null | string>;

Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/provider.d.ts:1201

Resolves to the address configured for the %%ensName%% or null if unconfigured.

ParameterType
ensNamestring

Promise<null | string>

NameResolver.resolveName


waitForBlock(blockTag?): Promise<Block>;

Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/provider.d.ts:1221

Resolves to the block at %%blockTag%% once it has been mined.

This can be useful for waiting some number of blocks by using the currentBlockNumber + N.

ParameterType
blockTag?BlockTag

Promise<Block>


waitForTransaction(
hash,
confirms?,
timeout?): Promise<
| null
| TransactionReceipt>;

Defined in: node_modules/.pnpm/ethers@6.15.0/node_modules/ethers/lib.esm/providers/provider.d.ts:1214

Waits until the transaction %%hash%% is mined and has %%confirms%% confirmations.

ParameterType
hashstring
confirms?number
timeout?number

Promise< | null | TransactionReceipt>