Class: Predicate<TData, TConfigurables>
@fuel-ts/account.Predicate
Predicate
provides methods to populate transaction data with predicate information and sending transactions with them.
Type parameters
Name | Type |
---|---|
TData | extends InputValue [] = InputValue [] |
TConfigurables | extends { [name: string] : unknown ; } | undefined = { [name: string] : unknown ; } |
Hierarchy
↳
Predicate
Constructors
constructor
• new Predicate<TData
, TConfigurables
>(«destructured»
): Predicate
<TData
, TConfigurables
>
Creates an instance of the Predicate class.
Type parameters
Name | Type |
---|---|
TData | extends InputValue [] = InputValue [] |
TConfigurables | extends undefined | { [name: string] : unknown ; } = { [name: string] : unknown ; } |
Parameters
Name | Type |
---|---|
«destructured» | PredicateParams <TData , TConfigurables > |
Returns
Predicate
<TData
, TConfigurables
>
Overrides
Defined in
packages/account/src/predicate/predicate.ts:59
Properties
_connector
• Protected
Optional
_connector: FuelConnector
The connector for use with external wallets
Inherited from
Defined in
packages/account/src/account.ts:85
_provider
• Protected
Optional
_provider: Provider
The provider used to interact with the network.
Inherited from
Defined in
packages/account/src/account.ts:80
address
• Readonly
address: AbstractAddress
The address associated with the account.
Inherited from
Defined in
packages/account/src/account.ts:75
bytes
• bytes: Uint8Array
Defined in
packages/account/src/predicate/predicate.ts:46
interface
• Optional
interface: Interface
Defined in
packages/account/src/predicate/predicate.ts:48
predicateData
• predicateData: TData
Defined in
packages/account/src/predicate/predicate.ts:47
Accessors
provider
• get
provider(): Provider
The provider used to interact with the network.
Throws
FuelError
if the provider is not set.
Returns
A Provider instance.
Inherited from
Account.provider
Defined in
packages/account/src/account.ts:108
• set
provider(provider
): void
Sets the provider for the account.
Parameters
Name | Type | Description |
---|---|---|
provider | Provider | A Provider instance. |
Returns
void
Inherited from
Account.provider
Defined in
packages/account/src/account.ts:121
Methods
addBatchTransfer
▸ addBatchTransfer(request
, transferParams
): ScriptTransactionRequest
Adds multiple transfers to a script transaction request.
Parameters
Name | Type | Description |
---|---|---|
request | ScriptTransactionRequest | The script transaction request to add transfers to. |
transferParams | TransferParams [] | An array of TransferParams objects representing the transfers to be made. |
Returns
The updated script transaction request.
Inherited from
Defined in
packages/account/src/account.ts:405
addTransfer
▸ addTransfer(request
, transferParams
): ScriptTransactionRequest
Adds a transfer to the given transaction request.
Parameters
Name | Type | Description |
---|---|---|
request | ScriptTransactionRequest | The script transaction request to add transfers to. |
transferParams | TransferParams | The object representing the transfer to be made. |
Returns
The updated transaction request with the added transfer.
Inherited from
Defined in
packages/account/src/account.ts:387
batchTransfer
▸ batchTransfer(transferParams
, txParams?
): Promise
<TransactionResponse
>
Transfers multiple amounts of a token to multiple recipients.
Parameters
Name | Type | Description |
---|---|---|
transferParams | TransferParams [] | An array of TransferParams objects representing the transfers to be made. |
txParams | TxParamsType | Optional transaction parameters. |
Returns
Promise
<TransactionResponse
>
A promise that resolves to a TransactionResponse
object representing the transaction result.
Inherited from
Defined in
packages/account/src/account.ts:370
connect
▸ connect(provider
): Provider
Changes the provider connection for the account.
Parameters
Name | Type | Description |
---|---|---|
provider | Provider | A Provider instance. |
Returns
The updated Provider instance.
Inherited from
Defined in
packages/account/src/account.ts:131
createTransfer
▸ createTransfer(destination
, amount
, assetId?
, txParams?
): Promise
<ScriptTransactionRequest
>
A helper that creates a transfer transaction request and returns it.
Parameters
Name | Type | Description |
---|---|---|
destination | string | AbstractAddress | The address of the destination. |
amount | BigNumberish | The amount of coins to transfer. |
assetId? | BytesLike | The asset ID of the coins to transfer (optional). |
txParams | TxParamsType | The transaction parameters (optional). |
Returns
Promise
<ScriptTransactionRequest
>
A promise that resolves to the prepared transaction request.
Inherited from
Defined in
packages/account/src/account.ts:332
fund
▸ fund<T
>(request
, params
): Promise
<T
>
Funds a transaction request by adding the necessary resources.
Type parameters
Name | Type | Description |
---|---|---|
T | extends TransactionRequest | The type of the TransactionRequest. |
Parameters
Name | Type | Description |
---|---|---|
request | T | The transaction request to fund. |
params | EstimatedTxParams | The estimated transaction parameters. |
Returns
Promise
<T
>
A promise that resolves to the funded transaction request.
Inherited from
Defined in
packages/account/src/account.ts:201
generateFakeResources
▸ generateFakeResources(coins
): Resource
[]
Generates an array of fake resources based on the provided coins.
Parameters
Name | Type | Description |
---|---|---|
coins | FakeResources [] | An array of FakeResources objects representing the coins. |
Returns
Resource
[]
An array of Resource
objects with generated properties.
Overrides
Defined in
packages/account/src/predicate/predicate.ts:212
getBalance
▸ getBalance(assetId?
): Promise
<BN
>
Retrieves the balance of the account for the given asset.
Parameters
Name | Type | Description |
---|---|---|
assetId? | BytesLike | The asset ID to check the balance for (optional). |
Returns
Promise
<BN
>
A promise that resolves to the balance amount.
Inherited from
Defined in
packages/account/src/account.ts:178
getBalances
▸ getBalances(): Promise
<GetBalancesResponse
>
Retrieves all the balances for the account.
Returns
Promise
<GetBalancesResponse
>
A promise that resolves to an array of Coins and their quantities.
Inherited from
Defined in
packages/account/src/account.ts:189
getCoins
▸ getCoins(assetId?
, paginationArgs?
): Promise
<GetCoinsResponse
>
Retrieves coins owned by the account.
Parameters
Name | Type | Description |
---|---|---|
assetId? | BytesLike | The asset ID of the coins to retrieve (optional). |
paginationArgs? | CursorPaginationArgs | - |
Returns
Promise
<GetCoinsResponse
>
A promise that resolves to an array of Coins.
Inherited from
Defined in
packages/account/src/account.ts:156
getIndexFromPlaceholderWitness
▸ getIndexFromPlaceholderWitness(request
): number
Returns the index of the witness placeholder that was added to this predicate. If no witness placeholder was added, it returns -1.
Parameters
Name | Type | Description |
---|---|---|
request | TransactionRequest | The transaction request. |
Returns
number
The index of the witness placeholder, or -1 if there is no witness placeholder.
Defined in
packages/account/src/predicate/predicate.ts:280
getMessages
▸ getMessages(paginationArgs?
): Promise
<GetMessagesResponse
>
Retrieves messages owned by the account.
Parameters
Name | Type |
---|---|
paginationArgs? | CursorPaginationArgs |
Returns
Promise
<GetMessagesResponse
>
A promise that resolves to an array of Messages.
Inherited from
Defined in
packages/account/src/account.ts:168
getPredicateData
▸ getPredicateData(): Uint8Array
Returns
Uint8Array
Defined in
packages/account/src/predicate/predicate.ts:134
getResourcesToSpend
▸ getResourcesToSpend(quantities
, excludedIds?
): Promise
<Resource
[]>
Retrieves resources satisfying the spend query for the account.
Parameters
Name | Type | Description |
---|---|---|
quantities | CoinQuantityLike [] | IDs of coins to exclude. |
excludedIds? | ExcludeResourcesOption | IDs of resources to be excluded from the query. |
Returns
Promise
<Resource
[]>
A promise that resolves to an array of Resources.
Overrides
Defined in
packages/account/src/predicate/predicate.ts:190
getTransactionCost
▸ getTransactionCost(transactionRequestLike
, transactionCostParams?
): Promise
<TransactionCost
>
Returns a transaction cost to enable user to set gasLimit and also reserve balance amounts on the transaction.
Parameters
Name | Type | Description |
---|---|---|
transactionRequestLike | TransactionRequestLike | The transaction request object. |
transactionCostParams | TransactionCostParams | The transaction cost parameters (optional). |
Returns
Promise
<TransactionCost
>
A promise that resolves to the transaction cost object.
Inherited from
Defined in
packages/account/src/account.ts:528
populateTransactionPredicateData
▸ populateTransactionPredicateData<T
>(transactionRequestLike
): T
Populates the transaction data with predicate data.
Type parameters
Name | Type |
---|---|
T | extends TransactionRequest |
Parameters
Name | Type | Description |
---|---|---|
transactionRequestLike | TransactionRequestLike | The transaction request-like object. |
Returns
T
The transaction request with predicate data.
Defined in
packages/account/src/predicate/predicate.ts:87
sendTransaction
▸ sendTransaction(transactionRequestLike
): Promise
<TransactionResponse
>
Sends a transaction with the populated predicate data.
Parameters
Name | Type | Description |
---|---|---|
transactionRequestLike | TransactionRequestLike | The transaction request-like object. |
Returns
Promise
<TransactionResponse
>
A promise that resolves to the transaction response.
Overrides
Defined in
packages/account/src/predicate/predicate.ts:118
signTransaction
▸ signTransaction(transactionRequestLike
): Promise
<string
>
Signs a transaction from the account via the connector..
Parameters
Name | Type | Description |
---|---|---|
transactionRequestLike | TransactionRequestLike | The transaction request to sign. |
Returns
Promise
<string
>
A promise that resolves to the signature of the transaction.
Inherited from
Defined in
packages/account/src/account.ts:578
simulateTransaction
▸ simulateTransaction(transactionRequestLike
): Promise
<CallResult
>
Simulates a transaction with the populated predicate data.
Parameters
Name | Type | Description |
---|---|---|
transactionRequestLike | TransactionRequestLike | The transaction request-like object. |
Returns
Promise
<CallResult
>
A promise that resolves to the call result.
Overrides
Defined in
packages/account/src/predicate/predicate.ts:129
transfer
▸ transfer(destination
, amount
, assetId?
, txParams?
): Promise
<TransactionResponse
>
Transfers coins to a destination address.
Parameters
Name | Type | Description |
---|---|---|
destination | string | AbstractAddress | The address of the destination. |
amount | BigNumberish | The amount of coins to transfer. |
assetId? | BytesLike | The asset ID of the coins to transfer (optional). |
txParams | TxParamsType | The transaction parameters (optional). |
Returns
Promise
<TransactionResponse
>
A promise that resolves to the transaction response.
Inherited from
Defined in
packages/account/src/account.ts:353
transferToContract
▸ transferToContract(contractId
, amount
, assetId?
, txParams?
): Promise
<TransactionResponse
>
Transfers coins to a contract address.
Parameters
Name | Type | Description |
---|---|---|
contractId | string | AbstractAddress | The address of the contract. |
amount | BigNumberish | The amount of coins to transfer. |
assetId? | BytesLike | The asset ID of the coins to transfer (optional). |
txParams | TxParamsType | The transaction parameters (optional). |
Returns
Promise
<TransactionResponse
>
A promise that resolves to the transaction response.
Inherited from
Defined in
packages/account/src/account.ts:426
withdrawToBaseLayer
▸ withdrawToBaseLayer(recipient
, amount
, txParams?
): Promise
<TransactionResponse
>
Withdraws an amount of the base asset to the base chain.
Parameters
Name | Type | Description |
---|---|---|
recipient | string | AbstractAddress | Address of the recipient on the base chain. |
amount | BigNumberish | Amount of base asset. |
txParams | TxParamsType | The transaction parameters (optional). |
Returns
Promise
<TransactionResponse
>
A promise that resolves to the transaction response.
Inherited from
Defined in
packages/account/src/account.ts:479
processPredicateData
▸ processPredicateData(bytes
, jsonAbi?
, configurableConstants?
): Object
Processes the predicate data and returns the altered bytecode and interface.
Parameters
Name | Type | Description |
---|---|---|
bytes | BytesLike | The bytes of the predicate. |
jsonAbi? | JsonAbi | The JSON ABI of the predicate. |
configurableConstants? | Object | Optional configurable constants for the predicate. |
Returns
Object
An object containing the new predicate bytes and interface.
Name | Type |
---|---|
predicateBytes | Uint8Array |
predicateInterface | undefined | Interface |
Defined in
packages/account/src/predicate/predicate.ts:151
setConfigurableConstants
▸ setConfigurableConstants(bytes
, configurableConstants
, abiInterface?
): Uint8Array
Sets the configurable constants for the predicate.
Parameters
Name | Type | Description |
---|---|---|
bytes | Uint8Array | The bytes of the predicate. |
configurableConstants | Object | Configurable constants to be set. |
abiInterface? | Interface | The ABI interface of the predicate. |
Returns
Uint8Array
The mutated bytes with the configurable constants set.
Defined in
packages/account/src/predicate/predicate.ts:228