@fuel-ts/account .Predicate
Predicate
provides methods to populate transaction data with predicate information and sending transactions with them.
Name | Type |
---|---|
TInputData | extends InputValue [] |
↳ Predicate
• new Predicate<TInputData
>(«destructured»
): Predicate
<TInputData
>
Creates an instance of the Predicate class.
Name | Type |
---|---|
TInputData | extends InputValue [] |
Name | Type |
---|---|
«destructured» | PredicateParams <TInputData > |
Predicate
<TInputData
>
packages/account/src/predicate/predicate.ts:52
• Protected
Optional
_connector: FuelConnector
The connector for use with external wallets
packages/account/src/account.ts:76
• Protected
Optional
_provider: Provider
The provider used to interact with the network.
packages/account/src/account.ts:71
• Readonly
address: AbstractAddress
The address associated with the account.
packages/account/src/account.ts:66
• bytes: Uint8Array
packages/account/src/predicate/predicate.ts:39
• Optional
interface: Interface
<JsonAbi
>
packages/account/src/predicate/predicate.ts:41
• predicateData: TInputData
packages/account/src/predicate/predicate.ts:40
• get
provider(): Provider
The provider used to interact with the network.
Throws
FuelError
if the provider is not set.
A Provider instance.
Account.provider
packages/account/src/account.ts:99
• set
provider(provider
): void
Sets the provider for the account.
Name | Type | Description |
---|---|---|
provider | Provider | A Provider instance. |
void
Account.provider
packages/account/src/account.ts:112
▸ addBatchTransfer(request
, transferParams
): ScriptTransactionRequest
Adds multiple transfers to a script transaction request.
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. |
The updated script transaction request.
packages/account/src/account.ts:454
▸ addTransfer(request
, transferParams
): ScriptTransactionRequest
Adds a transfer to the given transaction request.
Name | Type | Description |
---|---|---|
request | ScriptTransactionRequest | The script transaction request to add transfers to. |
transferParams | TransferParams | The object representing the transfer to be made. |
The updated transaction request with the added transfer.
packages/account/src/account.ts:436
▸ batchTransfer(transferParams
, txParams?
): Promise
<TransactionResponse
>
Transfers multiple amounts of a token to multiple recipients.
Name | Type | Description |
---|---|---|
transferParams | TransferParams [] | An array of TransferParams objects representing the transfers to be made. |
txParams | TxParamsType | Optional transaction parameters. |
Promise
<TransactionResponse
>
A promise that resolves to a TransactionResponse
object representing the transaction result.
packages/account/src/account.ts:419
▸ connect(provider
): Provider
Changes the provider connection for the account.
Name | Type | Description |
---|---|---|
provider | Provider | A Provider instance. |
The updated Provider instance.
packages/account/src/account.ts:122
▸ createTransfer(destination
, amount
, assetId?
, txParams?
): Promise
<TransactionRequest
>
A helper that creates a transfer transaction request and returns it.
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). |
Promise
<TransactionRequest
>
A promise that resolves to the prepared transaction request.
packages/account/src/account.ts:381
▸ fund<T
>(request
, params
): Promise
<T
>
Funds a transaction request by adding the necessary resources.
Name | Type | Description |
---|---|---|
T | extends TransactionRequest | The type of the TransactionRequest. |
Name | Type | Description |
---|---|---|
request | T | The transaction request to fund. |
params | EstimatedTxParams | The estimated transaction parameters. |
Promise
<T
>
A promise that resolves to the funded transaction request.
packages/account/src/account.ts:264
▸ getBalance(assetId?
): Promise
<BN
>
Retrieves the balance of the account for the given asset.
Name | Type | Description |
---|---|---|
assetId? | BytesLike | The asset ID to check the balance for (optional). |
Promise
<BN
>
A promise that resolves to the balance amount.
packages/account/src/account.ts:216
▸ getBalances(): Promise
<CoinQuantity
[]>
Retrieves all the balances for the account.
Promise
<CoinQuantity
[]>
A promise that resolves to an array of Coins and their quantities.
packages/account/src/account.ts:227
▸ getCoins(assetId?
): Promise
<Coin
[]>
Retrieves coins owned by the account.
Name | Type | Description |
---|---|---|
assetId? | BytesLike | The asset ID of the coins to retrieve (optional). |
Promise
<Coin
[]>
A promise that resolves to an array of Coins.
packages/account/src/account.ts:147
▸ 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.
Name | Type | Description |
---|---|---|
request | TransactionRequest | The transaction request. |
number
The index of the witness placeholder, or -1 if there is no witness placeholder.
packages/account/src/predicate/predicate.ts:252
▸ getMessages(): Promise
<Message
[]>
Retrieves messages owned by the account.
Promise
<Message
[]>
A promise that resolves to an array of Messages.
packages/account/src/account.ts:181
▸ getPredicateData(): Uint8Array
Uint8Array
packages/account/src/predicate/predicate.ts:127
▸ getResourcesToSpend(quantities
, excludedIds?
): Promise
<Resource
[]>
Retrieves resources satisfying the spend query for the account.
Name | Type | Description |
---|---|---|
quantities | CoinQuantityLike [] | IDs of coins to exclude. |
excludedIds? | ExcludeResourcesOption | IDs of resources to be excluded from the query. |
Promise
<Resource
[]>
A promise that resolves to an array of Resources.
packages/account/src/predicate/predicate.ts:183
▸ populateTransactionPredicateData<T
>(transactionRequestLike
): T
Populates the transaction data with predicate data.
Name | Type |
---|---|
T | extends TransactionRequest |
Name | Type | Description |
---|---|---|
transactionRequestLike | TransactionRequestLike | The transaction request-like object. |
T
The transaction request with predicate data.
packages/account/src/predicate/predicate.ts:80
▸ sendTransaction(transactionRequestLike
): Promise
<TransactionResponse
>
Sends a transaction with the populated predicate data.
Name | Type | Description |
---|---|---|
transactionRequestLike | TransactionRequestLike | The transaction request-like object. |
Promise
<TransactionResponse
>
A promise that resolves to the transaction response.
packages/account/src/predicate/predicate.ts:111
▸ signTransaction(transactionRequestLike
): Promise
<string
>
Signs a transaction from the account via the connector..
Name | Type | Description |
---|---|---|
transactionRequestLike | TransactionRequestLike | The transaction request to sign. |
Promise
<string
>
A promise that resolves to the signature of the transaction.
packages/account/src/account.ts:589
▸ simulateTransaction(transactionRequestLike
): Promise
<CallResult
>
Simulates a transaction with the populated predicate data.
Name | Type | Description |
---|---|---|
transactionRequestLike | TransactionRequestLike | The transaction request-like object. |
Promise
<CallResult
>
A promise that resolves to the call result.
packages/account/src/predicate/predicate.ts:122
▸ transfer(destination
, amount
, assetId?
, txParams?
): Promise
<TransactionResponse
>
Transfers coins to a destination address.
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). |
Promise
<TransactionResponse
>
A promise that resolves to the transaction response.
packages/account/src/account.ts:402
▸ transferToContract(contractId
, amount
, assetId?
, txParams?
): Promise
<TransactionResponse
>
Transfers coins to a contract address.
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). |
Promise
<TransactionResponse
>
A promise that resolves to the transaction response.
packages/account/src/account.ts:475
▸ withdrawToBaseLayer(recipient
, amount
, txParams?
): Promise
<TransactionResponse
>
Withdraws an amount of the base asset to the base chain.
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). |
Promise
<TransactionResponse
>
A promise that resolves to the transaction response.
packages/account/src/account.ts:529
▸ processPredicateData(bytes
, jsonAbi?
, configurableConstants?
): Object
Processes the predicate data and returns the altered bytecode and interface.
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. |
Object
An object containing the new predicate bytes and interface.
Name | Type |
---|---|
predicateBytes | Uint8Array |
predicateInterface | undefined | Interface <JsonAbi > |
packages/account/src/predicate/predicate.ts:144
▸ setConfigurableConstants(bytes
, configurableConstants
, abiInterface?
): Uint8Array
Sets the configurable constants for the predicate.
Name | Type | Description |
---|---|---|
bytes | Uint8Array | The bytes of the predicate. |
configurableConstants | Object | Configurable constants to be set. |
abiInterface? | Interface <JsonAbi > | The ABI interface of the predicate. |
Uint8Array
The mutated bytes with the configurable constants set.