# 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.
# 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.
# 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.
# 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!
Methods
# async restoreFootprint()
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.
- 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
# async send()
Sends the transaction to the network to return a SentTransaction
that
keeps track of all the attempts to fetch the transaction.
# toJSON()
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.
# toXDR()
Serialize the AssembledTransaction to a base64-encoded XDR string.
# static build()
Construct a new AssembledTransaction. This is the main way to create a new AssembledTransaction; the 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.
If you need to create an operation other than invokeHostFunction
, you
can use AssembledTransaction.buildWithOp instead.
Example
const tx = await AssembledTransaction.build({
...,
simulate: false,
})
# async static buildWithOp()
Construct a new AssembledTransaction, specifying an Operation other than
invokeHostFunction
(the default used by AssembledTransaction.build).
Note: AssembledTransaction
currently assumes these operations can be
simulated. This is not true for classic operations; only for those used by
Soroban Smart Contracts like invokeHostFunction
and createCustomContract
.
Example
const tx = await AssembledTransaction.buildWithOp(
Operation.createCustomContract({ ... });
{
...,
simulate: false,
}
)
# static fromXDR()
Deserialize the AssembledTransaction from a base64-encoded XDR string.