Icon LinkClass: Provider

@fuel-ts/providers.Provider

A provider for connecting to a node

Icon LinkConstructors

Icon Linkconstructor

new Provider(url, options?)

Constructor to initialize a Provider.

Icon LinkParameters

NameTypeDescription
urlstringGraphQL endpoint of the Fuel node
optionsProviderOptionsAdditional options for the provider

Icon LinkDefined in

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

Icon LinkProperties

Icon Linkcache

Optional cache: MemoryCache

Icon LinkDefined in

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


Icon Linkoperations

operations: Object

Icon LinkType declaration

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

Icon LinkDefined in

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


Icon Linkoptions

options: ProviderOptions = {}

Additional options for the provider

Icon LinkDefined in

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


Icon Linkurl

url: string

GraphQL endpoint of the Fuel node

Icon LinkDefined in

packages/providers/src/provider.ts:223 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
transactionRequestLikeTransactionRequestLikeThe transaction request object.
utxoValidationProviderCallParamsAdditional provider call parameters.

Icon LinkReturns

Promise<CallResult>

A promise that resolves to the call result object.

Icon LinkDefined in

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


Icon Linkconnect

connect(url): void

Connect provider to a different node url.

Icon LinkParameters

NameTypeDescription
urlstringThe URL of the Fuel node to connect to.

Icon LinkReturns

void

Icon LinkDefined in

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


Icon LinkcreateOperations

Private createOperations(url, options?): Object

Create GraphQL client and set operations.

Icon LinkParameters

NameTypeDescription
urlstringThe URL of the Fuel node
optionsProviderOptionsAdditional options for the provider

Icon LinkReturns

Object

The operation SDK object

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

Icon LinkDefined in

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


Icon LinkestimatePredicates

estimatePredicates(transactionRequest): Promise<TransactionRequest>

Verifies whether enough gas is available to complete transaction.

Icon LinkParameters

NameTypeDescription
transactionRequestTransactionRequestThe 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:408 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
transactionRequestTransactionRequestThe transaction request object.

Icon LinkReturns

Promise<void>

A promise.

Icon LinkDefined in

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


Icon LinkgetBalance

getBalance(owner, assetId): Promise<BN>

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

Icon LinkParameters

NameTypeDescription
ownerAbstractAddressThe 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:816 Icon Link


Icon LinkgetBalances

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

Returns balances for the given owner.

Icon LinkParameters

NameTypeDescription
ownerAbstractAddressThe 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:836 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:672 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:283 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:726 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:707 Icon Link


Icon LinkgetChain

getChain(): Promise<ChainInfo>

Returns chain information.

Icon LinkReturns

Promise<ChainInfo>

A promise that resolves to the chain information object

Icon LinkDefined in

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


Icon LinkgetChainId

getChainId(): Promise<number>

Returns the chain ID

Icon LinkReturns

Promise<number>

A promise that resolves to the chain ID number

Icon LinkDefined in

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


Icon LinkgetCoins

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

Returns coins for the given owner.

Icon LinkParameters

NameTypeDescription
ownerAbstractAddressThe 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:566 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:781 Icon Link


Icon LinkgetContractBalance

getContractBalance(contractId, assetId): Promise<BN>

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

Icon LinkParameters

NameTypeDescription
contractIdAbstractAddressThe 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:796 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:903 Icon Link


Icon LinkgetMessages

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

Returns message for the given address.

Icon LinkParameters

NameTypeDescription
addressAbstractAddressThe 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:863 Icon Link


Icon LinkgetNodeInfo

getNodeInfo(): Promise<NodeInfoAndConsensusParameters>

Returns node information.

Icon LinkReturns

Promise<NodeInfoAndConsensusParameters>

A promise that resolves to the node information object.

Icon LinkDefined in

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


Icon LinkgetResourcesToSpend

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

Returns resources for the given owner satisfying the spend query.

Icon LinkParameters

NameTypeDescription
ownerAbstractAddressThe 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:601 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:762 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
transactionRequestLikeTransactionRequestLikeundefinedThe 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:525 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:257 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:1009 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
transactionRequestLikeTransactionRequestLikeThe transaction request object.

Icon LinkReturns

Promise<TransactionResponse>

A promise that resolves to the transaction response object.

Icon LinkDefined in

packages/providers/src/provider.ts:344 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
transactionRequestLikeTransactionRequestLikeThe transaction request object.

Icon LinkReturns

Promise<CallResult>

A promise that resolves to the call result object.

Icon LinkDefined in

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

Was this page helpful?