Constructor
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
signAuthEntries. Then re-serialize and send to the next account
in this list.
signAndSend
Sign the transaction with the wallet
, included previously. If you did
not previously include one, you need to include one now that at least
includes the signTransaction
method. 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 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 sign the transaction
envelope and send it to the network.
Sending to all needsNonInvokerSigningBy
owners in parallel is not currently
supported!
Methods
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.
(async, static) build()
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.
const tx = await AssembledTransaction.build({
...,
simulate: false,
})