Class: ScriptTransactionRequest
@fuel-ts/account.ScriptTransactionRequest
ScriptTransactionRequest
provides functionalities for creating a transaction request that uses a script.
Hierarchy
↳
ScriptTransactionRequest
Constructors
constructor
• new ScriptTransactionRequest(scriptTransactionRequestLike?
): ScriptTransactionRequest
Constructor for ScriptTransactionRequest
.
Parameters
Name | Type | Description |
---|---|---|
scriptTransactionRequestLike | ScriptTransactionRequestLike | The initial values for the instance. |
Returns
Overrides
BaseTransactionRequest.constructor
Defined in
packages/account/src/providers/transaction-request/script-transaction-request.ts:64
Properties
abis
• Optional
abis: JsonAbisFromAllCalls
Defined in
packages/account/src/providers/transaction-request/script-transaction-request.ts:57
gasLimit
• gasLimit: BN
Gas limit for transaction
Defined in
packages/account/src/providers/transaction-request/script-transaction-request.ts:51
inputs
• inputs: TransactionRequestInput
[] = []
List of inputs
Inherited from
Defined in
packages/account/src/providers/transaction-request/transaction-request.ts:108
maturity
• Optional
maturity: number
Block until which tx cannot be included
Inherited from
BaseTransactionRequest.maturity
Defined in
packages/account/src/providers/transaction-request/transaction-request.ts:102
maxFee
• maxFee: BN
The maximum fee payable by this transaction using BASE_ASSET.
Inherited from
Defined in
packages/account/src/providers/transaction-request/transaction-request.ts:104
outputs
• outputs: TransactionRequestOutput
[] = []
List of outputs
Inherited from
BaseTransactionRequest.outputs
Defined in
packages/account/src/providers/transaction-request/transaction-request.ts:110
script
• script: Uint8Array
Script to execute
Defined in
packages/account/src/providers/transaction-request/script-transaction-request.ts:53
scriptData
• scriptData: Uint8Array
Script input data (parameters)
Defined in
packages/account/src/providers/transaction-request/script-transaction-request.ts:55
tip
• Optional
tip: BN
Gas price for transaction
Inherited from
Defined in
packages/account/src/providers/transaction-request/transaction-request.ts:100
type
• type: Script
Type of the transaction
Overrides
Defined in
packages/account/src/providers/transaction-request/script-transaction-request.ts:49
witnessLimit
• Optional
witnessLimit: BN
The maximum amount of witness data allowed for the transaction
Inherited from
BaseTransactionRequest.witnessLimit
Defined in
packages/account/src/providers/transaction-request/transaction-request.ts:106
witnesses
• witnesses: BytesLike
[] = []
List of witnesses
Inherited from
BaseTransactionRequest.witnesses
Defined in
packages/account/src/providers/transaction-request/transaction-request.ts:112
Methods
addAccountWitnesses
▸ addAccountWitnesses(account
): Promise
<ScriptTransactionRequest
>
Helper function to add an external signature to the transaction.
Parameters
Name | Type | Description |
---|---|---|
account | Account | Account [] | The account/s to sign to the transaction. |
Returns
Promise
<ScriptTransactionRequest
>
The transaction with the signature witness added.
Inherited from
BaseTransactionRequest.addAccountWitnesses
Defined in
packages/account/src/providers/transaction-request/transaction-request.ts:281
addChangeOutput
▸ addChangeOutput(to
, assetId
): void
Adds a change output to the transaction.
Parameters
Name | Type | Description |
---|---|---|
to | AddressLike | Address of the owner. |
assetId | BytesLike | Asset ID of coin. |
Returns
void
Inherited from
BaseTransactionRequest.addChangeOutput
Defined in
packages/account/src/providers/transaction-request/transaction-request.ts:503
addCoinInput
▸ addCoinInput(coin
): void
Adds a single coin input to the transaction and a change output for the related assetId, if one it was not added yet.
Parameters
Name | Type | Description |
---|---|---|
coin | Coin | Coin resource. |
Returns
void
Inherited from
BaseTransactionRequest.addCoinInput
Defined in
packages/account/src/providers/transaction-request/transaction-request.ts:355
addCoinOutput
▸ addCoinOutput(to
, amount
, assetId
): ScriptTransactionRequest
Adds a coin output to the transaction.
Parameters
Name | Type | Description |
---|---|---|
to | AddressLike | Address of the owner. |
amount | BigNumberish | Amount of coin. |
assetId | BytesLike | Asset ID of coin. |
Returns
Inherited from
BaseTransactionRequest.addCoinOutput
Defined in
packages/account/src/providers/transaction-request/transaction-request.ts:467
addCoinOutputs
▸ addCoinOutputs(to
, quantities
): ScriptTransactionRequest
Adds multiple coin outputs to the transaction.
Parameters
Name | Type | Description |
---|---|---|
to | AddressLike | Address of the destination. |
quantities | CoinQuantityLike [] | Quantities of coins. |
Returns
Inherited from
BaseTransactionRequest.addCoinOutputs
Defined in
packages/account/src/providers/transaction-request/transaction-request.ts:484
addContractInputAndOutput
▸ addContractInputAndOutput(contract
): ScriptTransactionRequest
Adds a contract input and output to the transaction request.
Parameters
Name | Type | Description |
---|---|---|
contract | ContractIdLike | The contract ID. |
Returns
The current instance of the ScriptTransactionRequest
.
Defined in
packages/account/src/providers/transaction-request/script-transaction-request.ts:190
addMessageInput
▸ addMessageInput(message
): void
Adds a single message input to the transaction and a change output for the asset against the message
Parameters
Name | Type | Description |
---|---|---|
message | MessageCoin | Message resource. |
Returns
void
Inherited from
BaseTransactionRequest.addMessageInput
Defined in
packages/account/src/providers/transaction-request/transaction-request.ts:396
addResource
▸ addResource(resource
): ScriptTransactionRequest
Adds a single resource to the transaction by adding a coin/message input and a change output for the related assetId, if one it was not added yet.
Parameters
Name | Type | Description |
---|---|---|
resource | Resource | The resource to add. |
Returns
This transaction.
Inherited from
BaseTransactionRequest.addResource
Defined in
packages/account/src/providers/transaction-request/transaction-request.ts:437
addResources
▸ addResources(resources
): ScriptTransactionRequest
Adds multiple resources to the transaction by adding coin/message inputs and change outputs from the related assetIds.
Parameters
Name | Type | Description |
---|---|---|
resources | readonly Resource [] | The resources to add. |
Returns
This transaction.
Inherited from
BaseTransactionRequest.addResources
Defined in
packages/account/src/providers/transaction-request/transaction-request.ts:454
addVariableOutputs
▸ addVariableOutputs(numberOfVariables?
): number
Adds variable outputs to the transaction request.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
numberOfVariables | number | 1 | The number of variables to add. |
Returns
number
The new length of the outputs array.
Defined in
packages/account/src/providers/transaction-request/script-transaction-request.ts:142
calculateMaxGas
▸ calculateMaxGas(chainInfo
, minGas
): BN
Calculates the maximum gas for the transaction.
Parameters
Name | Type | Description |
---|---|---|
chainInfo | ChainInfo | The chain information. |
minGas | BN | The minimum gas. |
Returns
BN
the maximum gas.
Overrides
BaseTransactionRequest.calculateMaxGas
Defined in
packages/account/src/providers/transaction-request/script-transaction-request.ts:162
fundWithFakeUtxos
▸ fundWithFakeUtxos(quantities
, baseAssetId
, resourcesOwner?
): void
Funds the transaction with fake UTXOs for each assetId and amount in the quantities array.
Parameters
Name | Type | Description |
---|---|---|
quantities | CoinQuantity [] | CoinQuantity Array. |
baseAssetId | string | The base asset to fund the transaction. |
resourcesOwner? | AbstractAddress | - |
Returns
void
Inherited from
BaseTransactionRequest.fundWithFakeUtxos
Defined in
packages/account/src/providers/transaction-request/transaction-request.ts:578
getBaseTransaction
▸ getBaseTransaction(): ToBaseTransactionResponse
Method to obtain the base transaction details.
Returns
ToBaseTransactionResponse
The base transaction details.
Inherited from
BaseTransactionRequest.getBaseTransaction
Defined in
packages/account/src/providers/transaction-request/transaction-request.ts:171
getChangeOutputs
▸ getChangeOutputs(): ChangeTransactionRequestOutput
[]
Gets the change outputs for a transaction.
Returns
ChangeTransactionRequestOutput
[]
The change outputs.
Inherited from
BaseTransactionRequest.getChangeOutputs
Defined in
packages/account/src/providers/transaction-request/transaction-request.ts:319
getCoinInputs
▸ getCoinInputs(): CoinTransactionRequestInput
[]
Gets the coin inputs for a transaction.
Returns
The coin inputs.
Inherited from
BaseTransactionRequest.getCoinInputs
Defined in
packages/account/src/providers/transaction-request/transaction-request.ts:297
getCoinOutputs
▸ getCoinOutputs(): CoinTransactionRequestOutput
[]
Gets the coin outputs for a transaction.
Returns
CoinTransactionRequestOutput
[]
The coin outputs.
Inherited from
BaseTransactionRequest.getCoinOutputs
Defined in
packages/account/src/providers/transaction-request/transaction-request.ts:308
getCoinOutputsQuantities
▸ getCoinOutputsQuantities(): CoinQuantity
[]
Retrieves an array of CoinQuantity for each coin output present in the transaction. a transaction.
Returns
CoinQuantity array.
Inherited from
BaseTransactionRequest.getCoinOutputsQuantities
Defined in
packages/account/src/providers/transaction-request/transaction-request.ts:627
getContractInputs
▸ getContractInputs(): ContractTransactionRequestInput
[]
Get contract inputs for the transaction.
Returns
ContractTransactionRequestInput
[]
An array of contract transaction request inputs.
Defined in
packages/account/src/providers/transaction-request/script-transaction-request.ts:97
getContractOutputs
▸ getContractOutputs(): ContractTransactionRequestOutput
[]
Get contract outputs for the transaction.
Returns
ContractTransactionRequestOutput
[]
An array of contract transaction request outputs.
Defined in
packages/account/src/providers/transaction-request/script-transaction-request.ts:108
getTransactionId
▸ getTransactionId(chainId
): string
Gets the Transaction Request by hashing the transaction.
Parameters
Name | Type | Description |
---|---|---|
chainId | number | The chain ID. |
Returns
string
- A hash of the transaction, which is the transaction ID.
Overrides
BaseTransactionRequest.getTransactionId
Defined in
packages/account/src/providers/transaction-request/script-transaction-request.ts:219
getVariableOutputs
▸ getVariableOutputs(): VariableTransactionRequestOutput
[]
Get variable outputs for the transaction.
Returns
VariableTransactionRequestOutput
[]
An array of variable transaction request outputs.
Defined in
packages/account/src/providers/transaction-request/script-transaction-request.ts:119
metadataGas
▸ metadataGas(gasCosts
): BN
Parameters
Name | Type |
---|---|
gasCosts | GasCosts |
Returns
BN
Overrides
BaseTransactionRequest.metadataGas
Defined in
packages/account/src/providers/transaction-request/script-transaction-request.ts:236
removeWitness
▸ removeWitness(index
): void
Parameters
Name | Type |
---|---|
index | number |
Returns
void
Inherited from
BaseTransactionRequest.removeWitness
Defined in
packages/account/src/providers/transaction-request/transaction-request.ts:655
setData
▸ setData(abi
, args
): ScriptTransactionRequest
Sets the data for the transaction request.
Parameters
Name | Type | Description |
---|---|---|
abi | JsonAbi | Script JSON ABI. |
args | InputValue [] | The input arguments. |
Returns
The current instance of the ScriptTransactionRequest
.
Defined in
packages/account/src/providers/transaction-request/script-transaction-request.ts:230
setScript
▸ setScript<T
>(script
, data
): void
Set the script and its data.
Type parameters
Name |
---|
T |
Parameters
Name | Type | Description |
---|---|---|
script | AbstractScriptRequest <T > | The abstract script request. |
data | T | The script data. |
Returns
void
Defined in
packages/account/src/providers/transaction-request/script-transaction-request.ts:131
toJSON
▸ toJSON(): any
Return the minimum amount in native coins required to create a transaction.
Returns
any
The transaction as a JSON object.
Inherited from
Defined in
packages/account/src/providers/transaction-request/transaction-request.ts:651
toTransaction
▸ toTransaction(): TransactionScript
Converts the transaction request to a TransactionScript
.
Returns
TransactionScript
The transaction script object.
Overrides
BaseTransactionRequest.toTransaction
Defined in
packages/account/src/providers/transaction-request/script-transaction-request.ts:77
toTransactionBytes
▸ toTransactionBytes(): Uint8Array
Converts the transaction request to a byte array.
Returns
Uint8Array
The transaction bytes.
Inherited from
BaseTransactionRequest.toTransactionBytes
Defined in
packages/account/src/providers/transaction-request/transaction-request.ts:197
updatePredicateGasUsed
▸ updatePredicateGasUsed(inputs
): void
Parameters
Name | Type |
---|---|
inputs | TransactionRequestInput [] |
Returns
void
Inherited from
BaseTransactionRequest.updatePredicateGasUsed
Defined in
packages/account/src/providers/transaction-request/transaction-request.ts:669
updateWitness
▸ updateWitness(index
, witness
): void
Updates an existing witness without any side effects.
Throws
If the witness does not exist.
Parameters
Name | Type | Description |
---|---|---|
index | number | The index of the witness to update. |
witness | BytesLike | The new witness. |
Returns
void
Inherited from
BaseTransactionRequest.updateWitness
Defined in
packages/account/src/providers/transaction-request/transaction-request.ts:268
updateWitnessByOwner
▸ updateWitnessByOwner(address
, signature
): void
Updates the witness for a given owner and signature.
Parameters
Name | Type | Description |
---|---|---|
address | string | AbstractAddress | The address to get the coin input witness index for. |
signature | BytesLike | The signature to update the witness with. |
Returns
void
Inherited from
BaseTransactionRequest.updateWitnessByOwner
Defined in
packages/account/src/providers/transaction-request/transaction-request.ts:253
from
▸ from(obj
): ScriptTransactionRequest
Parameters
Name | Type |
---|---|
obj | ScriptTransactionRequestLike |
Returns
Defined in
packages/account/src/providers/transaction-request/script-transaction-request.ts:41
getPolicyMeta
▸ getPolicyMeta(req
): Object
Parameters
Name | Type |
---|---|
req | BaseTransactionRequest |
Returns
Object
Name | Type |
---|---|
policies | Policy [] |
policyTypes | number |
Inherited from
BaseTransactionRequest.getPolicyMeta
Defined in
packages/account/src/providers/transaction-request/transaction-request.ts:137