@fuel-ts/providers.Provider
A provider for connecting to a node
• new Provider(url
, options?
)
Constructor to initialize a Provider.
Name | Type | Description |
---|---|---|
url | string | GraphQL endpoint of the Fuel node |
options | ProviderOptions | Additional options for the provider |
packages/providers/src/provider.ts:221
• Optional
cache: MemoryCache
packages/providers/src/provider.ts:213
• operations: Object
Name | Type |
---|---|
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 > |
packages/providers/src/provider.ts:212
• options: ProviderOptions
= {}
Additional options for the provider
packages/providers/src/provider.ts:224
• url: string
GraphQL endpoint of the Fuel node
packages/providers/src/provider.ts:223
▸ 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.
Name | Type | Description |
---|---|---|
transactionRequestLike | TransactionRequestLike | The transaction request object. |
utxoValidation | ProviderCallParams | Additional provider call parameters. |
Promise
<CallResult
>
A promise that resolves to the call result object.
packages/providers/src/provider.ts:385
▸ connect(url
): void
Connect provider to a different node url.
Name | Type | Description |
---|---|---|
url | string | The URL of the Fuel node to connect to. |
void
packages/providers/src/provider.ts:248
▸ Private
createOperations(url
, options?
): Object
Create GraphQL client and set operations.
Name | Type | Description |
---|---|---|
url | string | The URL of the Fuel node |
options | ProviderOptions | Additional options for the provider |
Object
The operation SDK object
Name | Type |
---|---|
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 > |
packages/providers/src/provider.ts:237
▸ estimatePredicates(transactionRequest
): Promise
<TransactionRequest
>
Verifies whether enough gas is available to complete transaction.
Name | Type | Description |
---|---|---|
transactionRequest | TransactionRequest | The transaction request object. |
Promise
<TransactionRequest
>
A promise that resolves to the estimated transaction request object.
packages/providers/src/provider.ts:408
▸ 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.
Name | Type | Description |
---|---|---|
transactionRequest | TransactionRequest | The transaction request object. |
Promise
<void
>
A promise.
packages/providers/src/provider.ts:445
▸ getBalance(owner
, assetId
): Promise
<BN
>
Returns the balance for the given owner for the given asset ID.
Name | Type | Description |
---|---|---|
owner | AbstractAddress | The address to get coins for. |
assetId | BytesLike | The asset ID of coins to get. |
Promise
<BN
>
A promise that resolves to the balance.
packages/providers/src/provider.ts:816
▸ getBalances(owner
, paginationArgs?
): Promise
<CoinQuantity
[]>
Returns balances for the given owner.
Name | Type | Description |
---|---|---|
owner | AbstractAddress | The address to get coins for. |
paginationArgs? | CursorPaginationArgs | Pagination arguments. |
Promise
<CoinQuantity
[]>
A promise that resolves to the balances.
packages/providers/src/provider.ts:836
▸ getBlock(idOrHeight
): Promise
<null
| Block
>
Returns block matching the given ID or height.
Name | Type | Description |
---|---|---|
idOrHeight | string | number | ID or height of the block. |
Promise
<null
| Block
>
A promise that resolves to the block.
packages/providers/src/provider.ts:672
▸ getBlockNumber(): Promise
<BN
>
Returns the block number.
Promise
<BN
>
A promise that resolves to the block number
packages/providers/src/provider.ts:283
▸ 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.
Name | Type | Description |
---|---|---|
idOrHeight | string | number | ID or height of the block. |
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.
packages/providers/src/provider.ts:726
▸ getBlocks(params
): Promise
<Block
[]>
Returns all the blocks matching the given parameters.
Name | Type | Description |
---|---|---|
params | Exact <{ after? : InputMaybe <string > ; before? : InputMaybe <string > ; first? : InputMaybe <number > ; last? : InputMaybe <number > }> | The parameters to query blocks. |
Promise
<Block
[]>
A promise that resolves to the blocks.
packages/providers/src/provider.ts:707
▸ getChain(): Promise
<ChainInfo
>
Returns chain information.
Promise
<ChainInfo
>
A promise that resolves to the chain information object
packages/providers/src/provider.ts:303
▸ getChainId(): Promise
<number
>
Returns the chain ID
Promise
<number
>
A promise that resolves to the chain ID number
packages/providers/src/provider.ts:312
▸ getCoins(owner
, assetId?
, paginationArgs?
): Promise
<Coin
[]>
Returns coins for the given owner.
Name | Type | Description |
---|---|---|
owner | AbstractAddress | The address to get coins for |
assetId? | BytesLike | The asset ID of coins to get |
paginationArgs? | CursorPaginationArgs | Pagination arguments |
Promise
<Coin
[]>
packages/providers/src/provider.ts:566
▸ getContract(contractId
): Promise
<null
| ContractResult
>
Get deployed contract with the given ID.
Name | Type | Description |
---|---|---|
contractId | string | ID of the contract. |
Promise
<null
| ContractResult
>
A promise that resolves to the contract.
packages/providers/src/provider.ts:781
▸ getContractBalance(contractId
, assetId
): Promise
<BN
>
Returns the balance for the given contract for the given asset ID.
Name | Type | Description |
---|---|---|
contractId | AbstractAddress | The contract ID to get the balance for. |
assetId | BytesLike | The asset ID of coins to get. |
Promise
<BN
>
A promise that resolves to the balance.
packages/providers/src/provider.ts:796
▸ getMessageProof(transactionId
, messageId
, commitBlockId?
, commitBlockHeight?
): Promise
<null
| MessageProof
>
Returns Message Proof for given transaction id and the message id from MessageOut receipt.
Name | Type | Description |
---|---|---|
transactionId | string | The transaction to get message from. |
messageId | string | The message id from MessageOut receipt. |
commitBlockId? | string | The commit block id. |
commitBlockHeight? | BN | The commit block height. |
Promise
<null
| MessageProof
>
A promise that resolves to the message proof.
packages/providers/src/provider.ts:903
▸ getMessages(address
, paginationArgs?
): Promise
<Message
[]>
Returns message for the given address.
Name | Type | Description |
---|---|---|
address | AbstractAddress | The address to get message from. |
paginationArgs? | CursorPaginationArgs | Pagination arguments. |
Promise
<Message
[]>
A promise that resolves to the messages.
packages/providers/src/provider.ts:863
▸ getNodeInfo(): Promise
<NodeInfoAndConsensusParameters
>
Returns node information.
Promise
<NodeInfoAndConsensusParameters
>
A promise that resolves to the node information object.
packages/providers/src/provider.ts:293
▸ getResourcesToSpend(owner
, quantities
, excludedIds?
): Promise
<Resource
[]>
Returns resources for the given owner satisfying the spend query.
Name | Type | Description |
---|---|---|
owner | AbstractAddress | The address to get resources for. |
quantities | CoinQuantityLike [] | The quantities to get. |
excludedIds? | ExcludeResourcesOption | IDs of excluded resources from the selection. |
Promise
<Resource
[]>
A promise that resolves to the resources.
packages/providers/src/provider.ts:601
▸ getTransaction<TTransactionType
>(transactionId
): Promise
<null
| Transaction
<TTransactionType
>>
Get transaction with the given ID.
Name | Type |
---|---|
TTransactionType | void |
Name | Type | Description |
---|---|---|
transactionId | string | ID of the transaction. |
Promise
<null
| Transaction
<TTransactionType
>>
A promise that resolves to the transaction.
packages/providers/src/provider.ts:762
▸ getTransactionCost(transactionRequestLike
, tolerance?
): Promise
<TransactionCost
>
Returns a transaction cost to enable user to set gasLimit and also reserve balance amounts on the the transaction.
Name | Type | Default value | Description |
---|---|---|---|
transactionRequestLike | TransactionRequestLike | undefined | The transaction request object. |
tolerance | number | 0.2 | The tolerance to add on top of the gasUsed. |
Promise
<TransactionCost
>
A promise that resolves to the transaction cost object.
packages/providers/src/provider.ts:525
▸ getVersion(): Promise
<string
>
Returns the version of the connected node.
Promise
<string
>
A promise that resolves to the version string.
packages/providers/src/provider.ts:257
▸ produceBlocks(amount
, startTime?
): Promise
<BN
>
Lets you produce blocks with custom timestamps and the block number of the last block produced.
Name | Type | Description |
---|---|---|
amount | number | The amount of blocks to produce |
startTime? | number | The UNIX timestamp to set for the first produced block |
Promise
<BN
>
A promise that resolves to the block number of the last produced block.
packages/providers/src/provider.ts:1009
▸ 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.
Name | Type | Description |
---|---|---|
transactionRequestLike | TransactionRequestLike | The transaction request object. |
Promise
<TransactionResponse
>
A promise that resolves to the transaction response object.
packages/providers/src/provider.ts:344
▸ 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
Name | Type | Description |
---|---|---|
transactionRequestLike | TransactionRequestLike | The transaction request object. |
Promise
<CallResult
>
A promise that resolves to the call result object.
Was this page helpful?