Predicate
provides methods to populate transaction data with predicate information and sending transactions with them.
Name | Type |
---|
TInputData | extends InputValue [] |
•
new Predicate<
TInputData
>(
«destructured»
):
Predicate
<
TInputData
>
Creates an instance of the Predicate class.
Name | Type |
---|
TInputData | extends InputValue [] |
•
Protected
Optional
_connector:
FuelConnector
•
Protected
Optional
_provider:
Provider
The provider used to interact with the network.
•
Readonly
address:
AbstractAddress
The address associated with the account.
• bytes: Uint8Array
• Optional
interface: Interface
<JsonAbi
>
• predicateData: TInputData
• predicateDataBytes: Uint8Array
•
get
provider():
Provider
The provider used to interact with the network.
Throws
FuelError
if the provider is not set.
A Provider instance.
Account.provider
• set
provider(provider
): void
Sets the provider for the account.
Name | Type | Description |
---|
provider | Provider | A Provider instance. |
void
Account.provider
▸
connect(
provider
):
Provider
Changes the provider connection for the account.
Name | Type | Description |
---|
provider | Provider | A Provider instance. |
The updated Provider instance.
▸
createTransfer(
destination
,
amount
,
assetId?
,
txParams?
):
Promise
<
TransactionRequest
>
A helper that creates a transfer transaction request and returns it.
Name | Type | Default value | Description |
---|
destination | AbstractAddress | undefined | The address of the destination. |
amount | BigNumberish | undefined | The amount of coins to transfer. |
assetId | BytesLike | BaseAssetId | The asset ID of the coins to transfer. |
txParams | TxParamsType | {} | The transaction parameters (gasLimit, gasPrice, maturity). |
A promise that resolves to the prepared transaction request.
Icon Linkfund
▸ fund<T
>(request
, coinQuantities
, fee
): Promise
<void
>
Adds resources to the transaction enough to fund it.
Name | Type | Description |
---|
request | T | The transaction request. |
coinQuantities | CoinQuantity [] | The coin quantities required to execute the transaction. |
fee | BN | The estimated transaction fee. |
Promise
<void
>
A promise that resolves when the resources are added to the transaction.
▸ getBalance(assetId?
): Promise
<BN
>
Retrieves the balance of the account for the given asset.
Name | Type | Default value | Description |
---|
assetId | BytesLike | BaseAssetId | The asset ID to check the balance for. |
Promise
<BN
>
A promise that resolves to the balance amount.
▸
getBalances():
Promise
<
CoinQuantity
[]>
Retrieves all the balances for the account.
A promise that resolves to an array of Coins and their quantities.
▸
getCoins(
assetId?
):
Promise
<
Coin
[]>
Retrieves coins owned by the account.
Name | Type | Description |
---|
assetId? | BytesLike | The asset ID of the coins to retrieve. |
A promise that resolves to an array of Coins.
▸
getMessages():
Promise
<
Message
[]>
Retrieves messages owned by the account.
A promise that resolves to an array of Messages.
▸ getPredicateData(policiesLength
): Uint8Array
Name | Type |
---|
policiesLength | number |
Uint8Array
▸
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. |
A promise that resolves to an array of Resources.
▸
populateTransactionPredicateData(
transactionRequestLike
):
TransactionRequest
Populates the transaction data with predicate data.
The transaction request with predicate data.
▸
sendTransaction(
transactionRequestLike
,
options?
):
Promise
<
TransactionResponse
>
Sends a transaction with the populated predicate data.
A promise that resolves to the transaction response.
▸ signMessage(message
): Promise
<string
>
Promise
<string
>
▸ signTransaction(transactionRequestLike
): Promise
<string
>
Signs a transaction with the wallet's private key.
Promise
<string
>
A promise that resolves to the signature of the transaction.
▸
simulateTransaction(
transactionRequestLike
):
Promise
<
CallResult
>
Simulates a transaction with the populated predicate data.
A promise that resolves to the call result.
▸
transfer(
destination
,
amount
,
assetId?
,
txParams?
):
Promise
<
TransactionResponse
>
Transfers coins to a destination address.
Name | Type | Default value | Description |
---|
destination | string | AbstractAddress | undefined | The address of the destination. |
amount | BigNumberish | undefined | The amount of coins to transfer. |
assetId | BytesLike | BaseAssetId | The asset ID of the coins to transfer. |
txParams | TxParamsType | {} | The transaction parameters (gasLimit, gasPrice, maturity). |
A promise that resolves to the transaction response.
▸
transferToContract(
contractId
,
amount
,
assetId?
,
txParams?
):
Promise
<
TransactionResponse
>
Transfers coins to a contract address.
Name | Type | Default value | Description |
---|
contractId | string | AbstractAddress | undefined | The address of the contract. |
amount | BigNumberish | undefined | The amount of coins to transfer. |
assetId | BytesLike | BaseAssetId | The asset ID of the coins to transfer. |
txParams | TxParamsType | {} | The optional transaction parameters. |
A promise that resolves to the transaction response.
▸
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 optional transaction parameters. |
A promise that resolves to the transaction response.
▸ 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 > |
▸ 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.