Icon SunFilledIcon MoonStars

Icon LinkClass: Provider

@fuel-ts/providers .Provider

A provider for connecting to a node

Icon LinkProperties

Icon Link#subscriptionClient

Private #subscriptionClient: Client

Icon LinkDefined in

packages/providers/src/provider.ts:230 Icon Link


Icon Linkcache

Optional cache: MemoryCache

Icon LinkDefined in

packages/providers/src/provider.ts:232 Icon Link


Icon Linkoperations

operations: Object

Icon LinkType declaration

NameType
dryRun(variables: Exact<{ encodedTransaction: string ; utxoValidation?: InputMaybe<boolean> }>, options?: unknown) => Promise<GqlDryRunMutation>
estimatePredicates(variables: Exact<{ encodedTransaction: string }>, options?: unknown) => Promise<GqlEstimatePredicatesQuery>
getBalance(variables: Exact<{ assetId: string ; owner: string }>, options?: unknown) => Promise<GqlGetBalanceQuery>
getBalances(variables: Exact<{ after?: InputMaybe<string> ; before?: InputMaybe<string> ; filter: GqlBalanceFilterInput ; first?: InputMaybe<number> ; last?: InputMaybe<number> }>, options?: unknown) => Promise<GqlGetBalancesQuery>
getBlock(variables?: Exact<{ blockHeight?: InputMaybe<string> ; blockId?: InputMaybe<string> }>, options?: unknown) => Promise<GqlGetBlockQuery>
getBlockWithTransactions(variables?: Exact<{ blockHeight?: InputMaybe<string> ; blockId?: InputMaybe<string> }>, options?: unknown) => Promise<GqlGetBlockWithTransactionsQuery>
getBlocks(variables?: Exact<{ after?: InputMaybe<string> ; before?: InputMaybe<string> ; first?: InputMaybe<number> ; last?: InputMaybe<number> }>, options?: unknown) => Promise<GqlGetBlocksQuery>
getChain(variables?: Exact<{ [key: string]: never; }>, options?: unknown) => Promise<GqlGetChainQuery>
getCoin(variables: Exact<{ coinId: string }>, options?: unknown) => Promise<GqlGetCoinQuery>
getCoins(variables: Exact<{ after?: InputMaybe<string> ; before?: InputMaybe<string> ; filter: GqlCoinFilterInput ; first?: InputMaybe<number> ; last?: InputMaybe<number> }>, options?: unknown) => Promise<GqlGetCoinsQuery>
getCoinsToSpend(variables: Exact<{ excludedIds?: InputMaybe<GqlExcludeInput> ; owner: string ; queryPerAsset: GqlSpendQueryElementInput | GqlSpendQueryElementInput[] }>, options?: unknown) => Promise<GqlGetCoinsToSpendQuery>
getContract(variables: Exact<{ contractId: string }>, options?: unknown) => Promise<GqlGetContractQuery>
getContractBalance(variables: Exact<{ asset: string ; contract: string }>, options?: unknown) => Promise<GqlGetContractBalanceQuery>
getMessageProof(variables: Exact<{ commitBlockHeight?: any ; commitBlockId?: InputMaybe<string> ; messageId: any ; transactionId: string }>, options?: unknown) => Promise<GqlGetMessageProofQuery>
getMessageStatus(variables: Exact<{ nonce: string }>, options?: unknown) => Promise<GqlGetMessageStatusQuery>
getMessages(variables: Exact<{ after?: InputMaybe<string> ; before?: InputMaybe<string> ; first?: InputMaybe<number> ; last?: InputMaybe<number> ; owner: string }>, options?: unknown) => Promise<GqlGetMessagesQuery>
getNodeInfo(variables?: Exact<{ [key: string]: never; }>, options?: unknown) => Promise<GqlGetNodeInfoQuery>
getTransaction(variables: Exact<{ transactionId: string }>, options?: unknown) => Promise<GqlGetTransactionQuery>
getTransactionWithReceipts(variables: Exact<{ transactionId: string }>, options?: unknown) => Promise<GqlGetTransactionWithReceiptsQuery>
getTransactions(variables?: Exact<{ after?: InputMaybe<string> ; before?: InputMaybe<string> ; first?: InputMaybe<number> ; last?: InputMaybe<number> }>, options?: unknown) => Promise<GqlGetTransactionsQuery>
getTransactionsByOwner(variables: Exact<{ after?: InputMaybe<string> ; before?: InputMaybe<string> ; first?: InputMaybe<number> ; last?: InputMaybe<number> ; owner: string }>, options?: unknown) => Promise<GqlGetTransactionsByOwnerQuery>
getVersion(variables?: Exact<{ [key: string]: never; }>, options?: unknown) => Promise<GqlGetVersionQuery>
produceBlocks(variables: Exact<{ blocksToProduce: string ; startTimestamp?: any }>, options?: unknown) => Promise<GqlProduceBlocksMutation>
statusChange(variables: Exact<{ transactionId: string }>, options?: unknown) => AsyncIterable<GqlStatusChangeSubscription>
submit(variables: Exact<{ encodedTransaction: string }>, options?: unknown) => Promise<GqlSubmitMutation>
submitAndAwait(variables: Exact<{ encodedTransaction: string }>, options?: unknown) => AsyncIterable<GqlSubmitAndAwaitSubscription>

Icon LinkDefined in

packages/providers/src/provider.ts:229 Icon Link


Icon Linkoptions

options: ProviderOptions <Response>

Icon LinkDefined in

packages/providers/src/provider.ts:233 Icon Link


Icon Linkurl

url: string

GraphQL endpoint of the Fuel node

Icon LinkDefined in

packages/providers/src/provider.ts:263 Icon Link


Icon LinkchainInfoCache

Static chainInfoCache: ChainInfoCache = {}

Icon LinkDefined in

packages/providers/src/provider.ts:250 Icon Link


Icon LinknodeInfoCache

Static nodeInfoCache: NodeInfoCache = {}

Icon LinkDefined in

packages/providers/src/provider.ts:251 Icon Link

Icon LinkMethods

Icon Linkcall

call(transactionRequestLike, utxoValidation?): 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.

Icon LinkParameters

NameTypeDescription
transactionRequestLikeTransactionRequestLike The transaction request object.
utxoValidationProviderCallParams Additional provider call parameters.

Icon LinkReturns

Promise<CallResult >

A promise that resolves to the call result object.

Icon LinkDefined in

packages/providers/src/provider.ts:585 Icon Link


Icon LinkcreateOperations

Private createOperations(): void

Create GraphQL client and set operations.

Icon LinkReturns

void

The operation SDK object

Icon LinkDefined in

packages/providers/src/provider.ts:370 Icon Link


Icon LinkestimatePredicates

estimatePredicates(transactionRequest): Promise<TransactionRequest >

Verifies whether enough gas is available to complete transaction.

Icon LinkParameters

NameTypeDescription
transactionRequestTransactionRequest The transaction request object.

Icon LinkReturns

Promise<TransactionRequest >

A promise that resolves to the estimated transaction request object.

Icon LinkDefined in

packages/providers/src/provider.ts:608 Icon Link


Icon LinkestimateTxDependencies

estimateTxDependencies(transactionRequest): Promise<void>

Will dryRun a transaction and check for missing dependencies.

If there are missing variable outputs, addVariableOutputs is called on the transaction.

Icon LinkParameters

NameTypeDescription
transactionRequestTransactionRequest The transaction request object.

Icon LinkReturns

Promise<void>

A promise.

Icon LinkDefined in

packages/providers/src/provider.ts:645 Icon Link


Icon LinkfetchChain

fetchChain(): Promise<ChainInfo >

Fetches the chainInfo for the given node URL.

Icon LinkReturns

Promise<ChainInfo >

ChainInfo object

Icon LinkDefined in

packages/providers/src/provider.ts:501 Icon Link


Icon LinkfetchChainAndNodeInfo

fetchChainAndNodeInfo(): Promise<{ chain: ChainInfo ; nodeInfo: NodeInfo }>

Retrieves and caches chain and node information if not already cached.

  • Checks the cache for existing chain and node information based on the current URL.
  • If not found in cache, fetches the information, caches it, and then returns the data.

Icon LinkReturns

Promise<{ chain: ChainInfo ; nodeInfo: NodeInfo }>

NodeInfo and Chain

Icon LinkDefined in

packages/providers/src/provider.ts:343 Icon Link


Icon LinkfetchNode

fetchNode(): Promise<NodeInfo >

Returns the chain information.

Icon LinkReturns

Promise<NodeInfo >

NodeInfo object

Icon LinkDefined in

packages/providers/src/provider.ts:484 Icon Link


Icon LinkgetBalance

getBalance(owner, assetId): Promise<BN>

Returns the balance for the given owner for the given asset ID.

Icon LinkParameters

NameTypeDescription
ownerAbstractAddress The address to get coins for.
assetIdBytesLikeThe asset ID of coins to get.

Icon LinkReturns

Promise<BN>

A promise that resolves to the balance.

Icon LinkDefined in

packages/providers/src/provider.ts:1016 Icon Link


Icon LinkgetBalances

getBalances(owner, paginationArgs?): Promise<CoinQuantity []>

Returns balances for the given owner.

Icon LinkParameters

NameTypeDescription
ownerAbstractAddress The address to get coins for.
paginationArgs?CursorPaginationArgsPagination arguments.

Icon LinkReturns

Promise<CoinQuantity []>

A promise that resolves to the balances.

Icon LinkDefined in

packages/providers/src/provider.ts:1036 Icon Link


Icon LinkgetBlock

getBlock(idOrHeight): Promise<null | Block >

Returns block matching the given ID or height.

Icon LinkParameters

NameTypeDescription
idOrHeightstring | numberID or height of the block.

Icon LinkReturns

Promise<null | Block >

A promise that resolves to the block.

Icon LinkDefined in

packages/providers/src/provider.ts:872 Icon Link


Icon LinkgetBlockNumber

getBlockNumber(): Promise<BN>

Returns the block number.

Icon LinkReturns

Promise<BN>

A promise that resolves to the block number

Icon LinkDefined in

packages/providers/src/provider.ts:474 Icon Link


Icon LinkgetBlockWithTransactions

getBlockWithTransactions(idOrHeight): Promise<null | Block & { transactions: Partial<Omit<TransactionScript, "type">> & Partial<Omit<TransactionCreate, "type">> & Partial<Omit<TransactionMint, "type">> & { type: TransactionType }[] }>

Returns block matching the given ID or type, including transaction data.

Icon LinkParameters

NameTypeDescription
idOrHeightstring | numberID or height of the block.

Icon LinkReturns

Promise<null | Block & { transactions: Partial<Omit<TransactionScript, "type">> & Partial<Omit<TransactionCreate, "type">> & Partial<Omit<TransactionMint, "type">> & { type: TransactionType }[] }>

A promise that resolves to the block.

Icon LinkDefined in

packages/providers/src/provider.ts:926 Icon Link


Icon LinkgetBlocks

getBlocks(params): Promise<Block []>

Returns all the blocks matching the given parameters.

Icon LinkParameters

NameTypeDescription
paramsExact<{ after?: InputMaybe<string> ; before?: InputMaybe<string> ; first?: InputMaybe<number> ; last?: InputMaybe<number> }>The parameters to query blocks.

Icon LinkReturns

Promise<Block []>

A promise that resolves to the blocks.

Icon LinkDefined in

packages/providers/src/provider.ts:907 Icon Link


Icon LinkgetChain

getChain(): ChainInfo

Returns the cached chainInfo for the current URL.

Icon LinkReturns

ChainInfo

Icon LinkDefined in

packages/providers/src/provider.ts:285 Icon Link


Icon LinkgetChainId

getChainId(): number

Returns the chain ID

Icon LinkReturns

number

A promise that resolves to the chain ID number

Icon LinkDefined in

packages/providers/src/provider.ts:510 Icon Link


Icon LinkgetCoins

getCoins(owner, assetId?, paginationArgs?): Promise<Coin []>

Returns coins for the given owner.

Icon LinkParameters

NameTypeDescription
ownerAbstractAddress The address to get coins for
assetId?BytesLikeThe asset ID of coins to get
paginationArgs?CursorPaginationArgsPagination arguments

Icon LinkReturns

Promise<Coin []>

Icon LinkDefined in

packages/providers/src/provider.ts:766 Icon Link


Icon LinkgetContract

getContract(contractId): Promise<null | ContractResult >

Get deployed contract with the given ID.

Icon LinkParameters

NameTypeDescription
contractIdstringID of the contract.

Icon LinkReturns

Promise<null | ContractResult >

A promise that resolves to the contract.

Icon LinkDefined in

packages/providers/src/provider.ts:981 Icon Link


Icon LinkgetContractBalance

getContractBalance(contractId, assetId): Promise<BN>

Returns the balance for the given contract for the given asset ID.

Icon LinkParameters

NameTypeDescription
contractIdAbstractAddress The contract ID to get the balance for.
assetIdBytesLikeThe asset ID of coins to get.

Icon LinkReturns

Promise<BN>

A promise that resolves to the balance.

Icon LinkDefined in

packages/providers/src/provider.ts:996 Icon Link


Icon LinkgetGasConfig

getGasConfig(): Object

Returns some helpful parameters related to gas fees.

Icon LinkReturns

Object

NameType
gasPerByteBN
gasPriceFactorBN
maxGasPerPredicateBN
maxGasPerTxBN
minGasPriceBN

Icon LinkDefined in

packages/providers/src/provider.ts:313 Icon Link


Icon LinkgetMessageProof

getMessageProof(transactionId, messageId, commitBlockId?, commitBlockHeight?): Promise<null | MessageProof >

Returns Message Proof for given transaction id and the message id from MessageOut receipt.

Icon LinkParameters

NameTypeDescription
transactionIdstringThe transaction to get message from.
messageIdstringThe message id from MessageOut receipt.
commitBlockId?stringThe commit block id.
commitBlockHeight?BNThe commit block height.

Icon LinkReturns

Promise<null | MessageProof >

A promise that resolves to the message proof.

Icon LinkDefined in

packages/providers/src/provider.ts:1103 Icon Link


Icon LinkgetMessageStatus

getMessageStatus(nonce): Promise<MessageStatus >

Returns Message Proof for given transaction id and the message id from MessageOut receipt.

Icon LinkParameters

NameTypeDescription
noncestringThe nonce of the message to get status from.

Icon LinkReturns

Promise<MessageStatus >

A promise that resolves to the message status

Icon LinkDefined in

packages/providers/src/provider.ts:1211 Icon Link


Icon LinkgetMessages

getMessages(address, paginationArgs?): Promise<Message []>

Returns message for the given address.

Icon LinkParameters

NameTypeDescription
addressAbstractAddress The address to get message from.
paginationArgs?CursorPaginationArgsPagination arguments.

Icon LinkReturns

Promise<Message []>

A promise that resolves to the messages.

Icon LinkDefined in

packages/providers/src/provider.ts:1063 Icon Link


Icon LinkgetNode

getNode(): NodeInfo

Returns the cached nodeInfo for the current URL.

Icon LinkReturns

NodeInfo

Icon LinkDefined in

packages/providers/src/provider.ts:299 Icon Link


Icon LinkgetResourcesToSpend

getResourcesToSpend(owner, quantities, excludedIds?): Promise<Resource []>

Returns resources for the given owner satisfying the spend query.

Icon LinkParameters

NameTypeDescription
ownerAbstractAddress The address to get resources for.
quantitiesCoinQuantityLike []The quantities to get.
excludedIds?ExcludeResourcesOptionIDs of excluded resources from the selection.

Icon LinkReturns

Promise<Resource []>

A promise that resolves to the resources.

Icon LinkDefined in

packages/providers/src/provider.ts:801 Icon Link


Icon LinkgetTransaction

getTransaction<TTransactionType>(transactionId): Promise<null | Transaction<TTransactionType>>

Get transaction with the given ID.

Icon LinkType parameters

NameType
TTransactionTypevoid

Icon LinkParameters

NameTypeDescription
transactionIdstringID of the transaction.

Icon LinkReturns

Promise<null | Transaction<TTransactionType>>

A promise that resolves to the transaction.

Icon LinkDefined in

packages/providers/src/provider.ts:962 Icon Link


Icon LinkgetTransactionCost

getTransactionCost(transactionRequestLike, tolerance?): Promise<TransactionCost >

Returns a transaction cost to enable user to set gasLimit and also reserve balance amounts on the the transaction.

Icon LinkParameters

NameTypeDefault valueDescription
transactionRequestLikeTransactionRequestLike undefinedThe transaction request object.
tolerancenumber0.2The tolerance to add on top of the gasUsed.

Icon LinkReturns

Promise<TransactionCost >

A promise that resolves to the transaction cost object.

Icon LinkDefined in

packages/providers/src/provider.ts:725 Icon Link


Icon LinkgetVersion

getVersion(): Promise<string>

Returns the version of the connected node.

Icon LinkReturns

Promise<string>

A promise that resolves to the version string.

Icon LinkDefined in

packages/providers/src/provider.ts:448 Icon Link


Icon LinkproduceBlocks

produceBlocks(amount, startTime?): Promise<BN>

Lets you produce blocks with custom timestamps and the block number of the last block produced.

Icon LinkParameters

NameTypeDescription
amountnumberThe amount of blocks to produce
startTime?numberThe UNIX timestamp to set for the first produced block

Icon LinkReturns

Promise<BN>

A promise that resolves to the block number of the last produced block.

Icon LinkDefined in

packages/providers/src/provider.ts:1226 Icon Link


Icon LinksendTransaction

sendTransaction(transactionRequestLike): 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.

Icon LinkParameters

NameTypeDescription
transactionRequestLikeTransactionRequestLike The transaction request object.

Icon LinkReturns

Promise<TransactionResponse >

A promise that resolves to the transaction response object.

Icon LinkDefined in

packages/providers/src/provider.ts:542 Icon Link


Icon Linksimulate

simulate(transactionRequestLike): 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

Icon LinkParameters

NameTypeDescription
transactionRequestLikeTransactionRequestLike The transaction request object.

Icon LinkReturns

Promise<CallResult >

A promise that resolves to the call result object.

Icon LinkDefined in

packages/providers/src/provider.ts:696 Icon Link


Icon LinkswitchUrl

switchUrl(url): Promise<void>

Updates the URL for the provider and fetches the consensus parameters for the new URL, if needed.

Icon LinkParameters

NameType
urlstring

Icon LinkReturns

Promise<void>

Icon LinkDefined in

packages/providers/src/provider.ts:329 Icon Link


Icon LinkadaptSubscriptionResponse

Private Static adaptSubscriptionResponse(originalResponse): Promise<Response>

The subscription response processing serves two purposes:

  1. To add an event field which is mandated by the graphql-sse library (not by the SSE protocol) (see the library's protocol Icon Link)
  2. To process the node's response because it's a different format to the types generated by graphql-codegen.

Icon LinkParameters

NameType
originalResponseResponse

Icon LinkReturns

Promise<Response>

Icon LinkDefined in

packages/providers/src/provider.ts:431 Icon Link


Icon Linkcreate

Static create(url, options?): Promise<Provider >

Creates a new instance of the Provider class. This is the recommended way to initialize a Provider.

Icon LinkParameters

NameTypeDescription
urlstringGraphQL endpoint of the Fuel node
optionsPartial<ProviderOptions <Response>>Additional options for the provider

Icon LinkReturns

Promise<Provider >

Icon LinkDefined in

packages/providers/src/provider.ts:276 Icon Link


Icon LinkcreateSubscriptionClient

Private Static createSubscriptionClient(url, fetchFn, options): Client

Icon LinkParameters

NameType
urlstring
fetchFnCustomFetch <Response>
optionsProviderOptions <Response>

Icon LinkReturns

Client

Icon LinkDefined in

packages/providers/src/provider.ts:396 Icon Link


Icon LinkgetFetchFn

Private Static getFetchFn(options): CustomFetch <Response>

Icon LinkParameters

NameType
optionsProviderOptions <Response>

Icon LinkReturns

CustomFetch <Response>

Icon LinkDefined in

packages/providers/src/provider.ts:239 Icon Link

Was this page helpful?