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.
Extends
Section titled “Extends”Properties
Section titled “Properties”provider
Section titled “provider”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.
Overrides
Section titled “Overrides”sendTransaction()?
Section titled “sendTransaction()?”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
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
tx | TransactionRequest |
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”ContractRunner
.sendTransaction
Methods
Section titled “Methods”addListener()
Section titled “addListener()”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]].
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
event | ProviderEvent |
listener | Listener |
Returns
Section titled “Returns”Promise
<Provider
>
Inherited from
Section titled “Inherited from”broadcastTransaction()
Section titled “broadcastTransaction()”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.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
signedTx | string |
Returns
Section titled “Returns”call()
Section titled “call()”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.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
tx | TransactionRequest |
Returns
Section titled “Returns”Promise
<string
>
Overrides
Section titled “Overrides”ContractRunner.call
destroy()
Section titled “destroy()”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.
Returns
Section titled “Returns”void
emit()
Section titled “emit()”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%%.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
event | ProviderEvent |
…args | any [] |
Returns
Section titled “Returns”Promise
<boolean
>
Inherited from
Section titled “Inherited from”estimateGas()
Section titled “estimateGas()”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%%.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
tx | TransactionRequest |
Returns
Section titled “Returns”Promise
<bigint
>
Overrides
Section titled “Overrides”ContractRunner.estimateGas
getBalance()
Section titled “getBalance()”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]].
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
address | AddressLike |
blockTag? | BlockTag |
Returns
Section titled “Returns”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()
Section titled “getBlock()”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.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
blockHashOrBlockTag | BlockTag |
prefetchTxs? | boolean |
Returns
Section titled “Returns”getBlockNumber()
Section titled “getBlockNumber()”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.
Returns
Section titled “Returns”Promise
<number
>
getCode()
Section titled “getCode()”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%%.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
address | AddressLike |
blockTag? | BlockTag |
Returns
Section titled “Returns”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()
Section titled “getFeeData()”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]].
Returns
Section titled “Returns”getLogs()
Section titled “getLogs()”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%%
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
filter | | Filter | FilterByBlockHash |
Returns
Section titled “Returns”getNetwork()
Section titled “getNetwork()”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]].
Returns
Section titled “Returns”getStorage()
Section titled “getStorage()”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%%.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
address | AddressLike |
position | BigNumberish |
blockTag? | BlockTag |
Returns
Section titled “Returns”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()
Section titled “getTransaction()”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
.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
hash | string |
Returns
Section titled “Returns”Promise
<
| null
| TransactionResponse
>
getTransactionCount()
Section titled “getTransactionCount()”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]].
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
address | AddressLike |
blockTag? | BlockTag |
Returns
Section titled “Returns”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()
Section titled “getTransactionReceipt()”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
.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
hash | string |
Returns
Section titled “Returns”Promise
<
| null
| TransactionReceipt
>
getTransactionResult()
Section titled “getTransactionResult()”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.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
hash | string |
Returns
Section titled “Returns”Promise
<null
| string
>
listenerCount()
Section titled “listenerCount()”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%%.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
event? | ProviderEvent |
Returns
Section titled “Returns”Promise
<number
>
Inherited from
Section titled “Inherited from”EventEmitterable
.listenerCount
listeners()
Section titled “listeners()”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%%.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
event? | ProviderEvent |
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”lookupAddress()
Section titled “lookupAddress()”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.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
address | string |
Returns
Section titled “Returns”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.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
event | ProviderEvent |
listener? | Listener |
Returns
Section titled “Returns”Promise
<Provider
>
Inherited from
Section titled “Inherited from”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.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
event | ProviderEvent |
listener | Listener |
Returns
Section titled “Returns”Promise
<Provider
>
Inherited from
Section titled “Inherited from”once()
Section titled “once()”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.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
event | ProviderEvent |
listener | Listener |
Returns
Section titled “Returns”Promise
<Provider
>
Inherited from
Section titled “Inherited from”removeAllListeners()
Section titled “removeAllListeners()”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%%.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
event? | ProviderEvent |
Returns
Section titled “Returns”Promise
<Provider
>
Inherited from
Section titled “Inherited from”EventEmitterable
.removeAllListeners
removeListener()
Section titled “removeListener()”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]].
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
event | ProviderEvent |
listener | Listener |
Returns
Section titled “Returns”Promise
<Provider
>
Inherited from
Section titled “Inherited from”EventEmitterable
.removeListener
resolveName()
Section titled “resolveName()”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.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
ensName | string |
Returns
Section titled “Returns”Promise
<null
| string
>
Overrides
Section titled “Overrides”waitForBlock()
Section titled “waitForBlock()”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
.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
blockTag? | BlockTag |
Returns
Section titled “Returns”waitForTransaction()
Section titled “waitForTransaction()”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.
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
hash | string |
confirms? | number |
timeout? | number |
Returns
Section titled “Returns”Promise
<
| null
| TransactionReceipt
>