Class: Predicate<TInputData>
@fuel-ts/account.Predicate
Predicate provides methods to populate transaction data with predicate information and sending transactions with them.
Type parameters
| Name | Type |
|---|---|
TInputData | extends InputValue[] |
Hierarchy
↳
Predicate
Constructors
constructor
• new Predicate<TInputData>(«destructured»): Predicate<TInputData>
Creates an instance of the Predicate class.
Type parameters
| Name | Type |
|---|---|
TInputData | extends InputValue[] |
Parameters
| Name | Type |
|---|---|
«destructured» | PredicateParams<TInputData> |
Returns
Predicate<TInputData>
Overrides
Defined in
packages/account/src/predicate/predicate.ts:55
Properties
_connector
• Protected Optional _connector: FuelConnector
Inherited from
Defined in
packages/account/src/account.ts:67
_provider
• Protected Optional _provider: Provider
The provider used to interact with the network.
Inherited from
Defined in
packages/account/src/account.ts:65
address
• Readonly address: AbstractAddress
The address associated with the account.
Inherited from
Defined in
packages/account/src/account.ts:60
bytes
• bytes: Uint8Array
Defined in
packages/account/src/predicate/predicate.ts:42
interface
• Optional interface: Interface<JsonAbi>
Defined in
packages/account/src/predicate/predicate.ts:44
predicateData
• predicateData: TInputData
Defined in
packages/account/src/predicate/predicate.ts:43
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:89
• 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:102
Methods
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:112
createTransfer
▸ createTransfer(destination, amount, assetId?, txParams?): Promise<TransactionRequest>
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. |
txParams | TxParamsType | The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit). |
Returns
Promise<TransactionRequest>
A promise that resolves to the prepared transaction request.
Inherited from
Defined in
packages/account/src/account.ts:366
fund
▸ fund<T>(request, params): Promise<T>
Adds resources to the transaction enough to fund it.
Type parameters
| Name | Type |
|---|---|
T | extends TransactionRequest |
Parameters
| Name | Type | Description |
|---|---|---|
request | T | The transaction request. |
params | EstimatedTxParams | - |
Returns
Promise<T>
A promise that resolves when the resources are added to the transaction.
Inherited from
Defined in
packages/account/src/account.ts:254
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. |
Returns
Promise<BN>
A promise that resolves to the balance amount.
Inherited from
Defined in
packages/account/src/account.ts:206
getBalances
▸ getBalances(): Promise<CoinQuantity[]>
Retrieves all the balances for the account.
Returns
Promise<CoinQuantity[]>
A promise that resolves to an array of Coins and their quantities.
Inherited from
Defined in
packages/account/src/account.ts:217
getCoins
▸ getCoins(assetId?): Promise<Coin[]>
Retrieves coins owned by the account.
Parameters
| Name | Type | Description |
|---|---|---|
assetId? | BytesLike | The asset ID of the coins to retrieve. |
Returns
Promise<Coin[]>
A promise that resolves to an array of Coins.
Inherited from
Defined in
packages/account/src/account.ts:137
getMessages
▸ getMessages(): Promise<Message[]>
Retrieves messages owned by the account.
Returns
Promise<Message[]>
A promise that resolves to an array of Messages.
Inherited from
Defined in
packages/account/src/account.ts:171
getPredicateData
▸ getPredicateData(policiesLength): Uint8Array
Parameters
| Name | Type |
|---|---|
policiesLength | number |
Returns
Uint8Array
Defined in
packages/account/src/predicate/predicate.ts:122
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:191
populateTransactionPredicateData
▸ populateTransactionPredicateData(transactionRequestLike): TransactionRequest
Populates the transaction data with predicate data.
Parameters
| Name | Type | Description |
|---|---|---|
transactionRequestLike | TransactionRequestLike | The transaction request-like object. |
Returns
The transaction request with predicate data.
Defined in
packages/account/src/predicate/predicate.ts:83
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:106
signMessage
▸ signMessage(message): Promise<string>
Parameters
| Name | Type |
|---|---|
message | string |
Returns
Promise<string>
Inherited from
Defined in
packages/account/src/account.ts:541
signTransaction
▸ signTransaction(transactionRequestLike): Promise<string>
Signs a transaction with the wallet's private key.
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:554
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:117
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. |
txParams | TxParamsType | The transaction parameters (gasLimit, maturity). |
Returns
Promise<TransactionResponse>
A promise that resolves to the transaction response.
Inherited from
Defined in
packages/account/src/account.ts:407
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. |
txParams | TxParamsType | The optional transaction parameters. |
Returns
Promise<TransactionResponse>
A promise that resolves to the transaction response.
Inherited from
Defined in
packages/account/src/account.ts:437
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 optional transaction parameters. |
Returns
Promise<TransactionResponse>
A promise that resolves to the transaction response.
Inherited from
Defined in
packages/account/src/account.ts:497
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<JsonAbi> |
Defined in
packages/account/src/predicate/predicate.ts:152
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<JsonAbi> | The ABI interface of the predicate. |
Returns
Uint8Array
The mutated bytes with the configurable constants set.