@fuel-ts/account .CreateTransactionRequest
CreateTransactionRequest
provides functionalities for creating a transaction request that creates a contract.
•
new CreateTransactionRequest(
createTransactionRequestLike?
):
CreateTransactionRequest
Creates an instance CreateTransactionRequest
.
Name | Type | Description |
---|
createTransactionRequestLike | CreateTransactionRequestLike | The initial values for the instance |
• bytecodeWitnessIndex: number
Witness index of contract bytecode to create
• gasPrice: BN
Gas price for transaction
List of inputs
• maturity: number
Block until which tx cannot be included
• Optional
maxFee: BN
The maximum fee payable by this transaction using BASE_ASSET.
List of outputs
Icon Linksalt
• salt: string
Salt
• storageSlots: TransactionRequestStorageSlot
[]
List of storage slots to initialize
Icon Linktype
Type of the transaction
• Optional
witnessLimit: BN
The maximum amount of witness data allowed for the transaction
•
witnesses:
BytesLike
[] =
[]
List of witnesses
▸
addAccountWitnesses(
account
):
Promise
<
CreateTransactionRequest
>
Helper function to add an external signature to the transaction.
Name | Type | Description |
---|
account | Account | Account [] | The account/s to sign to the transaction. |
The transaction with the signature witness added.
▸ 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
▸ 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.
Name | Type | Description |
---|
coin | Coin | Coin resource. |
predicate? | Predicate <InputValue []> | Predicate bytes. |
void
▸
addCoinOutput(
to
,
amount
,
assetId?
):
CreateTransactionRequest
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. |
▸
addCoinOutputs(
to
,
quantities
):
CreateTransactionRequest
Adds multiple coin outputs to the transaction.
▸ addContractCreatedOutput(contractId
, stateRoot
): void
Adds a contract created output to the transaction request.
void
▸ 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
▸
addPredicateResource(
resource
,
predicate
):
CreateTransactionRequest
Adds multiple resources to the transaction by adding coin/message inputs and change
outputs from the related assetIds.
This transaction.
▸
addPredicateResources(
resources
,
predicate
):
CreateTransactionRequest
Adds multiple predicate coin/message inputs to the transaction and change outputs
from the related assetIds.
Name | Type | Description |
---|
resources | Resource [] | The resources to add. |
predicate | Predicate <InputValue []> | - |
This transaction.
▸
addResource(
resource
):
CreateTransactionRequest
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.
▸
addResources(
resources
):
CreateTransactionRequest
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.
▸ calculateMaxGas(chainInfo
, minGas
): BN
BN
▸ fundWithFakeUtxos(quantities
, resourcesOwner?
): void
Funds the transaction with fake UTXOs for each assetId and amount in the
quantities array.
void
▸ getBaseTransaction(): ToBaseTransactionResponse
Method to obtain the base transaction details.
ToBaseTransactionResponse
The base transaction details.
Gets the change outputs for a transaction.
The change outputs.
Gets the coin inputs for a transaction.
The coin inputs.
Gets the coin outputs for a transaction.
The coin outputs.
▸
getCoinOutputsQuantities():
CoinQuantity
[]
Retrieves an array of CoinQuantity for each coin output present in the transaction.
a transaction.
CoinQuantity array.
Get contract created outputs for the transaction.
An array of contract created transaction request outputs.
▸ getTransactionId(chainId
): string
Gets the Transaction Request by hashing the transaction.
Name | Type | Description |
---|
chainId | number | The chain ID. |
string
- A hash of the transaction, which is the transaction ID.
▸ metadataGas(gasCosts
): BN
Name | Type |
---|
gasCosts | GqlGasCosts |
BN
BaseTransactionRequest.metadataGas
▸ toJSON(): any
Return the minimum amount in native coins required to create
a transaction.
any
The transaction as a JSON object.
▸ toTransaction(): TransactionCreate
Converts the transaction request to a TransactionCreate
.
TransactionCreate
The transaction create object.
▸ toTransactionBytes(): Uint8Array
Converts the transaction request to a byte array.
Uint8Array
The transaction bytes.
▸ updatePredicateInputs(inputs
): void
void
▸ 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
▸ 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
Icon Linkfrom
Name | Type |
---|
obj | CreateTransactionRequestLike |
▸ getPolicyMeta(req
): Object
Object
Name | Type |
---|
policies | Policy [] |
policyTypes | number |