@fuel-ts/account v0.96.1 • Docs
Class: Provider
A provider for connecting to a node
Properties
cache?
optional
cache:ResourceCache
Defined in
packages/account/src/providers/provider.ts:407
operations
operations:
SdkOperations
Defined in
packages/account/src/providers/provider.ts:406
options
options:
ProviderOptions
Defined in
packages/account/src/providers/provider.ts:427
Methods
autoRefetchConfigs()
autoRefetchConfigs():
Promise
<void
>
Returns
Promise
<void
>
Defined in
packages/account/src/providers/provider.ts:1162
connect()
connect(
url
,options
?):Promise
<void
>
Updates the URL for the provider and fetches the consensus parameters for the new URL, if needed.
Parameters
• url: string
The URL to connect to.
• options?: ProviderOptions
Additional options for the provider.
Returns
Promise
<void
>
Defined in
packages/account/src/providers/provider.ts:595
dryRun()
dryRun(
transactionRequestLike
,sendTransactionParams
):Promise
<CallResult
>
Executes a transaction without actually submitting it to the chain.
If the transaction is missing any dependencies, the transaction will be mutated and those dependencies will be added.
Parameters
• transactionRequestLike: TransactionRequestLike
The transaction request object.
• sendTransactionParams: ProviderCallParams
= {}
The provider call parameters (optional).
Returns
Promise
<CallResult
>
A promise that resolves to the call result object.
Defined in
packages/account/src/providers/provider.ts:917
dryRunMultipleTransactions()
dryRunMultipleTransactions(
transactionRequests
,sendTransactionParams
):Promise
<CallResult
[]>
Dry runs multiple transactions.
Parameters
• transactionRequests: TransactionRequest
[]
Array of transaction request objects.
• sendTransactionParams: ProviderCallParams
= {}
The provider call parameters (optional).
Returns
Promise
<CallResult
[]>
A promise that resolves to an array of results for each transaction call.
Defined in
packages/account/src/providers/provider.ts:1141
estimateGasPrice()
estimateGasPrice(
blockHorizon
):Promise
<BN
>
Returns the estimate gas price for the given block horizon.
Parameters
• blockHorizon: number
The block horizon to estimate gas price for.
Returns
Promise
<BN
>
A promise that resolves to the estimated gas price.
Defined in
packages/account/src/providers/provider.ts:1968
estimateMultipleTxDependencies()
estimateMultipleTxDependencies(
transactionRequests
):Promise
<EstimateTxDependenciesReturns
[]>
Dry runs multiple transactions and checks for missing dependencies in batches.
Transactions are dry run in batches. After each dry run, transactions requiring further modifications are identified. The method iteratively updates these transactions and performs subsequent dry runs until all dependencies for each transaction are satisfied.
Parameters
• transactionRequests: TransactionRequest
[]
Array of transaction request objects.
Returns
Promise
<EstimateTxDependenciesReturns
[]>
A promise that resolves to an array of results for each transaction.
Defined in
packages/account/src/providers/provider.ts:1060
estimatePredicates()
estimatePredicates<
T
>(transactionRequest
):Promise
<T
>
Verifies whether enough gas is available to complete transaction.
Type Parameters
• T extends TransactionRequest
The type of the transaction request object.
Parameters
• transactionRequest: T
The transaction request object.
Returns
Promise
<T
>
A promise that resolves to the estimated transaction request object.
Defined in
packages/account/src/providers/provider.ts:944
estimateTxDependencies()
estimateTxDependencies(
transactionRequest
):Promise
<EstimateTxDependenciesReturns
>
Will dryRun a transaction and check for missing dependencies.
If there are missing variable outputs, addVariableOutputs
is called on the transaction.
Parameters
• transactionRequest: TransactionRequest
The transaction request object.
Returns
Promise
<EstimateTxDependenciesReturns
>
A promise that resolves to the estimate transaction dependencies.
Defined in
packages/account/src/providers/provider.ts:988
estimateTxGasAndFee()
estimateTxGasAndFee(
params
):Promise
<object
>
Estimates the transaction gas and fee based on the provided transaction request.
Parameters
• params
• params.gasPrice?: BN
• params.transactionRequest: TransactionRequest
Returns
Promise
<object
>
An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
gasLimit
gasLimit:
BN
gasPrice
gasPrice:
BN
maxFee
maxFee:
BN
maxGas
maxGas:
BN
minFee
minFee:
BN
minGas
minGas:
BN
Defined in
packages/account/src/providers/provider.ts:1195
fetchChain()
fetchChain():
Promise
<ChainInfo
>
Returns the chain information for the current provider network.
Returns
Promise
<ChainInfo
>
a promise that resolves to the chain information.
Defined in
packages/account/src/providers/provider.ts:788
fetchChainAndNodeInfo()
fetchChainAndNodeInfo(
ignoreCache
):Promise
<object
>
Return the chain and node information.
Parameters
• ignoreCache: boolean
= false
If true, ignores the cache and re-fetch configs.
Returns
Promise
<object
>
A promise that resolves to the Chain and NodeInfo.
chain
chain:
ChainInfo
nodeInfo
nodeInfo:
NodeInfo
Defined in
packages/account/src/providers/provider.ts:612
fetchNode()
fetchNode():
Promise
<NodeInfo
>
Returns the node information for the current provider network.
Returns
Promise
<NodeInfo
>
a promise that resolves to the node information.
Defined in
packages/account/src/providers/provider.ts:767
getAddressType()
getAddressType(
id
):Promise
<"Blob"
|"Account"
|"Contract"
|"Transaction"
>
Parameters
• id: string
Returns
Promise
<"Blob"
| "Account"
| "Contract"
| "Transaction"
>
Defined in
packages/account/src/providers/provider.ts:2023
getBalance()
getBalance(
owner
,assetId
):Promise
<BN
>
Returns the balance for the given owner for the given asset ID.
Parameters
• owner: string
| AbstractAddress
The address to get coins for.
• assetId: BytesLike
The asset ID of coins to get.
Returns
Promise
<BN
>
A promise that resolves to the balance.
Defined in
packages/account/src/providers/provider.ts:1755
getBalances()
getBalances(
owner
):Promise
<GetBalancesResponse
>
Returns balances for the given owner.
Parameters
• owner: string
| AbstractAddress
The address to get coins for.
Returns
Promise
<GetBalancesResponse
>
A promise that resolves to the balances.
Defined in
packages/account/src/providers/provider.ts:1775
getBaseAssetId()
getBaseAssetId():
string
Returns the base asset ID for the current provider network.
Returns
string
the base asset ID.
Defined in
packages/account/src/providers/provider.ts:815
getBlobs()
getBlobs(
blobIds
):Promise
<string
[]>
Returns an array of blobIds that exist on chain, for a given array of blobIds.
Parameters
• blobIds: string
[]
blobIds to check.
Returns
Promise
<string
[]>
- A promise that resolves to an array of blobIds that exist on chain.
Defined in
packages/account/src/providers/provider.ts:1508
getBlock()
getBlock(
idOrHeight
):Promise
<null
|Block
>
Returns block matching the given ID or height.
Parameters
• idOrHeight: string
| number
ID or height of the block.
Returns
Promise
<null
| Block
>
A promise that resolves to the block or null.
Defined in
packages/account/src/providers/provider.ts:1527
getBlockNumber()
getBlockNumber():
Promise
<BN
>
Returns the latest block number.
Returns
Promise
<BN
>
A promise that resolves to the latest block number.
Defined in
packages/account/src/providers/provider.ts:753
getBlockWithTransactions()
getBlockWithTransactions(
idOrHeight
):Promise
<null
|Block
&object
>
Returns block matching the given ID or type, including transaction data.
Parameters
• idOrHeight: string
| number
ID or height of the block.
Returns
Promise
<null
| Block
& object
>
A promise that resolves to the block.
Defined in
packages/account/src/providers/provider.ts:1610
getBlocks()
getBlocks(
params
?):Promise
<GetBlocksResponse
>
Returns all the blocks matching the given parameters.
Parameters
• params?: CursorPaginationArgs
The parameters to query blocks.
Returns
Promise
<GetBlocksResponse
>
A promise that resolves to the blocks.
Defined in
packages/account/src/providers/provider.ts:1574
getChain()
getChain():
ChainInfo
Returns the cached chainInfo for the current URL.
Returns
the chain information configuration.
Defined in
packages/account/src/providers/provider.ts:543
getChainId()
getChainId():
number
Returns the chain ID for the current provider network.
Returns
number
A promise that resolves to the chain ID number.
Defined in
packages/account/src/providers/provider.ts:803
getCoins()
getCoins(
owner
,assetId
?,paginationArgs
?):Promise
<GetCoinsResponse
>
Returns coins for the given owner.
Parameters
• owner: string
| AbstractAddress
The address to get coins for.
• assetId?: BytesLike
The asset ID of coins to get (optional).
• paginationArgs?: CursorPaginationArgs
Pagination arguments (optional).
Returns
Promise
<GetCoinsResponse
>
A promise that resolves to the coins.
Defined in
packages/account/src/providers/provider.ts:1401
getContract()
getContract(
contractId
):Promise
<null
|ContractResult
>
Get deployed contract with the given ID.
Parameters
• contractId: string
ID of the contract.
Returns
Promise
<null
| ContractResult
>
A promise that resolves to the contract.
Defined in
packages/account/src/providers/provider.ts:1720
getContractBalance()
getContractBalance(
contractId
,assetId
):Promise
<BN
>
Returns the balance for the given contract for the given asset ID.
Parameters
• contractId: string
| AbstractAddress
The contract ID to get the balance for.
• assetId: BytesLike
The asset ID of coins to get.
Returns
Promise
<BN
>
A promise that resolves to the balance.
Defined in
packages/account/src/providers/provider.ts:1735
getGasConfig()
getGasConfig():
object
Returns some helpful parameters related to gas fees.
Returns
object
gasCosts
gasCosts:
GasCosts
gasPerByte
gasPerByte:
BN
gasPriceFactor
gasPriceFactor:
BN
maxGasPerPredicate
maxGasPerPredicate:
BN
maxGasPerTx
maxGasPerTx:
BN
Defined in
packages/account/src/providers/provider.ts:573
getLatestGasPrice()
getLatestGasPrice():
Promise
<BN
>
Get the latest gas price from the node.
Returns
Promise
<BN
>
A promise that resolves to the latest gas price.
Defined in
packages/account/src/providers/provider.ts:1957
getMessageByNonce()
getMessageByNonce(
nonce
):Promise
<null
|Message
>
Returns Message for given nonce.
Parameters
• nonce: string
The nonce of the message to retrieve.
Returns
Promise
<null
| Message
>
A promise that resolves to the Message object or null.
Defined in
packages/account/src/providers/provider.ts:2060
getMessageProof()
getMessageProof(
transactionId
,nonce
,commitBlockId
?,commitBlockHeight
?):Promise
<null
|MessageProof
>
Returns Message Proof for given transaction id and the message id from MessageOut receipt.
Parameters
• transactionId: string
The transaction to get message from.
• nonce: string
• commitBlockId?: string
The commit block id (optional).
• commitBlockHeight?: BN
The commit block height (optional).
Returns
Promise
<null
| MessageProof
>
A promise that resolves to the message proof.
Defined in
packages/account/src/providers/provider.ts:1847
getMessageStatus()
getMessageStatus(
nonce
):Promise
<MessageStatus
>
Returns Message Proof for given transaction id and the message id from MessageOut receipt.
Parameters
• nonce: string
The nonce of the message to get status from.
Returns
Promise
<MessageStatus
>
A promise that resolves to the message status
Defined in
packages/account/src/providers/provider.ts:1981
getMessages()
getMessages(
address
,paginationArgs
?):Promise
<GetMessagesResponse
>
Returns message for the given address.
Parameters
• address: string
| AbstractAddress
The address to get message from.
• paginationArgs?: CursorPaginationArgs
Pagination arguments (optional).
Returns
Promise
<GetMessagesResponse
>
A promise that resolves to the messages.
Defined in
packages/account/src/providers/provider.ts:1802
getNode()
getNode():
NodeInfo
Returns the cached nodeInfo for the current URL.
Returns
the node information configuration.
Defined in
packages/account/src/providers/provider.ts:559
getRelayedTransactionStatus()
getRelayedTransactionStatus(
relayedTransactionId
):Promise
<null
|GqlRelayedTransactionFailed
>
Get the relayed transaction for the given transaction ID.
Parameters
• relayedTransactionId: string
The relayed transaction ID to get the response for.
Returns
Promise
<null
| GqlRelayedTransactionFailed
>
A promise that resolves to the relayed transaction.
Defined in
packages/account/src/providers/provider.ts:2092
getResourcesToSpend()
getResourcesToSpend(
owner
,quantities
,excludedIds
?):Promise
<Resource
[]>
Returns resources for the given owner satisfying the spend query.
Parameters
• owner: string
| AbstractAddress
The address to get resources for.
• quantities: CoinQuantityLike
[]
The coin quantities to get.
• excludedIds?: ExcludeResourcesOption
IDs of excluded resources from the selection (optional).
Returns
Promise
<Resource
[]>
A promise that resolves to the resources.
Defined in
packages/account/src/providers/provider.ts:1440
getTransaction()
getTransaction<
TTransactionType
>(transactionId
):Promise
<null
|Transaction
<TTransactionType
>>
Get transaction with the given ID.
Type Parameters
• TTransactionType = void
Parameters
• transactionId: string
ID of the transaction.
Returns
Promise
<null
| Transaction
<TTransactionType
>>
A promise that resolves to the transaction.
Defined in
packages/account/src/providers/provider.ts:1656
getTransactionResponse()
getTransactionResponse(
transactionId
):Promise
<TransactionResponse
>
Get the transaction response for the given transaction ID.
Parameters
• transactionId: string
The transaction ID to get the response for.
Returns
Promise
<TransactionResponse
>
A promise that resolves to the transaction response.
Defined in
packages/account/src/providers/provider.ts:2050
getTransactions()
getTransactions(
paginationArgs
?):Promise
<GetTransactionsResponse
>
Retrieves transactions based on the provided pagination arguments.
Parameters
• paginationArgs?: CursorPaginationArgs
The pagination arguments for retrieving transactions.
Returns
Promise
<GetTransactionsResponse
>
A promise that resolves to an object containing the retrieved transactions and pagination information.
Defined in
packages/account/src/providers/provider.ts:1685
getVersion()
getVersion():
Promise
<string
>
Returns the version of the connected node.
Returns
Promise
<string
>
A promise that resolves to the version string.
Defined in
packages/account/src/providers/provider.ts:741
isUserAccount()
isUserAccount(
id
):Promise
<boolean
>
Check if the given ID is an account.
Parameters
• id: string
The ID to check.
Returns
Promise
<boolean
>
A promise that resolves to the result of the check.
Defined in
packages/account/src/providers/provider.ts:2010
produceBlocks()
produceBlocks(
amount
,startTime
?):Promise
<BN
>
Lets you produce blocks with custom timestamps and the block number of the last block produced.
Parameters
• amount: number
The amount of blocks to produce.
• startTime?: number
The UNIX timestamp (milliseconds) to set for the first produced block (optional).
Returns
Promise
<BN
>
A promise that resolves to the block number of the last produced block.
Defined in
packages/account/src/providers/provider.ts:1996
sendTransaction()
sendTransaction(
transactionRequestLike
,sendTransactionParams
):Promise
<TransactionResponse
>
Submits a transaction to the chain to be executed.
If the transaction is missing any dependencies, the transaction will be mutated and those dependencies will be added.
Parameters
• transactionRequestLike: TransactionRequestLike
The transaction request object.
• sendTransactionParams: EstimateTransactionParams
= {}
The provider send transaction parameters (optional).
Returns
Promise
<TransactionResponse
>
A promise that resolves to the transaction response object.
Defined in
packages/account/src/providers/provider.ts:879
simulate()
simulate(
transactionRequestLike
,estimateTxParams
):Promise
<CallResult
>
Executes a signed transaction without applying the states changes on the chain.
If the transaction is missing any dependencies, the transaction will be mutated and those dependencies will be added
Parameters
• transactionRequestLike: TransactionRequestLike
The transaction request object.
• estimateTxParams: EstimateTransactionParams
= {}
The estimate transaction params (optional).
Returns
Promise
<CallResult
>
A promise that resolves to the call result object.
Defined in
packages/account/src/providers/provider.ts:1273
create()
static
create(url
,options
):Promise
<Provider
>
Creates a new instance of the Provider class. This is the recommended way to initialize a Provider.
Parameters
• url: string
GraphQL endpoint of the Fuel node
• options: ProviderOptions
= {}
Additional options for the provider
Returns
Promise
<Provider
>
A promise that resolves to a Provider instance.
Defined in
packages/account/src/providers/provider.ts:530