@fuel-ts/account .ScriptTransactionRequest
ScriptTransactionRequest
provides functionalities for creating a transaction request that uses a script.
↳ ScriptTransactionRequest
• new ScriptTransactionRequest(scriptTransactionRequestLike?
): ScriptTransactionRequest
Constructor for ScriptTransactionRequest
.
Name | Type | Description |
---|---|---|
scriptTransactionRequestLike | ScriptTransactionRequestLike | The initial values for the instance. |
BaseTransactionRequest .constructor
packages/account/src/providers/transaction-request/script-transaction-request.ts:65
• Optional
abis: JsonAbisFromAllCalls
packages/account/src/providers/transaction-request/script-transaction-request.ts:58
• gasLimit: BN
Gas limit for transaction
packages/account/src/providers/transaction-request/script-transaction-request.ts:52
• gasPrice: BN
Gas price for transaction
BaseTransactionRequest .gasPrice
packages/account/src/providers/transaction-request/transaction-request.ts:95
• inputs: TransactionRequestInput
[] = []
List of inputs
BaseTransactionRequest .inputs
packages/account/src/providers/transaction-request/transaction-request.ts:103
• maturity: number
Block until which tx cannot be included
BaseTransactionRequest .maturity
packages/account/src/providers/transaction-request/transaction-request.ts:97
• Optional
maxFee: BN
The maximum fee payable by this transaction using BASE_ASSET.
BaseTransactionRequest .maxFee
packages/account/src/providers/transaction-request/transaction-request.ts:99
• outputs: TransactionRequestOutput
[] = []
List of outputs
BaseTransactionRequest .outputs
packages/account/src/providers/transaction-request/transaction-request.ts:105
• script: Uint8Array
Script to execute
packages/account/src/providers/transaction-request/script-transaction-request.ts:54
• scriptData: Uint8Array
Script input data (parameters)
packages/account/src/providers/transaction-request/script-transaction-request.ts:56
• type: Script
Type of the transaction
packages/account/src/providers/transaction-request/script-transaction-request.ts:50
• Optional
witnessLimit: BN
The maximum amount of witness data allowed for the transaction
BaseTransactionRequest .witnessLimit
packages/account/src/providers/transaction-request/transaction-request.ts:101
• witnesses: BytesLike
[] = []
List of witnesses
BaseTransactionRequest .witnesses
packages/account/src/providers/transaction-request/transaction-request.ts:107
▸ addAccountWitnesses(account
): Promise
<ScriptTransactionRequest
>
Helper function to add an external signature to the transaction.
Promise
<ScriptTransactionRequest
>
The transaction with the signature witness added.
BaseTransactionRequest .addAccountWitnesses
packages/account/src/providers/transaction-request/transaction-request.ts:275
▸ addChangeOutput(to
, assetId?
): void
Adds a change output to the transaction.
Name | Type | Default value | Description |
---|---|---|---|
to | AddressLike | undefined | Address of the owner. |
assetId | BytesLike | BaseAssetId | Asset ID of coin. |
void
BaseTransactionRequest .addChangeOutput
packages/account/src/providers/transaction-request/transaction-request.ts:533
▸ addCoinInput(coin
, predicate?
): void
Adds a single coin input to the transaction and a change output for the related assetId, if one it was not added yet.
void
BaseTransactionRequest .addCoinInput
packages/account/src/providers/transaction-request/transaction-request.ts:351
▸ addCoinOutput(to
, amount
, assetId?
): ScriptTransactionRequest
Adds a coin output to the transaction.
Name | Type | Default value | Description |
---|---|---|---|
to | AddressLike | undefined | Address of the owner. |
amount | BigNumberish | undefined | Amount of coin. |
assetId | BytesLike | BaseAssetId | Asset ID of coin. |
BaseTransactionRequest .addCoinOutput
packages/account/src/providers/transaction-request/transaction-request.ts:497
▸ addCoinOutputs(to
, quantities
): ScriptTransactionRequest
Adds multiple coin outputs to the transaction.
Name | Type | Description |
---|---|---|
to | AddressLike | Address of the destination. |
quantities | CoinQuantityLike [] | Quantities of coins. |
BaseTransactionRequest .addCoinOutputs
packages/account/src/providers/transaction-request/transaction-request.ts:514
▸ addContractInputAndOutput(contract
): ScriptTransactionRequest
Adds a contract input and output to the transaction request.
Name | Type | Description |
---|---|---|
contract | ContractIdLike | The contract ID. |
The current instance of the ScriptTransactionRequest
.
packages/account/src/providers/transaction-request/script-transaction-request.ts:180
▸ addMessageInput(message
, predicate?
): void
Adds a single message input to the transaction and a change output for the baseAssetId, if one it was not added yet.
Name | Type | Description |
---|---|---|
message | MessageCoin | Message resource. |
predicate? | Predicate <InputValue []> | Predicate bytes. |
void
BaseTransactionRequest .addMessageInput
packages/account/src/providers/transaction-request/transaction-request.ts:394
▸ addPredicateResource(resource
, predicate
): ScriptTransactionRequest
Adds multiple resources to the transaction by adding coin/message inputs and change outputs from the related assetIds.
This transaction.
BaseTransactionRequest .addPredicateResource
packages/account/src/providers/transaction-request/transaction-request.ts:467
▸ addPredicateResources(resources
, predicate
): ScriptTransactionRequest
Adds multiple predicate coin/message inputs to the transaction and change outputs from the related assetIds.
This transaction.
BaseTransactionRequest .addPredicateResources
packages/account/src/providers/transaction-request/transaction-request.ts:484
▸ 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.
Name | Type | Description |
---|---|---|
resource | Resource | The resource to add. |
This transaction.
BaseTransactionRequest .addResource
packages/account/src/providers/transaction-request/transaction-request.ts:437
▸ addResources(resources
): ScriptTransactionRequest
Adds multiple resources to the transaction by adding coin/message inputs and change outputs from the related assetIds.
Name | Type | Description |
---|---|---|
resources | readonly Resource [] | The resources to add. |
This transaction.
BaseTransactionRequest .addResources
packages/account/src/providers/transaction-request/transaction-request.ts:454
▸ addVariableOutputs(numberOfVariables?
): number
Adds variable outputs to the transaction request.
Name | Type | Default value | Description |
---|---|---|---|
numberOfVariables | number | 1 | The number of variables to add. |
number
The new length of the outputs array.
packages/account/src/providers/transaction-request/script-transaction-request.ts:143
▸ calculateMaxGas(chainInfo
, minGas
): BN
Name | Type |
---|---|
chainInfo | ChainInfo |
minGas | BN |
BN
BaseTransactionRequest .calculateMaxGas
packages/account/src/providers/transaction-request/script-transaction-request.ts:156
▸ fundWithFakeUtxos(quantities
, resourcesOwner?
): void
Funds the transaction with fake UTXOs for each assetId and amount in the quantities array.
Name | Type | Description |
---|---|---|
quantities | CoinQuantity [] | CoinQuantity Array. |
resourcesOwner? | AbstractAddress | - |
void
BaseTransactionRequest .fundWithFakeUtxos
packages/account/src/providers/transaction-request/transaction-request.ts:600
▸ getBaseTransaction(): ToBaseTransactionResponse
Method to obtain the base transaction details.
ToBaseTransactionResponse
The base transaction details.
BaseTransactionRequest .getBaseTransaction
packages/account/src/providers/transaction-request/transaction-request.ts:165
▸ getChangeOutputs(): ChangeTransactionRequestOutput
[]
Gets the change outputs for a transaction.
ChangeTransactionRequestOutput
[]
The change outputs.
BaseTransactionRequest .getChangeOutputs
packages/account/src/providers/transaction-request/transaction-request.ts:313
▸ getCoinInputs(): CoinTransactionRequestInput
[]
Gets the coin inputs for a transaction.
CoinTransactionRequestInput
[]
The coin inputs.
BaseTransactionRequest .getCoinInputs
packages/account/src/providers/transaction-request/transaction-request.ts:291
▸ getCoinOutputs(): CoinTransactionRequestOutput
[]
Gets the coin outputs for a transaction.
CoinTransactionRequestOutput
[]
The coin outputs.
BaseTransactionRequest .getCoinOutputs
packages/account/src/providers/transaction-request/transaction-request.ts:302
▸ getCoinOutputsQuantities(): CoinQuantity
[]
Retrieves an array of CoinQuantity for each coin output present in the transaction. a transaction.
CoinQuantity
[]
CoinQuantity array.
BaseTransactionRequest .getCoinOutputsQuantities
packages/account/src/providers/transaction-request/transaction-request.ts:647
▸ getContractInputs(): ContractTransactionRequestInput
[]
Get contract inputs for the transaction.
ContractTransactionRequestInput
[]
An array of contract transaction request inputs.
packages/account/src/providers/transaction-request/script-transaction-request.ts:98
▸ getContractOutputs(): ContractTransactionRequestOutput
[]
Get contract outputs for the transaction.
ContractTransactionRequestOutput
[]
An array of contract transaction request outputs.
packages/account/src/providers/transaction-request/script-transaction-request.ts:109
▸ getTransactionId(chainId
): string
Gets the Transaction Request by hashing the transaction.
Name | Type | Description |
---|---|---|
chainId | number | The chain ID. |
string
BaseTransactionRequest .getTransactionId
packages/account/src/providers/transaction-request/script-transaction-request.ts:209
▸ getVariableOutputs(): VariableTransactionRequestOutput
[]
Get variable outputs for the transaction.
VariableTransactionRequestOutput
[]
An array of variable transaction request outputs.
packages/account/src/providers/transaction-request/script-transaction-request.ts:120
▸ metadataGas(gasCosts
): BN
Name | Type |
---|---|
gasCosts | GqlGasCosts |
BN
BaseTransactionRequest.metadataGas
packages/account/src/providers/transaction-request/script-transaction-request.ts:226
▸ setData(abi
, args
): ScriptTransactionRequest
Sets the data for the transaction request.
Name | Type | Description |
---|---|---|
abi | JsonAbi | Script JSON ABI. |
args | InputValue [] | The input arguments. |
The current instance of the ScriptTransactionRequest
.
packages/account/src/providers/transaction-request/script-transaction-request.ts:220
▸ setScript<T
>(script
, data
): void
Set the script and its data.
Name |
---|
T |
Name | Type | Description |
---|---|---|
script | AbstractScriptRequest <T > | The abstract script request. |
data | T | The script data. |
void
packages/account/src/providers/transaction-request/script-transaction-request.ts:132
▸ toJSON(): any
Return the minimum amount in native coins required to create a transaction.
any
The transaction as a JSON object.
BaseTransactionRequest .toJSON
packages/account/src/providers/transaction-request/transaction-request.ts:671
▸ toTransaction(): TransactionScript
Converts the transaction request to a TransactionScript
.
TransactionScript
The transaction script object.
BaseTransactionRequest .toTransaction
packages/account/src/providers/transaction-request/script-transaction-request.ts:78
▸ toTransactionBytes(): Uint8Array
Converts the transaction request to a byte array.
Uint8Array
The transaction bytes.
BaseTransactionRequest .toTransactionBytes
packages/account/src/providers/transaction-request/transaction-request.ts:191
▸ updatePredicateInputs(inputs
): void
Name | Type |
---|---|
inputs | TransactionRequestInput [] |
void
BaseTransactionRequest .updatePredicateInputs
packages/account/src/providers/transaction-request/transaction-request.ts:675
▸ updateWitness(index
, witness
): void
Updates an existing witness without any side effects.
Throws
If the witness does not exist.
Name | Type | Description |
---|---|---|
index | number | The index of the witness to update. |
witness | BytesLike | The new witness. |
void
BaseTransactionRequest .updateWitness
packages/account/src/providers/transaction-request/transaction-request.ts:262
▸ updateWitnessByOwner(address
, signature
): void
Updates the witness for a given owner and signature.
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. |
void
BaseTransactionRequest .updateWitnessByOwner
packages/account/src/providers/transaction-request/transaction-request.ts:247
▸ from(obj
): ScriptTransactionRequest
Name | Type |
---|---|
obj | ScriptTransactionRequestLike |
packages/account/src/providers/transaction-request/script-transaction-request.ts:42
▸ getPolicyMeta(req
): Object
Name | Type |
---|---|
req | BaseTransactionRequest |
Object
Name | Type |
---|---|
policies | Policy [] |
policyTypes | number |
BaseTransactionRequest .getPolicyMeta
packages/account/src/providers/transaction-request/transaction-request.ts:132