# new AssembledTransaction()
Members
# Errors
A list of the most important errors that various AssembledTransaction methods can throw. Feel free to catch specific errors in your application logic.
Tx
# built
The Transaction as it was built with raw.build()
right before
simulation. Once this is set, modifying raw
will have no effect unless
you call tx.simulate()
again.
# isReadCall
Whether this transaction is a read call. This is determined by the
simulation result and the transaction data. If the transaction is a read
call, it will not need to be signed and sent to the network. If this
returns false
, then you need to call signAndSend
on this transaction.
# needsNonInvokerSigningBy
Get a list of accounts, other than the invoker of the simulation, that need to sign auth entries in this transaction.
Soroban allows multiple people to sign a transaction. Someone needs to sign the final transaction envelope; this person/account is called the invoker, or source. Other accounts might need to sign individual auth entries in the transaction, if they're not also the invoker.
This function returns a list of accounts that need to sign auth entries, assuming that the same invoker/source account will sign the final transaction envelope as signed the initial simulation.
One at a time, for each public key in this array, you will need to
serialize this transaction with toJSON
, send to the owner of that key,
deserialize the transaction with txFromJson
, and call
AssembledTransaction#signAuthEntries. Then re-serialize and send to
the next account in this list.
function
# needsNonInvokerSigningBy
Get a list of accounts, other than the invoker of the simulation, that need to sign auth entries in this transaction.
Soroban allows multiple people to sign a transaction. Someone needs to sign the final transaction envelope; this person/account is called the invoker, or source. Other accounts might need to sign individual auth entries in the transaction, if they're not also the invoker.
This function returns a list of accounts that need to sign auth entries, assuming that the same invoker/source account will sign the final transaction envelope as signed the initial simulation.
One at a time, for each public key in this array, you will need to
serialize this transaction with toJSON
, send to the owner of that key,
deserialize the transaction with txFromJson
, and call
AssembledTransaction#signAuthEntries. Then re-serialize and send to
the next account in this list.
TransactionBuilder
# raw
The TransactionBuilder as constructed in AssembledTransaction.build
. Feel free set simulate: false
to modify
this object before calling tx.simulate()
manually. Example:
const tx = await myContract.myMethod(
{ args: 'for', my: 'method', ... },
{ simulate: false }
);
tx.raw.addMemo(Memo.text('Nice memo, friend!'))
await tx.simulate();
# private server
The Soroban server to use for all RPC calls. This is constructed from the
rpcUrl
in the options.
# sign
Sign the transaction with the signTransaction function included previously. If you did not previously include one, you need to include one now.
function
# sign
Sign the transaction with the signTransaction function included previously. If you did not previously include one, you need to include one now.
# signAndSend
Sign the transaction with the signTransaction
function included previously.
If you did not previously include one, you need to include one now.
After signing, this method will send the transaction to the network and
return a SentTransaction
that keeps track * of all the attempts to fetch the transaction.
function
# signAndSend
Sign the transaction with the signTransaction
function included previously.
If you did not previously include one, you need to include one now.
After signing, this method will send the transaction to the network and
return a SentTransaction
that keeps track * of all the attempts to fetch the transaction.
# signAuthEntries
If AssembledTransaction#needsNonInvokerSigningBy returns a
non-empty list, you can serialize the transaction with toJSON
, send it to
the owner of one of the public keys in the map, deserialize with
txFromJSON
, and call this method on their machine. Internally, this will
use signAuthEntry
function from connected wallet
for each.
Then, re-serialize the transaction and either send to the next
needsNonInvokerSigningBy
owner, or send it back to the original account
who simulated the transaction so they can AssembledTransaction#sign
the transaction envelope and AssembledTransaction#send it to the
network.
Sending to all needsNonInvokerSigningBy
owners in parallel is not
currently supported!
function
# signAuthEntries
If AssembledTransaction#needsNonInvokerSigningBy returns a
non-empty list, you can serialize the transaction with toJSON
, send it to
the owner of one of the public keys in the map, deserialize with
txFromJSON
, and call this method on their machine. Internally, this will
use signAuthEntry
function from connected wallet
for each.
Then, re-serialize the transaction and either send to the next
needsNonInvokerSigningBy
owner, or send it back to the original account
who simulated the transaction so they can AssembledTransaction#sign
the transaction envelope and AssembledTransaction#send it to the
network.
Sending to all needsNonInvokerSigningBy
owners in parallel is not
currently supported!
Api.SimulateTransactionResponse
# simulation
The result of the transaction simulation. This is set after the first call
to simulate
. It is difficult to serialize and deserialize, so it is not
included in the toJSON
and fromJSON
methods. See simulationData
cached, serializable access to the data needed by AssembledTransaction
logic.
# private simulationResult
Cached simulation result. This is set after the first call to AssembledTransaction#simulationData, and is used to facilitate serialization and deserialization of the AssembledTransaction.
Most of the time, if you need this data, you can call
tx.simulation.result
.
If you need access to this data after a transaction has been serialized
and then deserialized, you can call simulationData.result
.
# private simulationTransactionData
Cached simulation transaction data. This is set after the first call to AssembledTransaction#simulationData, and is used to facilitate serialization and deserialization of the AssembledTransaction.
Most of the time, if you need this data, you can call
simulation.transactionData
.
If you need access to this data after a transaction has been serialized
and then deserialized, you can call simulationData.transactionData
.
object
# static Errors
A list of the most important errors that various AssembledTransaction methods can throw. Feel free to catch specific errors in your application logic.
Methods
# isReadCall() → {boolean}
Whether this transaction is a read call. This is determined by the
simulation result and the transaction data. If the transaction is a read
call, it will not need to be signed and sent to the network. If this
returns false
, then you need to call signAndSend
on this transaction.
boolean
# restoreFootprint(restorePreamble, accountopt) → {Promise.<Api.GetTransactionResponse>}
Restores the footprint (resource ledger entries that can be read or written) of an expired transaction.
The method will:
- Build a new transaction aimed at restoring the necessary resources.
- Sign this new transaction if a
signTransaction
handler is provided. - Send the signed transaction to the network.
- Await and return the response from the network.
Preconditions:
- A
signTransaction
function must be provided during the Client initialization. - The provided
restorePreamble
should include a minimum resource fee and valid transaction data.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
restorePreamble |
object
|
The preamble object containing data required to, build the restore transaction. |
|
account |
Account
|
<optional> |
The account that is executing the footprint restore operation. If omitted, will use the account from the AssembledTransaction. |
- Throws an error if no
signTransaction
function is provided during Client initialization.
Error
- Throws a custom error if the restore transaction fails, providing the details of the failure.
AssembledTransaction.Errors.RestoreFailure
Promise.<Api.GetTransactionResponse>
# send() → {Promise.<SentTransaction.<T>>}
Sends the transaction to the network to return a SentTransaction
that
keeps track of all the attempts to fetch the transaction.
Promise.<SentTransaction.<T>>
# toJSON() → {string}
Serialize the AssembledTransaction to a JSON string. This is useful for
saving the transaction to a database or sending it over the wire for
multi-auth workflows. fromJSON
can be used to deserialize the
transaction. This only works with transactions that have been simulated.
string
# static build(options) → {Promise.<AssembledTransaction.<T>>}
Construct a new AssembledTransaction. This is the only way to create a new AssembledTransaction; the main constructor is private.
This is an asynchronous constructor for two reasons:
- It needs to fetch the account from the network to get the current sequence number.
- It needs to simulate the transaction to get the expected fee.
If you don't want to simulate the transaction, you can set simulate
to
false
in the options.
Parameters:
Name | Type | Description |
---|---|---|
options |
AssembledTransactionOptions.<T>
|
Promise.<AssembledTransaction.<T>>
Example
const tx = await AssembledTransaction.build({
...,
simulate: false,
})
# static fromXDR(options, encodedXDR, spec) → {AssembledTransaction.<T>}
Deserialize the AssembledTransaction from a base64-encoded XDR string.
Parameters:
Name | Type | Description |
---|---|---|
options |
Omit.<AssembledTransactionOptions.<T>, ("args"|"method"|"parseResultXdr")>
|
|
encodedXDR |
string
|
|
spec |
Spec
|